Select into.....

Select into.....

Post by Doug Hodde » Sat, 15 Dec 2001 23:47:50



I am using a 'select into' command that populates a number of host
variables.  One of these variables is a number.  If the number is populated
with any number (inlcuding 0) the command works fine.  But, if the number is
not populated, I get a -305 SQLCODE when the 'select into' command is
executed and none of the host fields get populated.
If I use a fetch instead and get the -305 SQLCODE error, the rest of the
host fields will get populated.
I would rather use the select into statement.  Then I wouldnt have to
declare/open/fetch/close a cursor just to read in a record.  Is there a way
I can do this?

Thanks
Doug

 
 
 

Select into.....

Post by Lee Dilwort » Sun, 16 Dec 2001 00:25:25


have you tired using an indicator variable set to -1 ? Take a look at the
app/dev guide.

 
 
 

Select into.....

Post by Knut Stol » Sun, 16 Dec 2001 07:27:59



> I am using a 'select into' command that populates a number of host
> variables.  One of these variables is a number.  If the number is populated
> with any number (inlcuding 0) the command works fine.  But, if the number is
> not populated, I get a -305 SQLCODE when the 'select into' command is
> executed and none of the host fields get populated.
> If I use a fetch instead and get the -305 SQLCODE error, the rest of the
> host fields will get populated.

A -305 is an error and not a warning.  You shouldn't rely on any value to be
set, neither in the FETCH nor in the SELECT INTO case.

Besides that, you should give db2 an indicator variable to work with.  Have a
look at the application development duide for the details on that.

--
Knut Stolze
DB2 Spatial Extender
IBM Silicon Valley Lab

 
 
 

1. Parameters in SELECT Clause (SELECT ? AS X)

I wish to do something like;
   SELECT ? AS X
So that I may parameterize the value that appears as X in each row of
the resultset - but SQL server gives me an 'invalid descriptor index'

Can anyone see a way to do this, or more point me to a source of
information on where it is legal to use ? in a SQL statement.

2. Schema comparisons

3. How to write a select from a select?

4. One transaction at a time???!!

5. SELECT INTO vs CREATE/INSERT/SELECT

6. Updrading SBS SQL 6.5 to SQL 7.0

7. Select into #temptable and select from #temptable error :

8. Where is cursor in edit field???

9. select * or select column_names

10. Difference between SELECT AS and simple SELECT ?

11. Select into...and select at the same time

12. Select from another Select satement

13. Selecting from a select