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

How syntax check at Bind time is diff. from Pre-compilation


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

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Wed Mar 21, 2018 9:16 pm
Reply with quote

Hi All,

I have read that at pre-compilation stage DB2 does a syntax check for the sql query written in COBOL-DB2 program based on the table declaration values. But during Bind, it also checks the syntax of SQL with help from the data in the DB2 catalog.

But i am not sure what does it actually means and how it is different from pre-compilation time syntax check. Can anyone please explain the difference between these two syntax checking with an example.


Thanks a lot in Advance !
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Mon Mar 26, 2018 7:21 pm
Reply with quote

Quote:
But i am not sure what does it actually means and how it is different from pre-compilation time syntax check. Can anyone please explain the difference between these two syntax checking with an example

It is very simple.
1. SELECT int(abc from table a where abc>0
You will get pre compilation error because its a syntax error ")" is missing
2.Once you correct that to below the pre compilation will be successful. But at this point the abc column and table is not validated against the IBM catlog tables, so once you BIND then those all Catlog tables are engaged and validated so if abc is not part of table column then -206 is given and all other errors if present.
SELECT int(abc) from table a where abc>0

Read here futhe to know in detail.
Preparation process for an application program
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Wed Apr 04, 2018 9:49 pm
Reply with quote

Hi Rohit,

Thank you for taking out the time to respond on my query. But i am still in doubt. My understanding is, during Pre-compilation the INCLUDE statement member is copied in the program so when syntax check is performed during pre-compilation, it has column name for reference from DCLGEN and if the column name is not correct then it will give -206.

That is why i had the doubt that if this type of syntax check (wrong column name, bracket is missing, etc) is being done during Pre-compilation then what extra syntax check is happening during Bind time.

Please correct me if i am wrong.


Thank You !
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Apr 04, 2018 10:58 pm
Reply with quote

Just because all the table information is correct with regard to the Include (DCLGEN), it does not mean the table/columns exist IN THE DATABASE.

For example, when a new table or column is added, it is probably only added to the DB2 TEST Subsystem regions. A bind to one of these regions (schemas) would be successful.

If however a bind is attempted to a Quality or Production region, where the changes have yet to be released, the bind would fail.

To summarize, a compile time, the syntax is checked and existence in the dclgen is done.

At bind time, existence in the database is required for a successful bind.
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 74
Location: India

PostPosted: Wed Apr 04, 2018 11:08 pm
Reply with quote

I got the picture now and the difference i was looking for. Thanks a lot Dave & Rohit for clearing out the doubt.

icon_biggrin.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Thu Apr 05, 2018 12:01 am
Reply with quote

Quote:
so when syntax check is performed during pre-compilation, it has column name for reference from DCLGEN and if the column name is not correct then it will give -206.
No -206 is given at the time of Bind. In DCLGEN column name is for ref. purpose only. You don't need DECLGEN always, you can declare as copybook too instead.
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 PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts SCOPE PENDING option -check data DB2 2
No new posts To get the the current time DFSORT/ICETOOL 13
No new posts RC query -Time column CA Products 3
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top