Re: Enclosing values in single quotes

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Ma Siva Kumar <siva(at)leatherlink(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Enclosing values in single quotes
Date: 2002-06-18 08:30:57
Message-ID: 20020618183057.A2786@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 18, 2002 at 12:10:58PM +0530, Ma Siva Kumar wrote:
>
> I am trying to write a function which takes in an associative array (from a
> user submitted form for example), converts the keys to a column array and
> values to a value array. These arrays together with the name of the database
> table are fed into another function, which generates the query string (insert
> into $table ($colmn) values ($value)).
>
> As a short cut, I am enclosing all the values (numeric as well as strings)
> in single quotes when generating the arrays. In my trials so far,
> everything is fine. What will be the issues in enclosing numeric values in
> single quotes?

Absolutly none. In fact, it will work better than if you attempt to leave
them off, since without quote, they'll all be interpreted as int4. With
quotes, they'll all be interpreted by the appropriate input function for
each type.

Don't forget to escape the ' and \ characters.
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2002-06-18 08:34:25 Re: Wierd Explain
Previous Message Varun Kacholia 2002-06-18 07:00:47 Re: Wierd Explain