Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently December 22nd, 2024, 9:21 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Passing a parameter to a SQL statement using a variable
PostPosted: April 7th, 2010, 9:13 pm 
Offline

Joined: September 6th, 2008, 6:24 pm
Posts: 15
Location: Brazil
Does anyone know how to pass a parameter to a SQL statement (ex: SELECT * FROM Tabela WHERE Field=<variable>)?


For this message Interactive has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Passing a parameter to a SQL statement using a variable
PostPosted: April 7th, 2010, 11:23 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Quote:
how to pass a parameter to a SQL statement (ex: SELECT * FROM Tabela WHERE Field=<variable>)?

Do you mean this:
Code:
SELECT * FROM Tabela04 WHERE Field002= '"+variable014+"' ;


Going a little further, you can write your SQL Statement into a variable and then just reference that variable later where the SQL Statement is expected. Just be sure to use surrounding quote marks and include the ending semi-colon.
Code:
var getCustomerSQL = "SELECT CustomerName FROM CustTable WHERE RegionCode = '"+variable014+"' ;"

//later, calling the function ListCustomers() --- which will use the SQL Statement
ListCustomers(getCustomerSQL)

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: Passing a parameter to a SQL statement using a variable
PostPosted: April 8th, 2010, 1:50 am 
Offline

Joined: September 6th, 2008, 6:24 pm
Posts: 15
Location: Brazil
Thank you very much for your help, my friend. It worked fine!


For this message Interactive has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Passing a parameter to a SQL statement using a variable
PostPosted: April 8th, 2010, 2:59 pm 
Offline

Joined: September 6th, 2008, 6:24 pm
Posts: 15
Location: Brazil
Dear Lar_123,

In completion to my question, let me ask your attention again:
where is the statement below syntatically wrong?

"INSERT INTO Table1 (Field1,Field2) VALUES ('" + variable1 + "', '" + variable2 + "');"

I would really appreciate your attention.
Thanks in advance!


For this message Interactive has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: Passing a parameter to a SQL statement using a variable
PostPosted: April 8th, 2010, 7:38 pm 
Offline
Godlike
Godlike

Joined: November 12th, 2005, 1:56 am
Posts: 1474
Location: SFBay Area
Opus: OpusPro v9.0x, & Evol.
OS: Vista32
System: Core 2 duo 2Ghz, RAM 3GB, Nvidia Go 7700 - laptop
Int,

I don't know. I'll have to look into it.
My first impression and guess is to try this:
Code:
"INSERT INTO Table1 (Field1,Field2) VALUES ( variable1, variable2 );"


In the meantime you could do a little browsing here in the forum, simply search for SQL and SELECT keywords, or SQL and INSERT keywords. You will find some examples of opusscript that confirm variable names are written directly into certain parts of the sql statement.

_________________
_good things come to those who wait(0)_


For this message Lar_123 has been thanked by : mackavi


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 31 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group