View previous topic :: View next topic
|
Author |
Message |
acrajesh
New User
Joined: 31 May 2007 Posts: 15 Location: Bangalore
|
|
|
|
I am trying to use two DCLGEN's in the same program where two of the variables used is ambigous, ie; they are used in both the dclgen's. how to fix this issue?
Ex: The variable STL-CODE is used in both the DCLGEN's |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
acrajesh,
Quote: |
am trying to use two DCLGEN's in the same program where two of the variables used is ambigous, ie; they are used in both the dclgen's. |
Not a problem and you can use it even when the names are same.
Quote: |
how to fix this issue?
|
Have both the dclgen's INCLUDEd in the program and when it comes to differentiate the variables code as shown below
Say if the field X is in DCLGEN Y and Z
Code: |
MOVE X OF Y TO X OF Z |
|
|
Back to top |
|
|
acrajesh
New User
Joined: 31 May 2007 Posts: 15 Location: Bangalore
|
|
|
|
Hi Aaru,
The code is as follows
EXEC SQL
INSERT INTO MTW.STK_MRKT_DTL(
STK_CODE,
DMAT_ACCT,
DMAT_ACCT_NAME,
DMAT_ACCT_ADDR,
STK_BUY_PRC,
STK_SELL_PRC,
TOT_STK_BOUGHT,
TOT_STK_SOLD,
STOP_LOSS_PRC,
STK_HLD_FROM,
LST_TXN_DATE,
CRT_USER_ID,
CRT_TMSTMP)
VALUES (
:STK-CODE,
:DMAT-ACCT,
:DMAT-ACCT-NAME,
:DMAT-ACCT-ADDR,
:STK-BUY-PRC,
:STK-SELL-PRC,
:TOT-STK-BOUGHT,
:TOT-STK-SOLD,
:STOP-LOSS-PRC,
:STK-HLD-FROM,
:LST-TXN-DATE,
CURRENT SQLID,
CURRENT TIMESTAMP)
END-EXEC
EXEC SQL
INSERT INTO MTW.STK_MRKT_HDR(
STK_CODE,
COMP_NAME,
COMP_ADDR,
CURR_STK_PRC,
CURR_YR_LOW,
CURR_YR_HIGH,
TOT_PUB_STK,
CRT_USER_ID,
CRT_TMSTMP )
VALUES (
:STK-CODE,
:COMP-NAME,
:COMP-ADDR,
:CURR-STK-PRC,
:CURR-YR-LOW,
:CURR-YR-HIGH,
:TOT-PUB-STK,
CURRENT SQLID,
CURRENT TIMESTAMP)
END-EXEC
where STK-CODE appears in both of the INSERT's. How to fix this issue as the compilation throws the following error:
DSNH314I E DSNHSMUD LINE 246 COL 0 REFERENCE TO HOST VARIABLE STK-CODE IS AMBIGUOUS
DSNH314I E DSNHSMUD LINE 300 COL 0 REFERENCE TO HOST VARIABLE STK-CODE IS AMBIGUOUS
I even tried like STK-CODE OF STK-MRKT-HDR and STK-MRKT-HDR.STK-CODE but both went in vain. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
reference qualification in COBOL is via the 'IN' or 'OF' keyword.
the format for qualifying columns in db2 is a little different.
it is either qualifier.column_name
or column_name.qualifier
i don't remember,
either refer to the documentation or try both ways and see which works |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
an amendment to the previous post.
it is host variable and not column that is qualified. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
acrajesh,
This is how it should be done when the same field is there in 2 DCLGEN's.
Say the DCLGEN's are Y and Z
In the DCLGEN you would have 2 things
- DECLARE TABLE
- COBOL declaration for the TABLE
In the cobol declaration of the table make sure that the 01 level has the DCLGEN name.
Code: |
01 X.
10 field one pic x(10)
10 field two pic x(20)
|
In the DCLGEN Y have it as
Code: |
01 Y.
10 field one pic x(10)
|
then in the query use as shown below
Code: |
EXEC SQL
INSERT
INTO TABLE
....
....
VALUES(FIELD EIGHT
,:X.FIELD ONE)
END-EXEC |
Similarly in the next query use it with the prefix Y.
Hope this helps |
|
Back to top |
|
|
acrajesh
New User
Joined: 31 May 2007 Posts: 15 Location: Bangalore
|
|
|
|
Not working |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
only thing that is not working is you.
sorry if you are offended (yes the sarcasm was intended) |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
acrajesh,
Which part of the code do you think is not working? Did you try ? |
|
Back to top |
|
|
Cristopher
New User
Joined: 31 Jul 2008 Posts: 53 Location: NY
|
|
|
|
If nothing is working and standards permit , U may try this (not tested)
Move STK-CODE of STK-MRKT-DTL to WS-CODE-DTL
Move STK-CODE of STK-MRKT-HDR to WS-CODE-HDR
Make sure the data types exactly match and use these these variables in your SQl insert query.
Hope This helps. |
|
Back to top |
|
|
|