View previous topic :: View next topic
|
Author |
Message |
lr23307
New User
Joined: 16 Jul 2010 Posts: 2 Location: india
|
|
|
|
Hi friends,
one question.. stupid may be
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
lr23307 wrote: |
Hi friends,
one question.. stupid may be
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
i am a little slow tonight, Craig. |
|
Back to top |
|
|
lr23307
New User
Joined: 16 Jul 2010 Posts: 2 Location: india
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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. . .
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 |
|
|
|