Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

need help on sql code 206

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
Purnendu.it

New User


Joined: 11 May 2007
Posts: 59
Location: chennai

PostPosted: Thu Mar 14, 2013 12:48 pm    Post subject: need help on sql code 206
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

Moderator


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

PostPosted: Thu Mar 14, 2013 1:49 pm    Post subject:
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

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Thu Mar 14, 2013 2:01 pm    Post subject:
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

Moderator


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

PostPosted: Thu Mar 14, 2013 2:18 pm    Post subject:
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: 59
Location: chennai

PostPosted: Thu Mar 14, 2013 2:24 pm    Post subject:
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

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Thu Mar 14, 2013 2:36 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Mar 14, 2013 3:55 pm    Post subject: Reply to: need help on sql code 206
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: 59
Location: chennai

PostPosted: Thu Mar 14, 2013 4:32 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Thu Mar 14, 2013 4:48 pm    Post subject: Reply to: need help on sql code 206
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: 59
Location: chennai

PostPosted: Thu Mar 14, 2013 5:01 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Need Help in understanding what is th... mainakdalal PL/I & Assembler 9 Mon Oct 03, 2016 8:03 pm
No new posts Problem Compiling cobol code with Cob... amitc23 COBOL Programming 2 Wed Aug 24, 2016 1:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us