Re : Host variables



IBM's flagship relational database management system

Re : Host variables

Postby ykreddy » Sat Nov 27, 2010 10:27 am

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
Thanks & Regards,

YK Reddy
ykreddy
 
Posts: 6
Joined: Mon Sep 20, 2010 5:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re : Host variables

Postby NicC » Sat Nov 27, 2010 10:52 am

I would say 'No' as you SELECT table columns INTO host vars. W?hat you are trying to do is a straight COBOL MOVE.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Re : Host variables

Postby RENGANATHAN » Sat Nov 27, 2010 6:26 pm

host variables are used at the precompiler step not in db2,so we cant use the host varible in db2 level
learner(admin)
RENGANATHAN
 
Posts: 9
Joined: Thu Jul 29, 2010 2:23 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re : Host variables

Postby enrico-sorichetti » Sat Nov 27, 2010 6:48 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Re : Host variables

Postby ykreddy » Sun Nov 28, 2010 1:23 pm

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
Thanks & Regards,

YK Reddy
ykreddy
 
Posts: 6
Joined: Mon Sep 20, 2010 5:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re : Host variables

Postby dick scherrer » Mon Nov 29, 2010 6:02 am

Hello,

I am supporting mainframe project having COBOL + DB2 program has the following SQL code
What happens when this is executed?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Re : Host variables

Postby ykreddy » Wed Dec 01, 2010 2:58 pm

Hi,

I dont knw but it is executed succesfully
Thanks & Regards,

YK Reddy
ykreddy
 
Posts: 6
Joined: Mon Sep 20, 2010 5:00 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re : Host variables

Postby GuyC » Wed Dec 01, 2010 3:18 pm

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.
I can explain it to you, but i can not understand it for you.
GuyC
 
Posts: 315
Joined: Tue Aug 11, 2009 3:23 pm
Has thanked: 1 time
Been thanked: 4 times


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post