db2 dynamic sql cuesor

Viewed 86

can I use two parameters in db2 cursor and open it using :parm1 :parm2 my cobol source is:

working-storage
01 parm1 pic x(09).
01 parm2 pic x(09).
procedure division.
move '080000' to parm1.
move '090000' to parm2.
move 'select s2p from grp2.arz where s2p > ? and < ?' to st.

and then I prepare it:

exec-sql parepare s1 from :st statement1 end-exec.
exec-sql declare c1 vursor for s1 end-exec.
exec-sql open c1 using :parm1 :parm2 end-exec.

and then I fetch from the cursor.

In run time I got error:

indicator variable parm2 is not smallint type!

1 Answers

The parameters passed in using have to separated by a comma:

exec-sql open c1 using :parm1, :parm2 end-exec.

Without the comma DB2 is interpreting it as a pair of host-variable and null-indicator.

Related