SQLite Issue
Scott Kane
scott at proherp.com
Mon Dec 26 23:52:13 EST 2005
Hi folks,
Hope you all had a great holiday. :)
I'm stuck on a problem. I had this solved
two months ago, had a HD crash and the backups
I have turn out to be incorrect, so I'm unable
to get this rather (what should be) easy function
to work. Note that I'm a Rev newbie, so I'm still
fighting with relatively little script knowledge.
Anyway, the excerpt below is from Altuits altSQL
demo. I don't want to bother Chipp and co with
such elementary problems. So I thought I'd give
it a go here.
The script adds a record to a table in SQLite.
What I'm trying to do is get the value of a Field
into the array ready to be parsed into SQL by the
handlers (included). I'm getting the result "It"
rather than the value of the field (in the example
below the field is called "edName"). Hoping someone
can throw some light onto what I'm doing wrong! A
code snippet that works the I need it to would be
heaven! I wish, basically, to put the values of the
field boxes into the new record.
TIA
Scott
-------- Paste Script -------------
on mouseUp
global gConID
--> COLLECT name AND email
put "name,email" into tColumnItems
repeat for each item I in tColumnItems
--ask question "New value for column: " & I
put Field "edName" into i
--if it is empty or the result is "cancel" then exit to top
put "'" & cleanSQL(it) & "'" & "," after tRowData
end repeat
--> COLLECT emailList
ask question "New value for column: emailList" with "true"
if it is empty or the result is "cancel" then exit to top
put "'" & cleanSQL(it) & "'" after tRowData
--> CONSTRUCT SQL
put "INSERT INTO users(userID,name,email,emailList)" & \
" VALUES(null," & tRowData & ")" into tSQL
--> EXECUTE SQL
put revdb_execute(gConID,tSQL) into tTmp
handleRevDBerror tTmp
if the result is not empty then
answer warning the result
exit mouseUp
end if
answer information "Number of rows added: " &cr& tTmp
end mouseUp
function cleanSQL pSQL
--> THIS ESCAPES THE QUOTE PROBLEM IN SQL
replace "'" with "''" in pSQL
replace quote with quote & quote in pSQL
--> THIS ESCAPES THE tab AND cr DELIMITERS
--> IF YOU PLAN ON HAVING USERS ENTER cr AND tab THEN YOU ALSO NEED TO
--> replace "*CR*" with cr IN THE RETURNED DATA!
replace cr with "*CR*" in pSQL
replace tab with "*TAB*" in pSQL
return pSQL
end cleanSQL
---------- End Paste --------------
More information about the use-livecode
mailing list