Please advise how to use SPL to insert cols of data
Posted in 1998
Topics: Stored Procedures & SPL
Can anyone advise me what is the best way to use SPL to insert several
columns of data into a table?
The columns are passed as several equi-length lists of data items. What
I want to do is in effect:
CREATE PROCEDURE my_insert (list_1 ROW(<type1>),list_2 ROW(<type2>),...)
FOR i = 1 TO length_of lists
DO INSERT INTO my_table VALUES (list_1[i],list_2[i],...); END FOR;
END PROCEDURE;
However I have not been able to find a way of specifying the i'th
element of the list, i.e. an equivalent to "col_n[i]".
My current solution seems to be an unnecessarily complex for a simple
problem:
let i = 0 ;
foreach t_cursor for select * into v1 from table(list_1)
insert into temp_table (col_i,col_1) values (i,v1) ; let i = i + 1 ;
end foreach ;
let i = 0 ;
foreach t_cursor for select * into v2 from table(list_2)
update temp_table set col_2 = v2 where col_i = i ; let i = i + 1 ;
end foreach ;
:::
All this is required because Web DataBlade generates lists of data
corresponding to input fields, but does not support iteration through
the lists.
I am a newcomer to SPL so any help would be appreciated.
Thanks,
Andrew Coney.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading