Exceeding the permissible coordinate zone

不打扰是莪最后的温柔 提交于 2019-12-13 08:59:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!