Skip site navigation (1) Skip section navigation (2)

Re: Bound parameter is not substituted

From: ning <mailxiening(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: Bound parameter is not substituted
Date: 2009-04-17 05:52:44
Message-ID: 27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-odbc
Thank you very much for your reply.

Now I understand the cause of the error, but I seems funciton body
cannot be constructed dynamically.
I tried:
-----------
ss <<
   "create or replace function plpgsql_setDocAttrs() returns void as ' "
   "declare "
   "pid integer; "
   "begin "
   "pid := ' "
   " || ? || "
   "'; "
   "end;"
   "' language plpgsql volatile;"
----------

When I bind a variable, with value 10, to ?, the string after substitution is
----------
create or replace function plpgsql_setDocAttrs() returns void as
'declare pid integer;begin pid := '  || 10 || '; end;' language
plpgsql volatile;
----------
I got the following error:
ERROR:  syntax error at or near "||"

String concatenation operator "||" is not allowed in "create function"
statement, which breaks syntax.
Is there any way to force string concatenation before function definition?
So that the  function body is firstly concatenated to
---------
'declare pid integer;begin pid := 10; end;'
--------
Then "create function" statement is executed as
-------
create or replace function plpgsql_setDocAttrs() returns void as '
declare pid integer;begin pid := 10; end;' language plpgsql volatile;
------

Any suggestion or idea is appreciated.

Best regards.

ning

On Thu, Apr 16, 2009 at 11:07 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> ning <mailxiening(at)gmail(dot)com> writes:
>> I am trying to create a stored function through ODBC connection,
>> But the parameter marker inside the function is not substituted.
>
> You've written a question mark inside a string literal.  It would be
> a bug for the software to consider that to be a parameter marker.
> It's just a question mark.
>
>                        regards, tom lane
>

In response to

Responses

pgsql-odbc by date

Next:From: ningDate: 2009-04-17 09:26:33
Subject: Re: Bound parameter is not substituted
Previous:From: Adrian KlaverDate: 2009-04-16 14:20:19
Subject: Re: Bound parameter is not substituted

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group