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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-odbc by date

  From Date Subject
Next Message ning 2009-04-17 09:26:33 Re: Bound parameter is not substituted
Previous Message Adrian Klaver 2009-04-16 14:20:19 Re: Bound parameter is not substituted