example for using execute block to insert data using parameters for column names
I dont know if this is possible but I am looking for any example using execute block to execute Insert statement and insert data using parameters for column names
pseudo code:
While loop_counter begin
Insert into table1 (f1+loop_counter, f2+loop_counter, f3+loop_counter, f4+loop_counter)
values (#,#,#,#)
end
where开发者_开发百科 "f" is the first initial of the field name and "loop_counter" is a loop variable
Thanks
You need in EXECUTE STATEMENT operator. Try something like this:
EXECUTE BLOCK
AS
DECLARE VARIABLE s VARCHAR(200);
...
BEGIN
...
WHILE (<some condition with loop_counter>) DO
BEGIN
s = 'INSERT INTO TABLE1 (F1' ||
loop_counter || ', F2' ||
loop_counter || ',F3' ||
loop_counter || ',F4' ||
loop_counter || ') VALUES (?, ?, ?, ?)';
EXECUTE STATEMENT (:S) (#,#,#,#);
...
END
...
END
精彩评论