CREATE OR REPLACE FUNCTION layer2layerAttribute RETURN VARCHAR2 AS
/**
* This function properly joins all layers to their appropriate fields
*/
cursor PLACES is select * from layer l where l.layer_name like '%place%';
BEGIN
FOR place IN PLACES
LOOP
Insert all
into LAYER_JOIN_LAYER_ATTRIBUTE (ID_LAYER, ID_LAYER_ATTRIBUTE)
values (place.id_layer, select id_layer_attribute from layer_attribute where name_attribute = 'filter.street')
into LAYER_JOIN_LAYER_ATTRIBUTE (ID_LAYER, ID_LAYER_ATTRIBUTE)
values (place.id_layer, select id_layer_attribute from layer_attribute where name_attribute = 'filter.city')
into LAYER_JOIN_LAYER_ATTRIBUTE (ID_LAYER, ID_LAYER_ATTRIBUTE)
values (place.id_layer, select id_layer_attribute from layer_attribute where name_attribute = 'filter.state')
into LAYER_JOIN_LAYER_ATTRIBUTE (ID_LAYER, ID_LAYER_ATTRIBUTE)
values (place.id_layer, select id_layer_attribute from layer_attribute where name_attribute = 'filter.zip')
into LAYER_JOIN_LAYER_ATTRIBUTE (ID_LAYER, ID_LAYER_ATTRIBUTE)
values (place.id_layer, select id_layer_attribute from layer_attribute where name_attribute = 'filter.country')
select * from dual;
END LOOP;
RETURN null;
END layer2layerAttribute;
CREATE OR REPLACE FUNCTION layer2layerAttribute RETURN VARCHAR2 AS /** * This function properly joins
Share
You can, but you can’t use a
selectinside thevaluesclause, or in place of thevaluesclause for eachinto. You can either use values, or a single subquery. (See the syntax diagram). I’m also not sure why you’re using a cursor, rather than having the select fromlayeras the subquery instead of selecting fromdual.You can do this with a single insert though and skip the explicit cursor at the same time; in a procedure (rather than a function since you don’t need to return anything, and functions aren’t generally used when data can be updated) if neccessary:
Although this looks like a one-off task to populate a new table, so you might be able to run it as a simple SQL statement. If it isn’t a one-off then you’ll get duplicates on the second execution unless you check and exclude them.