I have a question. so I have a query into "txt". txt is a column of one of my table(opt_xel_views) and i want to know how to execute the query that is in txt.
Here is my code
I have a question. so I have a query into "txt". txt is a column of one of my table(opt_xel_views) and i want to know how to execute the query that is in txt.
Here is my code
There is not enough context, but probably what you want is:
CREATE OR REPLACE FUNCTION opt_z00_batch(psBatNam VARCHAR(70)) RETURNS void AS $$
DECLARE
r record;
BEGIN
FOR r IN
Select y8_name,y8_order,y8_step,y8_query,y8_count, y8_comment, txt
From opt_xel_batchs
inner join opt_xel_views
On y8_query = id
Where y8_name = psBatNam
Order by y8_order
LOOP
execute r.txt;
INSERT INTO opt_xel_log(z_log_dat, z_bat_nam, z_bat_stp, z_bat_ord, z_bat_com, a_nbr_upd) values(current_timestamp, psBatNam , r.y8_query, r.y8_order, r.y8_comment, 1);
END LOOP;
END;
$$ LANGUAGE plpgsql;