View previous topic :: View next topic
|
Author |
Message |
learnmf
Active User
Joined: 14 Mar 2005 Posts: 123
|
|
|
|
Hi All,
I am facing a problem on FETCH.
The CUrsor based on a query which contains count(coulumn_name).
In Fetch :
Fetch cursor-name
into :ws-count
When i display ws-count it does n't show any value i.e spaces (i do n't emember exactly it is periods (...).
Note : While running query at QMF its show a value in the count value.But in my program the query is not giving the actual result in the cursor.
Can any body help me why i am not getting the acctual value. |
|
Back to top |
|
|
SHIVAREDDY
New User
Joined: 25 Jul 2005 Posts: 20
|
|
|
|
Hi,
If you want the count, you can check the count in the following variables also after the SQL stament.
SQLERRD(1) |The number of rows in the result table of a cursor when the cursor position |is after the last row (when SQLCODE is equal to +100). This field is not set |for
FETCH [[NEXT | PRIOR | FIRST | LAST | ABSOLUTE n | RELATIVE n] FROM]
cursor_name
[INTO @variable_name1, @variable_name2, ...]
where
dynamic scrollable cursors.
|| |SQLERRD(2) |The number of rows in the result table of a cursor when the cursor position |is after the last row (when SQLCODE is equal to +100). This field is not set |for dynamic scrollable cursors.
|| |SQLERRD(3) |The number of rows in the result table of an INSERT when the SELECT |statement of the cursor contains the INSERT statement.
SQLERRD5 contains an indication that the last row in the table was fetched. It can be used to detect the end-of-data condition in the table being fetched .
Fetch Count for Cursors (BUT I COULDN'T DO USING THIS OPTION)
Normally, the select @@rowcount command returns the number of
rows actually returned to the client as a result of the most recent
request. However, on DB2, when a cursor is open and results are
fetched, select @@rowcount returns the number of rows in the fetch
count for that cursor. This may differ from the number of rows
actually returned, depending upon how the cursor is used.
The sqlerrd's give values in hex i suppose.
please let me know if you could get the count using the above.
CHEERS |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Can you please give us the CURSOR definition and the definition of WS-COUNT.
Also. When you do the display of WS-COUNT please give an example of what you expect the count to be, and the HEX value of the corresponding display '....'.
Thanks, We'll see if we can get to the bottom of this. |
|
Back to top |
|
|
|