Page 1 of 1
How to concatenate my sql statement..?
Posted: Sat Mar 08, 2014 3:35 am
by snop21
Hello livecoders,
Just wanna ask how can I concatenate my sql statement I have 100 columns in my table in my script
---------> put "CREATE TABLE CBMS_Details (A_1A char(10), City A_1B(10), A_1C char(10), A_1D char(10) \
,A_1E char(10))" into tSQL
--------> revExecuteSQL conn, tSQL
so I wanna make it 10 columns each line I tried the script above it was wrong. I use \ to concatenate.. Not working..
Need help..
Thank you..
Regards
-snop21
Re: How to concatenate my sql statement..?
Posted: Sat Mar 08, 2014 4:00 am
by Simon
Code: Select all
put "CREATE TABLE CBMS_Details (A_1A char(10), City A_1B(10), A_1C char(10), A_1D char(10)"& \
",A_1E char(10))" into tSQL
Simon
Re: How to concatenate my sql statement..?
Posted: Sat Mar 08, 2014 9:37 am
by SparkOut
Or if it is just for legibility, then it can be much more readable to break up the string into sections...
put "CREATE TABLE CBMS_Details " into tSQL
put "(A_1A char (10))" after tSQL
Obviously add the rest of the column definitions - I did not as I am on phone keyboard and too lazy.
If you go even further you can make it something like
put "CREATE TABLE CMS_Details" into tSQLaction
put "(A_1A char (10))" into tSQLoptions
put tSQLaction && tSQLoptions into tSQL
Note the differences in handling space between clauses.
Re: How to concatenate my sql statement..?
Posted: Sat Mar 08, 2014 1:33 pm
by Klaus
You are trying to concatenate a STRING with \, but that does only work with a SCRIPT!
Simon and SparkOut already gave the solution.
Re: How to concatenate my sql statement..?
Posted: Sat Mar 08, 2014 6:48 pm
by bangkok
With 100 columns... with you bother to type the query ?
You should use a loop to create it.
Code: Select all
put "CREATE TABLE CBMS_Details (" into tSQL
repeat with i = 1 to 100
put "A_"&i&"A char(10), City A_"&i&"B(10), A_"&i&"C char(10), A_"&i&"D char(10),A_"&i&"E char(10)," after tSQL
end repeat
delete last char of tSQL
put ")" after tSQL
revExecuteSQL conn, tSQL
Re: How to concatenate my sql statement..?
Posted: Sat Mar 08, 2014 6:56 pm
by Klaus
YES!
Your message contains 7 characters. The minimum number of characters you need to enter is 10.