Returning a value from an SQL query
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Returning a value from an SQL query
I am using MAMP in order to connect to an SQL database. I can connect just fine but the problem arises when I try to execute my query. I am trying to perform a count(*) query on a table and return the value but every time I run it the result is "OK" which apparently counts as a number because it causes my "if the result is a number" statement to trigger. any ideas as to how I could fix this?
-
- Livecode Opensource Backer
- Posts: 366
- Joined: Tue Apr 10, 2012 9:18 am
Re: Returning a value from an SQL query
can we see the code you have so far? or the query and return section of it?
Re: Returning a value from an SQL query
put "SELECT COUNT(*) FROM scores" into tSQL
revExecuteSQL gConnectionID, tSQL
if the result is a number then
put it into temp
put "00000" + temp into ScoreID
else
answer"nope"
end if
answer ScoreID
revExecuteSQL gConnectionID, tSQL
if the result is a number then
put it into temp
put "00000" + temp into ScoreID
else
answer"nope"
end if
answer ScoreID
-
- VIP Livecode Opensource Backer
- Posts: 190
- Joined: Sat Apr 08, 2006 7:55 am
- Location: Lübbecke, Germany
- Contact:
Re: Returning a value from an SQL query
You have to use the function revDatafromQuery for this.
revExecuteSQL is used for example for inserting, updating, deleting a record.
revExecuteSQL is used for example for inserting, updating, deleting a record.
Re: Returning a value from an SQL query
Thank you very much, everything works fine now
Re: Returning a value from an SQL query
A look into the Dictionary, which is better than its reputaiton, usually clears these kind of "misunderstandings"!