Re: How to excute dynamically a generated SQL command? - Mailing list pgsql-sql

From Adrian Klaver
Subject Re: How to excute dynamically a generated SQL command?
Date
Msg-id 200901041304.37661.aklaver@comcast.net
Whole thread Raw
In response to How to excute dynamically a generated SQL command?  ("John Zhang" <johnzhang06@gmail.com>)
List pgsql-sql
On Saturday 03 January 2009 5:57:32 pm John Zhang wrote:
> Hi the list,
>
> Referring to the PostgreSQL 8.3 documentation " 38.5.4. Executing Dynamic
> Commands ", the command for executing a dynamic command is:
> EXECUTE command-string [ INTO [STRICT] target ];
>
>
> I am to execute an sql statement created dynamically, which is represented
> in a variable sSql.
> Here is an example:
> sSql='INSERT INTO hm_raster.hm_airphotos( file_ext, airphoto) VALUES
> ('.tif',  lo_import( E''C:\\HM\\Data\\Flightmap.tif'');'

You are missing a ')'  Should be
VALUES ('.tif',  lo_import( E''C:\\HM\\Data\\Flightmap.tif''));';

> EXECUTE sSQL;
>
> It raises the error as:
> ERROR:  syntax error at end of input
> LINE 1: ...E'C:\\HM\\Data\\Flightmap.tif')
>                                                           ^
>
> I would appreciate a lot if you offer your input. Thanks a lot.
>
> John



-- 
Adrian Klaver
aklaver@comcast.net


pgsql-sql by date:

Previous
From: "sergey kapustin"
Date:
Subject: EXECUTE with a prepared plan and NULL
Next
From: Tom Lane
Date:
Subject: Re: EXECUTE with a prepared plan and NULL