If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Problem using GET DIAGNOSTICS

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-06-04, 07:49
Alairj Alairj is offline
Registered User
 
Join Date: Nov 2004
Location: São Paulo, Brazil
Posts: 32
Problem using GET DIAGNOSTICS

Hi,

I'm trying to use GET DIAGNOSTICS to know if a select returns or not a row, in a function that contains a statement like this :

SET ( vVariable ) = ( select colunm
from table
fetch first 1 rows only );

GET DIAGNOSTICS vRows = ROW_COUNT;

But in this case always GET DIAGNOSTICS returns "0", someone knows what's happening ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 12-06-04, 08:34
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
The way I read the manual on GET DIAGNOSTICS is that it returns information about the previous SQL statement. It does not mention anything about subselects. If the statement is a INSERT, UPDATE, OR DELETE row_count returns the number of rows affected.

I think in your example, you statement is a SET, and no rows are affected by that.

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 12-06-04, 10:39
Alairj Alairj is offline
Registered User
 
Join Date: Nov 2004
Location: São Paulo, Brazil
Posts: 32
But you know another way to get the number of rows without using GET DIAGNOSTICS, because i need to know if my select returns any rows.

I've tried to use SELECT INTO, and then use GET DIAGNOSTICS but i think the statement SELECT INTO doesn't work in a function.

I'm waiting for reply, thanks.
Reply With Quote
  #4 (permalink)  
Old 12-06-04, 10:42
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Why not use:
select count(*) from mytable where (same as other select stmt)

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On