I have the following SELECT which I want to change into an anonymous block (need to use an anonymous block as doing it within Java and do not have access to created stored functionality) in order to remove the use of the literal into a bind variable:
SELECT IL.LAT_NUM, IL.LNGTD_NUM
FROM ITEM_LOCATION IL
WHERE IL.ITEM_ID = 294341;
I have two anonymous blocks created but am unable to find how to return the values created in both:
1)
DECLARE
itemID number;
latitude number;
longitude number;
BEGIN
itemID := 294341;
SELECT
IL.LAT_NUM,
IL.LNGTD_NUM,
INTO
latitude,
longitude,
FROM
ITEM_LOCATION IL
WHERE
IL.ITEM_ID = itemID ;
END;
2)
DECLARE
TYPE t_ref_cursor IS REF CURSOR;
c_cursor t_ref_cursor;
itemID number;
latitude ITEM_LOCATION.LAT_NUM%TYPE;
longitude ITEM_LOCATION.LNGTD_NUM%TYPE;
BEGIN
itemID := 294341;
OPEN c_cursor FOR
SELECT
IL.LAT_NUM,
IL.LNGTD_NUM,
FROM
ITEM_LOCATION IL
WHERE
IL.ITEM_ID = itemID ;
CLOSE c_cursor;
END;
Does anyone know how either/both of these blocks can return as if it were the SELECT above?