From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-07-2011 05:53 AM
I am trying to execute the following SQl query, SELECT * FROM Failure WHERE ID = '123' AND RepairAction = ' ';, using the DB Tools Execute Query.vi. This query never finds the record in my database. My database contains a record where the ID filed contains the value of '123' and the RepairAction field is an empty string. If I remove the 'AND RepairAction ' ';' text from my query statement, the record is found. I believe my problem is that I am not using the correct syntax to describe and empty string. I have tried the following: '', ' ', "", " ", and NULL as empty string arguments, and none of these work.
I was hoping someone might be able to tell me what the correct syntax is for an empty string or if there is another approach I need to take.
Thank you in advance for your help,
Jim
Solved! Go to Solution.
06-07-2011 06:06 AM
Hi,
While creating your table "Failure", was the column "ID" delclared as intiger or varchar? If it is intiger and you use '123' , it wont return the results. You will have to try without the inverted comas ' '.
Regards,
Nitzz
(Giver Kudos to good Answers, Mark it as a solution if your problem is Solved;))
06-07-2011 06:09 AM
Hi there Jim,
you could try modifying your command just a little bit. Try this:
...AND RepairAction is null;
It works for me in Oracle.
Cheers,
Cerati
06-07-2011 06:10 AM
The column ID is varchar. As previously stated the query works when I leave out the RepairAction search. So I think the problem is with my syntax for declaring an empty string in the SQL query.
Thank you,
Jim
06-07-2011 06:15 AM
Hi Cerati,
I tried your suggestion, null, and still did not return a record.
Thank you. I appreciate your assistance.
Jim
06-07-2011 06:19 AM
Jim,
Just to be sure, did you use "is" instead of " = " in that command ?
That makes the whole difference in that command.
Cerati
06-07-2011 06:27 AM
06-07-2011 06:30 AM
Cerati,
"is" is the solution. Thank you for pointing out this 'minor' detail. I had initially tested you suggestion using the "=". When I replaced this with "is" per your follow up, the record was read.
Thank you again,
Jim
06-07-2011 06:32 AM
Okey, I'm glad it worked for you as well
Cheers,
Cerati