Re: function query error: column does not exist

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: giozh <giozh(at)yahoo(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: function query error: column does not exist
Date: 2013-07-11 10:22:47
Message-ID: CAF-3MvNRzGPzc_GkRPom-+Ccrine7fh01kpx+rGJGbmZG2vSdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11 July 2013 11:01, giozh <giozh(at)yahoo(dot)it> wrote:

> this is the insert code:
>
> >EXECUTE 'INSERT INTO table VALUES('||value1||','[...]','||value_char||')';
>
> and the error is on value_char. pg told me that "column does not exist".
>

A few suggestions:

1. Post a statement that actually matches your problem statement. What you
posted can't possibly work as [...] is not valid SQL syntax. Post the
actual query. You can replace table names and column names and such with
example names, if/where necessary.

2. Show the actual error message instead of some interpretation; the actual
message would have mentioned the name of the column that doesn't exist.
That would have been useful info.

3. Don't concatenate values into a dynamic query, use USING instead so that
the values get properly escaped and don't open you up for SQL injection
issues.

The problem you ran into was possibly (we really can't tell from the info
you provided) an error in how you quote the various parts of the query, or
one of your variables/parameters had a value that contained a quote.

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2013-07-11 11:41:10 Re: pg recovery
Previous Message Jayadevan M 2013-07-11 09:19:28 Re: pg recovery