View previous topic :: View next topic
|
Author |
Message |
Poha Eater
New User
Joined: 31 Aug 2016 Posts: 74 Location: India
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
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 |
|
|
Poha Eater
New User
Joined: 31 Aug 2016 Posts: 74 Location: India
|
|
|
|
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 |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
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 |
|
|
Poha Eater
New User
Joined: 31 Aug 2016 Posts: 74 Location: India
|
|
|
|
I got the picture now and the difference i was looking for. Thanks a lot Dave & Rohit for clearing out the doubt.
|
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
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 |
|
|
|