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
>