sql - db2 doesn't allow to use function in a stored procedure -


i have following error

   unexpected token "table" found following "elect .." 

that produced after code below. if call function works fine

   --example    select * foo('2013-02-20') 

but when plug stored proceddure deosnt' work. allowed call in function 1 did below?

   create function foo( my_date date ) returns table(data integer)     language sql reads sql data  return select id,sum(value) table date=my_date group id;      create procedure list_open_positions(my_date date)     language sql begin select * table(foo(my_date)); end; 

stored procedures can't contain bare select statement, don't output results of queries directly.

the table function should work fine in select statement part of expression. example:

create procedure bar(my_date date) language sql begin     insert some_table          select * table(foo(my_date)); end 

this answer not 100% definitive without knowing version , platform of db2 using. there major differences between versions in allowed in functions/procedures. example such above works fine in 9.7 luw.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -