670 pts.
 SQL/400
What is wrong in the *BLANKS in the following code

 

WHERE (EMPID=:*BLANKS OR EMPID=:EMPID)



Software/Hardware used:
AS400
ASKED: March 30, 2012  9:43 AM
UPDATED: March 30, 2012  11:29 PM

Answer Wiki:
I assume from the heading and tags you are looking for an SQL answer... That's just a guess. Why not just use "WHERE (EMPID IS NULL)" and drop the test to itself.
Last Wiki Answer Submitted:  March 30, 2012  2:07 pm  by  ToddN2000   3,910 pts.
All Answer Wiki Contributors:  ToddN2000   3,910 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

WHERE (EMPID=:*BLANKS OR
EMPID=:EMPID)

Why would you check to see if a values of a field is equal to itselt?

And how do you know there is somehting wrong with *BLANKS

Is this RPG, CL ot some other language?

 32,855 pts.

 

This is the where clause from an SQL statement.
*BLANKS is an RPG literial but that doesn’t extend into the SQL precompiler.
So your where clause might look something like this.
WHERE (EMPID = ‘ ‘ OR EMPID = :EMPID)
This would accept rows with blank employee ids or where the empid = the RPG value of EMPID.
Phil

 44,180 pts.

 

I would think that this condition “EMPID=:EMPID” is not comparing a field to itself…

In my non-400 world, :EMPID would be called a “bind variable”.

 63,535 pts.

 

Hi Carlos
I think the first respondees missed the SQL issue and ‘:’ is a bit small to see for my old eyes. But you’re correct as an embedded SQL where clause in RPG it’s using the RPG field EMPID to compare with the database field EMPID.
Phil

 44,180 pts.

 

Basically, there is no such host variable named “*BLANKS”. Therefore, it can’t used where a host variable is needed.

The word “*BLANKS” is a “figurative constant” rather than a variable. It is only known to the RPG compiler. SQL has no knowledge of it.

Phil’s example of simply using {EMPID = ‘ ‘} is best for this.

Tom

 108,055 pts.