Variable arguments to revDataFromQuery don't seem to work

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

Variable arguments to revDataFromQuery don't seem to work

Post by Tukcedo » Wed Apr 01, 2015 8:29 pm

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?
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

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

Post by phaworth » Thu Apr 02, 2015 7:56 pm

The code looks correct. Perhaps check if tCountry and tRescueName have the correct values in them?
Pete

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

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

Post by Tukcedo » Thu Apr 02, 2015 8:14 pm

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.
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

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

Post by phaworth » Thu Apr 02, 2015 8:47 pm

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

Tukcedo
Posts: 65
Joined: Fri Jun 27, 2014 9:43 pm

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

Post by Tukcedo » Thu Apr 02, 2015 10:11 pm

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.
Michel J.L. van der Kleij
Coding to help stray animals in the Philippines
Albert Foundation - http://albert.tukcedo.nl
Aklan Animal Rescue & Rehabilitation Center - http://aarrc.tukcedo.nl

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

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

Post by phaworth » Fri Apr 03, 2015 12:24 am

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

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”