Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Verifying the result of a SELECT using VBScript

Hi,

I'm creating a VBScript sub to read from a SQL Server table. The select reads records filtering from a particular primary key value passed by a QV variable.

I have sSQL = "SELECT TOP 1 Code FROM myTable where code = '" & varCodeValue & "'".

When it exists a record for code value I can control the select result with sSQL.Fields(0).Value, but when no records are found I have an error.

How can I verify when my select returns no records? Thanks

1 Reply
deepakk
Partner - Specialist III
Partner - Specialist III

hi,

Check if its len is greater than zero. Something like below

if len(trim(sSQL.Fields(0).Value)) >0 then

store value

else

exit script.

end if