Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Oracle/Sql question

Status
Not open for further replies.

MarkR2207

Programmer
Sep 19, 2003
7
US
Good Afternoon,

My knowledge of SQL is limited so please bare with. I am attempting to select all the records in a table that meet two criteria, Serial Number and Status. Thanks in advance for suggestions.



SetRSTRE "SELECT * FROM MCSDCOM_APP.VW_RADIO_INVENTORY WHERE RADIO_SERIAL_NUMBER = '" & Me.txtInqSerialNumber.Text & "RADIO_STATUS <> 'ISSUED''", ceRST, ceCNN
 
One minor error on your SQL.
The way you have it it translate to
SELECT * FROM MCSDCOM_APP.VW_RADIO_INVENTORY WHERE RADIO_SERIAL_NUMBER = 'serial_number_text_valueRADIO_STATUS <> 'ISSUED'


As you can see this is wrong, as if "serial_number_text_value" has a value of "123" your sql is
RADIO_SERIAL_NUMBER = '123RADIO_STATUS <> 'ISSUED'
and this won't work at all.

You need to add a "'" before and AFTER each variable (or not if they are numbers) and an "AND" between each criteria.

e.g.
you need
RADIO_SERIAL_NUMBER = 'var' AND RADIO_STATUS <> 'ISSUED'

So your particular code is missing "' AND "

When ever you are doing this type of SQL always debug the program, and always look at the value of the variable.

I would change your code as follows
dim sSql as string
sSql = "SELECT * FROM MCSDCOM_APP.VW_RADIO_INVENTORY WHERE"
sSql = sSql & " RADIO_SERIAL_NUMBER = '" & Me.txtInqSerialNumber.Text & "'"
sSql = sSql & " and RADIO_STATUS <> 'ISSUED'"

SetRSTRE sSql, ceRST, ceCNN

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top