IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 Row positining fetch giving error


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Nov 20, 2009 12:41 pm
Reply with quote

Hi ,
im using the rowset positioning of a cursor to get the rows from my table butthe rows returned are 'NONE'
below is my fetch cursor
Code:
   01 ws-ar-data.
                   05 ws-ar-a1    pic x(02) occurs 15 times.
                   05 ws-ar-a2    pic x(02) occurs 15 times.

              DECLARE A1_CUR CURSOR WITH
               ROWSET POSITIONING FOR
                   SELECT
                              A1,A2
                   INTO :A1,:A2
                FROM  A1_TABLE
                WHERE
                     AX_1 = :AX-1
       
                     
               


im then openening my curor ande fetching it.
Code:
  EXEC SQL
                      OPEN A1_CUR
                    END-EXEC.
               
                   EXEC SQL
                      FETCH NEXT ROWSET FROM A1_CUR FOR 15 ROWS
                     INTO :WS-AR-A1
                             ,:WS-AR-A2
                    END-EXEC.
               
                  EXEC SQL
                     GET DIAGNOSTICS :WS-COUNT = ROW_COUNT
                  END-EXEC.

               
                       




it is returning me a sqlcode +100 while there are 15 rows in that table and also the WS-COUNT is holding zeroes in it.

Please help me ,where i have made any mistakes if any present in this code.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Fri Nov 20, 2009 2:46 pm
Reply with quote

Hi Tecnokrat,

Put
Code:
DISPLAY SQLCODE.

After every EXEC SQL ... END-EXEC. statement and checkout the sqlcodes. Also check SQLERRD(3) infomation.

Let us know what happens ?


Sushanth
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Nov 20, 2009 2:56 pm
Reply with quote

he knows what happens : sqlcode = +100 and row-count = 0

check out definition and content of :ax-1.
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Nov 20, 2009 3:31 pm
Reply with quote

AX-1 is defined as pic s9(09).

and the where condition holds good as all the 15 rows are present in the table ...
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Fri Nov 20, 2009 3:55 pm
Reply with quote

Tecnokrat,
In my example mult-row fetch program, i have declared cursor in the following format.
Code:
EXEC SQL
   DECLARE A1_CUR CURSOR WITH ROWSET POSITIONING
   FOR
           SELECT A1,A2
                FROM  A1_TABLE
                WHERE AX_1 = :AX-1

END-EXEC.


Check it out.


Sushanth
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Nov 20, 2009 4:35 pm
Reply with quote

i have also given the same thing but i dint metioned here in the example in myt post
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Fri Nov 20, 2009 4:40 pm
Reply with quote

Tecnokrat,

Check your package QUALIFIER, whether its pointing to the right database.

Sushanth
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Tue Nov 24, 2009 12:14 pm
Reply with quote

Put a display and make sure AX-1 has desired value before opening the cursor.
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Tue Nov 24, 2009 12:34 pm
Reply with quote

resolved my problem as one of the key field was not included in the WHERE clause.
icon_sad.gif sorry for the trouble.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 24, 2009 5:27 pm
Reply with quote

tecnokrat,

thanks for getting back; and kudos for one of the few honest solutions.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Fetch data from programs execute (dat... DB2 3
No new posts Error while running web tool kit REXX... CLIST & REXX 5
Search our Forums:

Back to Top