What is wrong with the blanks in SQL/400 code?

770 pts.
Tags:
AS/400
AS/400 SQL
What is wrong in the *BLANKS in the following code WHERE (EMPID=:*BLANKS OR EMPID=:EMPID)

Software/Hardware used:
AS400

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • CharlieBrowne
    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?
    41,370 pointsBadges:
    report
  • philpl1jb
    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
    49,550 pointsBadges:
    report
  • carlosdl
    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".
    68,430 pointsBadges:
    report
  • philpl1jb
    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
    49,550 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report
  • ankit2002
    [...] 3. CharlieBrown, Philpl1jb and Carlosdl discuss the ‘BLANKS’ code in a SQL statement. [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following