Re: Bound parameter is not substituted - Mailing list pgsql-odbc

From ning
Subject Re: Bound parameter is not substituted
Date
Msg-id 27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com
Whole thread Raw
In response to Re: Bound parameter is not substituted  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Bound parameter is not substituted
List 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@sss.pgh.pa.us> wrote:
> ning <mailxiening@gmail.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
>

pgsql-odbc by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Bound parameter is not substituted
Next
From: ning
Date:
Subject: Re: Bound parameter is not substituted