Changing where criteria in the program



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Changing where criteria in the program

Postby vegafacundodaniel » Thu Feb 16, 2012 8:25 pm

Hello,

I have a question pls.

In a cobol/db2 program, can I modify the WHERE criteria of a query sql ?

for ex:
cond1 = "where nroemp = 'XXXXXXX'
cond2 = "where nro emp ='XXXXXXX' and country = 'USA' "

Select nroemp
into ws-nroemp
from base.tb
where cond1

Select nroemp
into ws-nroemp
from base.tb
where cond2

For both querys I am getting the same colonne (nroemp)

Thanks in advance !
vegafacundodaniel
 
Posts: 61
Joined: Tue Jul 20, 2010 4:27 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Changing where criteria in the program

Postby Nik22Dec » Fri Feb 17, 2012 2:35 pm

Yes, you can. Please note that after making the change you will have to recompile as well as rebind the program.

It is absolutely possible for both your queries to return the same rows. Why do you think it is an issue?
Thanks,
Nik
User avatar
Nik22Dec
 
Posts: 68
Joined: Mon Dec 26, 2011 6:38 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Changing where criteria in the program

Postby Anuj Dhawan » Fri Feb 17, 2012 3:22 pm

Short answer is - it can be done, as Nik also indicates. However, rather interesting question is to know why are you asking? If you don't trust the results of your queries, may be browse through the tables uisng SPUFI and QMF and see what is there in your table/s?
Anuj
Anuj Dhawan
 
Posts: 273
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

Re: Changing where criteria in the program

Postby vegafacundodaniel » Sun Mar 08, 2015 3:50 am

Hello. In my program cobol/db2, I am using theses sentences:

01 cond1 pic x(30).

move "nroemp = 'XXXXXXX'" to cond1

EXEC SQL
Select nroemp
into ws-nroemp
from base.tb
where cond1
END-EXEC.

and when I compile, I get an error on the WHERE.
Could anyone help me, please?

thanks in advance
vegafacundodaniel
 
Posts: 61
Joined: Tue Jul 20, 2010 4:27 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Changing where criteria in the program

Postby vegafacundodaniel » Sun Mar 08, 2015 4:09 am

vegafacundodaniel wrote:Hello. In my program cobol/db2, I am using theses sentences:

01 cond1 pic x(30).
01 var-employe pic 9(8).

move "nroemp1 = :var-employe'" to cond1
move 11111111 to var-employe

EXEC SQL
Select nroemp
into ws-nroemp
from table
where cond1
AND nroemp2 = 99999999
END-EXEC.

and when I compile, I get an error on the WHERE.
Could anyone help me, please?

thanks in advance
vegafacundodaniel
 
Posts: 61
Joined: Tue Jul 20, 2010 4:27 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Changing where criteria in the program

Postby BillyBoyo » Sun Mar 08, 2015 4:41 am

Please don't ask a new question in an old topic.

What were you hoping "where cond1" would do?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post