[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sql: with argument substitution

From: Hans Schou
Subject: Re: sql: with argument substitution
Date: Thu, 14 Apr 2011 09:43:44 +0200

2011/4/14 Ole Tange <>:

> I am not sure if the {1} syntax is good or if the syntax should use $1
> instead. I would prefer using a syntax that is easy to understand -

How would you deal with handling '$1' litterally in a SQL statement?

 1. SELECT * FROM foo WHERE price='$1'; -- normal way
 2. SELECT * FROM foo WHERE price='\$1'; -- escaped
 3. SELECT * FROM foo WHERE price='$$1'; -- escaped

And how should {1} be escaped?

> preferably something already known and which does not make problems
> with any dialect of SQL. So if some obscure SQL dialect uses $1 for
> something else (e.g. in functions), then that is a no-go.

I think MySQL had something with a data type which was an array and
there the curly bracket is used but Im not sure.
I don't remember seeing $1 in any SQL dialect.

> So dear users: Please give some advice on what you think about this
> and if you can find an even better idea for implementation.

I would prefer $1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]