How to excute dynamically a generated SQL command?

From: "John Zhang" <johnzhang06(at)gmail(dot)com>
To: postgis-users(at)postgis(dot)refractions(dot)net
Subject: How to excute dynamically a generated SQL command?
Date: 2009-01-04 01:57:32
Message-ID: 618950b80901031757l15109658kdae1cdb0814d33fc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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'');';
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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message sergey kapustin 2009-01-04 20:53:46 EXECUTE with a prepared plan and NULL
Previous Message Steve Midgley 2009-01-03 17:48:01 Re: Question on Escape-string