By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,230 Members | 1,473 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,230 IT Pros & Developers. It's quick & easy.

Declare variables and assigning in SP's

P: n/a
Hi,

while trying to read data from a table assigning values into more than
one value I stopped at the following problem:

declare c1 cursor for
select val1 into cval1, val2 into cval2
from inst1.table
where CUSID = iCUSID;

The db2 tells me that he expects "from" after "cval1". This means for me I
can't request more than one value in one query. But this should be bullsh..,
if it can't - and I think it will work, but how?
Does anyone know how?!?

Greetings from Cologne
Bas

Oct 2 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi,
>
while trying to read data from a table assigning values into more than
one value I stopped at the following problem:
Thanks for reading.

I had enougth time to solve the problem by myself.
For futher reading please use this:

declare cCol1 char(1);
declare cCol1 char(8);

declare c2 cursor for
select col1, col2
from inst1.table
where CUSID = iCUSID;

open c1;
fetch c1 into cCol1, cCol2;
close c1;

Greets
Bas
Oct 2 '06 #2

P: n/a
Hi, Bas:

If you're only expecting a singleton, a cursor is not necessary--and
will be unnecessarily costly. The general syntax for what you're trying
to do is:

select val1, val2 into cval1, cval2
from inst1.table
where CUSID = iCUSID;

Regards,

--Jeff

Sebastian Moderlak wrote:
Hi,

while trying to read data from a table assigning values into more than
one value I stopped at the following problem:

Thanks for reading.

I had enougth time to solve the problem by myself.
For futher reading please use this:

declare cCol1 char(1);
declare cCol1 char(8);

declare c2 cursor for
select col1, col2
from inst1.table
where CUSID = iCUSID;

open c1;
fetch c1 into cCol1, cCol2;
close c1;

Greets
Bas
Oct 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.