|
naubol Newbie
Joined: 13 Mar 2004 Posts: 3 Location: USA
|
Posted: Sat Mar 13, 2004 11:36 pm
Variable Expansion problems |
I want to be able to use variables that expand inside ADO SQL statements...heres what I currently have.
quote:
#CALL @con.Execute( "INSERT INTO ftalk (name,comment) VALUES ('@friendname','@comment')")
Why do the variables not expand? What can I do to make them expand?
N |
|
|
|
Zakarius Newbie
Joined: 17 Mar 2003 Posts: 5 Location: Canada
|
Posted: Sat Mar 13, 2004 11:54 pm |
reply I don't know if this applies to your problem but variables can be expanded when surrounded <@variable> like that.
again I don't know if that will work in your situation but you can try. |
|
|
|
naubol Newbie
Joined: 13 Mar 2004 Posts: 3 Location: USA
|
Posted: Sun Mar 14, 2004 12:10 am |
Yeah I thought that might work too, but it didn't.
:(
N |
|
|
|
IceChild Magician
Joined: 11 Oct 2000 Posts: 419 Location: Post Falls, ID, USA
|
Posted: Sun Mar 14, 2004 12:12 am |
Have you tried using the %expand(@friendname) method?
That may solve your problem. |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Mar 14, 2004 12:23 am |
Currently your SQL statement is contained in a set of quotes. This causes the parser to treat it literally.
#CALL @con.Execute( "INSERT INTO ftalk (name,comment) VALUES ('@friendname','@comment')")
Instead you should use the %concat function.
#CALL @con.Execute(%concat("INSERT INTO ftalk (name,comment) VALUES ('",@friendname,"','",@comment,"')")) |
|
|
|
naubol Newbie
Joined: 13 Mar 2004 Posts: 3 Location: USA
|
Posted: Sun Mar 14, 2004 12:33 am |
okay I've determined that the real problem is variable expansion inside of quotes.
The only solution that I can think of, is %concat but %concat _requires_ quotes and you need some sort of escape character to insert a quote into a concat and I don't know it! very frustrating. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Mar 14, 2004 2:44 pm |
No need for an escape character, the %char function will return the character of whatever ASCII code you supply:
#SH %concat("This is some text with a ", %char(34), " in it.") |
|
|
|
|
|