Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
SQL QUERY -- WHERE CLAUSE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
lr23307

New User


Joined: 16 Jul 2010
Posts: 2
Location: india

PostPosted: Fri Jul 16, 2010 11:28 pm    Post subject: SQL QUERY -- WHERE CLAUSE
Reply with quote

Hi friends,
one question.. stupid may be icon_smile.gif

i have one sql query...

Select c1, c2
from t1, t2
where t1.name = t2.name

now in above query if u want to add one more condition in where clause like below

Select c1, c2
from t1, t2
where t1.name = t2.name
and variableA = variableB

where variableA and variableB are host variables and not db2 columns.
is it acceptable?

thanks for the help!
Back to top
View user's profile Send private message

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Jul 16, 2010 11:34 pm    Post subject: Re: SQL QUERY -- WHERE CLAUSE
Reply with quote

lr23307 wrote:
Hi friends,
one question.. stupid may be icon_smile.gif

i have one sql query...

Select c1, c2
from t1, t2
where t1.name = t2.name

now in above query if u want to add one more condition in where clause like below

Select c1, c2
from t1, t2
where t1.name = t2.name
and variableA = variableB

where variableA and variableB are host variables and not db2 columns.
is it acceptable?

thanks for the help!


If it coded properly it will work but why not just compare the host variables in you program and avoid the extra overhead and cost of calling DB2 to do it? If they don't match then you would not have to call DB2 at all.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Jul 16, 2010 11:36 pm    Post subject:
Reply with quote

Quote:
is it acceptable?


no, the compare should be done outside of the sql,
in your programming language,
and only if equal should you invoke your original sql.

it is a waste of db2 resources.

now,
is it valid sql?

yes,
as long as you precede the host variables with the syntax required colon - :.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Fri Jul 16, 2010 11:38 pm    Post subject:
Reply with quote

i am a little slow tonight, Craig.
Back to top
View user's profile Send private message
lr23307

New User


Joined: 16 Jul 2010
Posts: 2
Location: india

PostPosted: Sat Jul 17, 2010 12:04 am    Post subject:
Reply with quote

thank u friends.... actually the requirement is such that ... so i wanted to confirm.... i will run in mainframe and make sure from my end as well.. thanks for the help.. appreciate.. have a nice weekend.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Sat Jul 17, 2010 1:01 am    Post subject:
Reply with quote

lr23307 wrote:
thank u friends.... actually the requirement is such that ... so i wanted to confirm.... i will run in mainframe and make sure from my end as well.. thanks for the help.. appreciate.. have a nice weekend.


i interpret that as:
well, since I can do it, I'm gonna, yuk-yuk!
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jul 17, 2010 1:24 am    Post subject:
Reply with quote

Hello and welcome to the forum,

Quote:
actually the requirement is such that
No it is not the requirement. The requirement is to correctly solve the business need.

You may have someone in your organization that believes coding preferences of clueless people constitutes a requirement, but it does not. Why would someone believe that doing simple code via the database management software was even acceptable let alone required. . . icon_confused.gif

Quote:
is it acceptable?
Not by any proper development standard. . . It is a poor choice for implementation. Another of the things that "can be done", but should not be done.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us