sql update statement

Stephen Barncard stephenREVOLUTION at barncard.com
Sun Oct 1 00:55:52 EDT 2006


you need to concatenate lines with the \ or ¬ character.
I still prefer the ¬ (option l on macs) char myself

Also you have ' quotes surrounding " quotes. Rev 
doesn't work like PHP in that regard, it can only 
quote to one level.

also global, script local and local variables can 
be initialized by another variable, a literal 
number or text string, but it can't be 
initialized to a calculation on the right side of 
the =. Also there's no typing in Rev.

so you would do

local builtString = ""

put \
fld "2srd3" & comma & fld "2srd4" & comma & \
fld "2srd5" & comma & fld "2srd6" & comma & \
fld "2srd7" & comma & fld "2srd8" & comma & \
fld "srideht" & comma & fld "smisccomment" into builtString

to make a comma delimited string from a bunch of fields.

I actually like to put the names of the fields in 
a list and store data in an array. using rev's 
array notation. 
tVariableA[id],tVariableA[name],tVariableA[address], 
etc. Arrays can also be made using commas, tabs 
or any delimiter. Lines in a list can be an array.

Building complex SQL statements can be done 
easily in Rev, just perhaps not the way you're 
used to.

Here's a simple SQL string:

SELECT  * FROM `Contractors` ORDER BY `id` DESC

this is how you could put this into a variable for direct use as a SQL call.

put "SELECT  * FROM `Contractors` ORDER BY `id` DESC" into tLocalVariable

if you needed to use it with vars for FROM and ORDER BY
use the words Contractors and ID as a placeholder 
you could change them with replace this way

replace "Contractors" with "Installers" in tLocalVariable
replace "id" with "date" in tLocalVariable

you could also write a routine to replace the * 
with a list of fields to display. A short handler 
could be written to surround each field with a '

This also could be done with in-line variables or 
fields contents, but a little trickier.

put "SELECT" && fld "fieldlist" && "FROM" && "'" 
& label of btn "tableSelect" & "'"\
     &&   "ORDER BY" && "'" & (label of btn 
"tableORderby") & "'" & "DESC" into tSQL

by using groups, a handler could determine all 
grouped field names (which are designed to match 
the database fields), then create an array of all 
the data in the fields.

This is pretty heady stuff, MYSQL, to get into 
with your first app. Perhaps you should try 
something  a little simpler to goof around with 
to understand the 'Rev' way...

But don't get discouraged!

sqb

>I have a sql update statement that has several hundred items in it, is it
>possible to leave it in list format like this
>
>2srd3 = '"& fld "2srd3" &"',
>2srd4 = '"& fld "2srd4" &"',
>2srd5 = '"& fld "2srd5" &"',
>srideht = '"& fld "srideht" &"',
>smisccomment = '"& fld "smisccomment" &"',
>
>and not like this
>
>  2srd3 = '"& fld "2srd3" &"', 2srd4 = '"& fld "2srd4" &"', 2srd5 = '"& fld
>"2srd5" &"', srideht = '"& fld "srideht" &"', smisccomment = '"& fld
>"smisccomment" &"',
>
>why you might ask do I want to do this, well once I get out quit a ways on
>one line rev seems to not like it and starts to give me problems run slow,
>and not want to copy and paste
>
>I tried the above list format but it does not like the returns after each
>comma, what can I do to correct this?
>
>Robert Mann

-- 
stephen barncard
s a n  f r a n c i s c o
- - -  - - - - - - - - -


More information about the use-livecode mailing list