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

need help on sql code 206


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

New User


Joined: 11 May 2007
Posts: 57
Location: chennai

PostPosted: Thu Mar 14, 2013 12:48 pm
Reply with quote

I am trying to run a simple cobol-db2 program but getting error.while precompilation state i have got rc=04 and while binding i also got rc=0.I ran the run cobol jcl and it showing below error in SYSOUT.
and not able to print the employee name..see below
Code:
********************************* TOP OF DATA ***************
SQL FAILED.                                                 
SQL CODE =  000000206                                       
*INTO THE PROGRAM JUNK *                                     
EMLOYEE NAME IS :                                           
******************************** BOTTOM OF DATA *************


Now DCLGEN looks like this
Code:

 ******************************************************************
      EXEC SQL DECLARE IBMGRP.PEMP TABLE                           
      ( EMPID                          CHAR(6) NOT NULL,           
        EMPNAME                        VARCHAR(20) NOT NULL,       
        DEPARTMENT                     CHAR(2) NOT NULL,           
        SALARY                         DECIMAL(6, 2) NOT NULL,     
        DESIGNATION                    CHAR(20) NOT NULL           
      ) END-EXEC.                                                 
 ******************************************************************
 * COBOL DECLARATION FOR TABLE IBMGRP.PEMP                        *
 ******************************************************************
  01  DCLPEMP.                                                     
      10 EMPID                PIC X(6).                           
      10 EMPNAME.                                                 
         49 EMPNAME-LEN       PIC S9(4) USAGE COMP.               
         49 EMPNAME-TEXT      PIC X(20).                           
     10 DEPARTMENT           PIC X(2).                     
     10 SALARY               PIC S9(4)V9(2) USAGE COMP-3.   
     10 DESIGNATION          PIC X(20).                     


querry in the program is
Quote:

EXEC SQL
SELECT EMPNAME
INTO :EMPNAME
FROM IBMGRP.PEMP
WHERE EMPID = '111111'
END-EXEC.


Now i know -206 comes for below reason.

column-name IS NOT A COLUMN OF AN INSERTED TABLE, UPDATED TABLE, OR ANY TABLE IDENTIFIED IN A FROM CLAUSE..

If you can see the querry I have used EMPID which is the correct column name defined in the DCLGEN given above.Then why I am getting the -206?Please suggest.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Mar 14, 2013 1:49 pm
Reply with quote

The Dclgen what you see could still be deceiving

Please check the table and its columns in Catalog tables or admin tool
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Mar 14, 2013 2:01 pm
Reply with quote

Pandora-Box wrote:
The Dclgen what you see could still be deceiving

Unlikely, as DCLGEN dates from the time that IBM still did things the proper way, with well trained staff!
The answer is here.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Thu Mar 14, 2013 2:18 pm
Reply with quote

Prino,

I saw that link but yet to insist on my point we could still edit DCLGEN after all it is just another form of COPYBOOK and I am no where blaming IBM
Back to top
View user's profile Send private message
Purnendu.it

New User


Joined: 11 May 2007
Posts: 57
Location: chennai

PostPosted: Thu Mar 14, 2013 2:24 pm
Reply with quote

Hi Pandora,

I autogenerated DCLGEN using Spufi.I tried to run another queries like
Quote:

EXEC SQL
SELECT EMPNAME
INTO :EMPNAME
FROM IBMGRP.PEMP
*WHERE EMPID = '111111' //COMMENTED OUT
FETCH FIRST ROW ONLY
END-EXEC


And this was working fine.But coming to my point why i am getting -206 for wrong column name whereas i have given correct column name?
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Mar 14, 2013 2:36 pm
Reply with quote

Purnendu.it wrote:
Hi Pandora,

I autogenerated DCLGEN using Spufi.I tried to run another queries like
Quote:

EXEC SQL
SELECT EMPNAME
INTO :EMPNAME
FROM IBMGRP.PEMP
*WHERE EMPID = '111111' //COMMENTED OUT
FETCH FIRST ROW ONLY
END-EXEC


And this was working fine.But coming to my point why i am getting -206 for wrong column name whereas i have given correct column name?

Are you really stupid, or just pretending?

The answer is here
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 14, 2013 3:55 pm
Reply with quote

curious and tested ...

Code:
      *****EXEC SQL
      *****     DECLARE OWN.TAB TABLE
      *****     ( KEY CHAR(8) NOT NULL ,
      *****       DATA CHAR(8) NOT NULL )
      *****END-EXEC .

      *****EXEC SQL
      *****     SELECT DATA INTO :DATA
      *****     FROM OWN.TAB
      *****     WHERE KEY = '11111111'
      *****END-EXEC .


ends with a RC 4

and the message ...

Code:
 DSNH206I W     DSNHANAL LINE 22 COL 17  STATEMENT REFERENCES COLUMN 'OWN'.'TAB''11111111', WHICH IS NOT DECLARED IN THE SPECIFIED
 TABLE(S)
 SELECT DATA INTO : DATA FROM OWN.TAB WHERE KEY ='11111111'


meditate a bit, meditate on
APOST/QUOTE APOSTSQL/QUOTESQL icon_cool.gif

Code:
running the same with
//PC      EXEC PGM=DSNHPC,PARM='HOST(IBMCOB),APOSTSQL'

ends with a RC 0
Back to top
View user's profile Send private message
Purnendu.it

New User


Joined: 11 May 2007
Posts: 57
Location: chennai

PostPosted: Thu Mar 14, 2013 4:32 pm
Reply with quote

Quote:

meditate a bit, meditate on
APOST/QUOTE APOSTSQL/QUOTESQL

Code:
running the same with
//PC EXEC PGM=DSNHPC,PARM='HOST(IBMCOB),APOSTSQL'

ends with a RC 0


Hi enrico-sorichetti,

I tried to pass the PARM='HOST(IBMCOB),APOSTSQL while running the the program though it returned RC=0 but still i am getting -266.. can you please explain what you meant by above quote of yours.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Mar 14, 2013 4:48 pm
Reply with quote

that too often an improper specification of APOST QUOTE and friends
might yield unexpected results

and it is always better to use them consistently
Back to top
View user's profile Send private message
Purnendu.it

New User


Joined: 11 May 2007
Posts: 57
Location: chennai

PostPosted: Thu Mar 14, 2013 5:01 pm
Reply with quote

you are right ..it solved now..
Thanks Enrico..
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Monitoring production job progress. N... JCL & VSAM 4
Search our Forums:

Back to Top