[postgis-users] Using string variables with PGScript

David Fawcett david.fawcett at gmail.com
Wed Sep 23 18:43:30 PDT 2015


Bob,

I haven't ever used PGScript, but I wonder one of the postgres quote
functions found on this page might work:
http://www.postgresql.org/docs/9.1/static/functions-string.html

I would try quote_literal()

David.

On Wed, Sep 23, 2015 at 4:26 PM, Bistrais, Bob <Bob.Bistrais at maine.gov>
wrote:

> I am having trouble using a variable in a Select statement, using
> PGScript.  I am trying to define a string variable, then use it in the
> Select statement.  Something like this:
>
>
>
> DECLARE @MYSTRING;
>
> SET @MYSTRING = CAST(@REC[0]['mycode'] AS STRING);   -- at REC was set from a
> previous select
>
>
>
> SELECT * from mytable where myfield = @MYSTRING;
>
>
>
> -The variable is not quoted, so the select statement fails.  How do I get
> the string variable to be enclosed in quotes?
>
>
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150923/a0ce2539/attachment.html>


More information about the postgis-users mailing list