Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
naubol
Newbie


Joined: 13 Mar 2004
Posts: 3
Location: USA

PostPosted: 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
Reply with quote
Zakarius
Newbie


Joined: 17 Mar 2003
Posts: 5
Location: Canada

PostPosted: 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.
Reply with quote
naubol
Newbie


Joined: 13 Mar 2004
Posts: 3
Location: USA

PostPosted: Sun Mar 14, 2004 12:10 am   
 
Yeah I thought that might work too, but it didn't.

:(

N
Reply with quote
IceChild
Magician


Joined: 11 Oct 2000
Posts: 419
Location: Post Falls, ID, USA

PostPosted: Sun Mar 14, 2004 12:12 am   
 
Have you tried using the %expand(@friendname) method?

That may solve your problem.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: 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,"')"))
Reply with quote
naubol
Newbie


Joined: 13 Mar 2004
Posts: 3
Location: USA

PostPosted: 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.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: 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.")
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net