问题
I work in apex oracle, I have a table with geo-coordinates and objects. When I seal this object, I fill out the form. When I fill out this form, I select an object from the LoV from the "test1" table, also in the form of automatically pulling my location into cells P1_long, and P1_lati. I wish that when I stored this form in the "test2" table, I calculated the difference of geo-coordinates between the geodata that is in the "test1" table and in my form. And if this difference is more than -+0.001 then an entry was made in the table "ero_tabel" that the geo-coordinates are violated I created a dynamic promotion, and I'm trying to write something like this
CREATE TABLE test1
(
objects_name varcahar2(10),
geo-latit varcahar2(20),
geo-long varcahar2(20)
);
INSERT INTO test1
VALUES ('House', '60.2311699999996', '12.454977900000003');
CREATE TABLE test2
(
id number(),
data_seals date(),
objects_name varcahar2(10),
geo-latit varcahar2(20),
geo-long varcahar2(20)
);
CREATE TABLE eror_table
(
id number(),
data_err date(),
objects_name varcahar2(10),
);
Declare
Begin
if (to_number(:P1_long) - (select geo-long from test1 where
objects_name = P1_SEALING_OBJECT )) > 0.001 then
INSERT INTO eror_table
VALUES ('1', sysdate, 'P1_SEALING_OBJECT);
end if;
end;
回答1:
I can see a few issues (need a variable to hold the data, a query can not be directly used in IF
) in your code and Updated your code block as follows:
DECLARE
LV_GEO_LONG TEST1.GEO_LONG%TYPE; -- variable to hold geo_long
BEGIN
SELECT
GEO_LONG
INTO LV_GEO_LONG -- storing geo_long value to newly defined variable
FROM
TEST1
WHERE
OBJECTS_NAME = P1_SEALING_OBJECT;
IF ABS(TO_NUMBER(:P1_LONG) - LV_GEO_LONG) > 0.001 THEN -- checking for the difference
INSERT INTO EROR_TABLE VALUES (
'1',
SYSDATE,
P1_SEALING_OBJECT
);
END IF;
END;
/
Cheers!!
来源:https://stackoverflow.com/questions/57902052/exceeding-the-permissible-coordinate-zone