Issue in Stored Proc : db2 -
i have written following stored proc in db2.
create or replace procedure rtimd.ialert_proc ( in usr_name varchar(20) default '', in in_rtim_id varchar(25) default '', in api_method varchar(25) default '', in params varchar(500) default '', in application_name varchar(20) default '', out tickt_id varchar(20), out rtimid_var varchar(25)) language sql begin declare rtim_id_out varchar(25); if api_method = 'getincident' set tickt_id = execute immediate ( 'select distinct ticket_id rtimd.v3_ticket_log rtim_id = in_rtim_id' ); set rtim_id_out = in_rtim_id; elseif api_method = 'createincident' set rtimid_var = execute immediate ( "select 'rtim_' concat usr_name concat varchar(bigint(days(current date) - days('1970-01-01'))*bigint(86400) + midnight_seconds(current_timestamp - current_timezone)) concat '_' concat varchar(smallint ( rand () *10000 + 1 )) sysibm.sysdummy1"); set rtim_id_out = rtimid_var; elseif api_method = 'closeincident' set rtim_id_out = in_rtim_id; end if; insert rtimd.v3_ticket_log( rtim_id, state, api_method, api_message, ticket_type, impact_row_id, ticket_id, params, remote_user, created, updated, db_state, cps_state, application, prb_owner, sn_instance ) values ( rtim_id_out, 0, api_method, '', 'incident', 0, '', params, usr_name, current timestamp, timestamp, 0, 0, application_name, 'self', '' ); end
when executing stored proc, getting following error message.
db21034e command processed sql statement because not valid command line processor command. during sql processing returned: sql0104n unexpected token "immediate" found following "set tickt_id=execute". expected tokens may include: "in". line number=1. sqlstate=42601
what went wrong here, have surfed enough no answers :( there syntactical errors. please guide me.
tia.
the syntax of execute wrong:
- execute immediate http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000950.html
- execute http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000948.html
the first query seems static, means can convert select into, instead of using execute.
http://pic.dhe.ibm.com/infocenter/db2luw/v10r5/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000994.html
Comments
Post a Comment