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

DB2 Sql Error code -204


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

New User


Joined: 18 May 2018
Posts: 3
Location: UK

PostPosted: Fri May 18, 2018 4:40 pm
Reply with quote

Hi,

Am facing a Sql error -204(Object not Found) when trying to open a cursor which has Temporary table reference. Have done below analysis on this issue.

1) Validated Temporaray table creation and records insertion was successfully by displaying and fetching the values from Temp Table.
2) Ensured that Temporary Table was created before opening the cursor
3) Table and Fields name are correct.
4) If replaces Temporary table with hard code values, cursor is working fine.

Below is the Cursor and Temporary table definition followed with open cursor in the sequence executed in the Program

Code:
WORKING STORAGE SECTION.

EXEC SQL
  DECLARE CJLR-OUT-NOTICE-CSR CURSOR FOR
    SELECT DISTINCT
           PARTNO
    FROM  PDDB2DB.PWRSFUP
    WHERE PROD_TYPE||VEHICLE_LINE IN
    (SELECT DISTINCT WWRS_VEHICLE FROM SESSION.VEHICLE
    WHERE WWRS_VEH_REQ = "CJLR")
END-EXEC.


PROCEDURE DIVISION.

EXEC SQL
    DECLARE GLOBAL TEMPORARY TABLE SESSION.VEHICLE
            (WWRS_VEHICLE      CHAR(3) NOT NULL,
             WWRS_VEH_REQ      CHAR(4) NOT NULL)
    ON COMMIT PRESERVE ROWS
END-EXEC

EXEC SQL
     INSERT INTO SESSION.VEHICLE
          (WWRS_VEHICLE,WWRS_VEH_REQ)
     VALUES (:WS-VEHICLE,:WS-VEH-REQ)
END-EXEC

EXEC SQL
    OPEN CJLR-OUT-NOTICE-CSR
END-EXEC


Please adviSe what is causing this issue and how to resolve it.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri May 18, 2018 7:23 pm
Reply with quote

What are the pictures for the fields? Have you displayed them between markers e.g.
Code:
>value  <
?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri May 18, 2018 9:26 pm
Reply with quote

It looks like the temp table is getting Dropped during the process before you are opening the cursor.
Try DROPing the temp table before its Declaration and get rid of the DROP from elsewhere( if present).

After opening the cursor what next? are you processing it in the same program like the FETCH?
Back to top
View user's profile Send private message
rohit_naidu

New User


Joined: 18 May 2018
Posts: 3
Location: UK

PostPosted: Fri May 18, 2018 10:46 pm
Reply with quote

Nic Clouston wrote:
What are the pictures for the fields? Have you displayed them between markers e.g.
Code:
>value  <
?


Its alphanumeric fields.
WWRS_VEHICLE PIC X(03).
WWRS_VEH_REQ PIC X(04).
Back to top
View user's profile Send private message
rohit_naidu

New User


Joined: 18 May 2018
Posts: 3
Location: UK

PostPosted: Fri May 18, 2018 10:50 pm
Reply with quote

Rohit Umarjikar wrote:
It looks like the temp table is getting Dropped during the process before you are opening the cursor.
==> Have displayed the Value from this temp table before opening the cursor to check if Temp table exist or not. Its displaying required value.

Try DROPing the temp table before its Declaration and get rid of the DROP from elsewhere( if present).
==> It will throw the SQL error, haven't tried yet. Do u want me to try

After opening the cursor what next? are you processing it in the same program like the FETCH?

==> fetching the data and writing into output file
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Fri May 18, 2018 11:01 pm
Reply with quote

Try the other thing suggested of Dropping the temp table if nothing works out then check with the DBA at your site.
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
Search our Forums:

Back to Top