Page 1 of 1
Re : Host variables
Posted:
Sat Nov 27, 2010 10:27 am
by ykreddy
Hi All,
This is Yedukondalu Reddy.
can we use [quote]host variables in select statement in cobol+db2 application program
like
SELECT
:WS-Y,B.NTWRK_IND,A.GRP_RULE_ID
INTO
:WS-GRP-RULE-IND,:WS-NTWRK-IND,:WS-GRP-RULE-ID
Thanks,
Ykreddy
Re: Re : Host variables
Posted:
Sat Nov 27, 2010 10:52 am
by NicC
I would say 'No' as you SELECT table columns INTO host vars. W?hat you are trying to do is a straight COBOL MOVE.
Re: Re : Host variables
Posted:
Sat Nov 27, 2010 6:26 pm
by RENGANATHAN
host variables are used at the precompiler step not in db2,so we cant use the host varible in db2 level
Re: Re : Host variables
Posted:
Sat Nov 27, 2010 6:48 pm
by enrico-sorichetti
before replying try to understand the issue at stake
the environment is COBOL+DB2 the SELECT is supposed to be within and EXEC SQL thing
so the question, even if a bit unclear is not completely out of place,
the TS just needs to understand the things that can be selected and where/into
Re: Re : Host variables
Posted:
Sun Nov 28, 2010 1:23 pm
by ykreddy
Thanks for your reply
I am supporting mainframe project having COBOL + DB2 program has the following SQL code
WORKING-STORAGE SECTION.
01 WS-MISC-AND-HOST-VARIABLES.
05 WS-Y PIC X(1) VALUE 'Y'.
05 WS-N PIC X(1) VALUE 'N'.
.
.
.
.
.
.
Procedure division.
EXEC SQL
SELECT
:WS-Y,B.NTWRK_IND,A.GRP_RULE_ID
INTO
:WS-GRP-RULE-IND,:WS-NTWRK-IND,:WS-GRP-RULE-ID
FROM
(SELECT GRP_RULE_ID
FROM Wgd.GRP_RULE
WHERE RULE_ID = :HS-UM-RULE-ID) A,
(SELECT NTWRK_IND, RULE_ID
FROM Wgd.RULE_CNTRCT
WHERE CNTRCT_CD = :WS-WS-CONTRACT-CD
AND STRT_DT = :WS-HS-BNFT-YR-CONTR-EFF-DTE) B
WHERE A.GRP_RULE_ID = B.RULE_ID
UNION ALL
SELECT
:WS-N,B.NTWRK_IND,:WS-BLANK
INTO
:WS-GRP-RULE-IND,:WS-NTWRK-IND,:WS-GRP-RULE-ID
FROM Wgd.RULE_CNTRCT B
WHERE B.RULE_ID = :HS-UM-RULE-ID
AND B.CNTRCT_CD = :WS-WS-CONTRACT-CD
AND B.STRT_DT = :WS-HS-BNFT-YR-CONTR-EFF-DTE
END-EXEC
But I'm not sure how it works
can we use host variables in select statement in cobol+db2 application program
Can you please tell how it possible
Regards,
Ykreddy
Re: Re : Host variables
Posted:
Mon Nov 29, 2010 6:02 am
by dick scherrer
Hello,
I am supporting mainframe project having COBOL + DB2 program has the following SQL code
What happens when this is executed?
Re: Re : Host variables
Posted:
Wed Dec 01, 2010 2:58 pm
by ykreddy
Hi,
I dont knw but it is executed succesfully
Re: Re : Host variables
Posted:
Wed Dec 01, 2010 3:18 pm
by GuyC
it just works as any literal.
move 'Y' to ws-y
exec sql
select :ws-y from sysibm.sysdummy1
end-exec
=
select 'Y' from sysibm.sydummy1
Your query just returns a certain grp-rule with a 'Y' and if any, all dependant contract rules of a certain contract started at a certain time with a 'N'
I'm not sure what the requirement is, but functionally you can probably do the same thing with
SELECT B.NTWRK_IND,A.GRP_RULE_ID INTO :WS-NTWRK-IND,:WS-GRP-RULE-ID:ws-grp-rule-ind
from Wgd.RULE_CNTRCT B
left join Wgd.GRP_RULE A on A.GRP_RULE_ID = B.RULE_ID
WHERE B.RULE_ID = :HS-UM-RULE-ID
AND B.CNTRCT_CD = :WS-WS-CONTRACT-CD
AND b.STRT_DT = :WS-HS-BNFT-YR-CONTR-EFF-DTE
it looks to be written before left join was implemented or understood.