Page 1 of 1

Variable arguments to revDataFromQuery don't seem to work

Posted: Wed Apr 01, 2015 8:29 pm
by Tukcedo
Is there any reason why this:

Code: Select all

#
# works fine
#
put "select Name, Address, Town, Email, WebSite, Twitter, Facebook, Lat, Lon from Rescue where Country = " & quote & tCountry & quote & " and Name = " & quote & tRescueName & quote into tSQL
put revDataFromQuery(,,tDBid, tSQL) into tList
works, but is a bit awkward to read, whereas this

Code: Select all

#
# no error, but no results
#
put "select Name, Address, Town, Email, WebSite, Twitter, Facebook, Lat, Lon from Rescue where Country = :1 and Name = :2" into tSQL
put revDataFromQuery(,,tDBid, tSQL, "tCountry", "tRescueName") into tList
is much cleaner code but doesn't turn up any results?

Re: Variable arguments to revDataFromQuery don't seem to wor

Posted: Thu Apr 02, 2015 7:56 pm
by phaworth
The code looks correct. Perhaps check if tCountry and tRescueName have the correct values in them?
Pete

Re: Variable arguments to revDataFromQuery don't seem to wor

Posted: Thu Apr 02, 2015 8:14 pm
by Tukcedo
They do ... I comment out the one version, test it, then comment out the next, run it again. Nothing else changes. I can't think of how it can be anything else than that I must be doing something else wrong in the call to revDataFromQuery.

Re: Variable arguments to revDataFromQuery don't seem to wor

Posted: Thu Apr 02, 2015 8:47 pm
by phaworth
That's strange, I use that format all the time (except with an array) and it seems to work fine.

Another possibility - any unusual characters in the tCountry or tRescueName variables, space, punctuation, etc. It shouldn't matter but just clutching at straws. From your web address, looks like you are in the Netherlands - do the variables have any Unicode characters in them? Once again, just clutching at straws.
Pete

Re: Variable arguments to revDataFromQuery don't seem to wor

Posted: Thu Apr 02, 2015 10:11 pm
by Tukcedo
Hehe yes, lots of straw to clutch at, but no there aren't any locale dependent characters there, it's (for the moment) still pretty simple. There can be spaces in there, so perhaps that's something. Does :1 take care of quoting the variables? That was my interpretation of the examples anyway.

Re: Variable arguments to revDataFromQuery don't seem to wor

Posted: Fri Apr 03, 2015 12:24 am
by phaworth
You don't need to bother with quoting or escaping quote characters within the variables, thats one of the things I like about using this feature. You probably already know, but it also protects against SQL injection attacks which, if you're using a network implementation of SQL is really important these days. I'm going to do some testing to see if spaces cause a problem because I don't see any reason why this shouldn't work for you.
Pete