search and replace a SQL query



i have a sql query in a variable called $sql

i want to search through the query and for every placeholder insert a
variable

Example

$sql = select * from table where user = ? id = ? address = ? name = ?

and i want to replace the question marks with a variable to complete
the query

so ive tried

$sql =~ s/"?"/$user/;
$sql =~ s/"?"/$id/;
$sql =~ s/"?"/$address/;
$sql =~ s/"?"/$name/;

which i thought would go in to $sql the first time, find the first ?
and put the contents on $user in place of the ? then the second time
there would only be 3 question marks left so the second line of code
should replace the second question mark with the content of the next
variable.

could anybody push me in the right direction here. its starting to
drive me nuts

.



Relevant Pages

  • Re: Run Query from Form
    ... Here is what my sql reads as requested. ... working even the first time that i push the button) but my code of the ... > Try switching to the SQL view and post your SQL statement of your query. ... > Jeff wrote: ...
    (microsoft.public.access.queries)
  • Re: How to make the SQL to run longer?
    ... To reproduce one of our cusotmer's probem, I need to make the SQL to ... If you just need a query, any query, that will run for more than a minute so that your app can hang, then you can easily create one. ... Then add the query to your reporting app. ... By the way...this is the first time I've ever heard of someone asking to make things take longer! ...
    (comp.databases.oracle.server)
  • Re: someone help
    ... >first time I am creating SPs.. ... You describe your query as if you were writing a Cobol ... That's not how SQL works. ... A few well-chosen rows of sample data, ...
    (microsoft.public.sqlserver.clients)
  • Use List Box to select a paramter for a query
    ... For the first time I'm trying to base a query on a user selection via a ... Qry_2's SQL is ... This is so similar to Joanna's query that John Vinson answered a few ...
    (microsoft.public.access.queries)
  • Re: Weird one.
    ... The first time a query runs, ... "Execution Plan Caching and Reuse" in SQL Server Books Online for more ...
    (microsoft.public.dotnet.languages.vb)