pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ning <mailxiening@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Bound parameter is not substituted
Date: Fri, 17 Apr 2009 14:52:44 +0900
Message-ID: <27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com> (raw)
In-Reply-To: <16591.1239890835@sss.pgh.pa.us>
References: <27f31620904160102j7668c947ta435601dd8751c6e@mail.gmail.com>
	<16591.1239890835@sss.pgh.pa.us>

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
>



view thread (5+ messages)  latest in thread

Message-ID: <27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com>
Permalink:  ../27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com/
Also on:    postgresql.org/message-id/27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: mailxiening@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: Bound parameter is not substituted
  In-Reply-To: <27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com>
  References: <27f31620904160102j7668c947ta435601dd8751c6e@mail.gmail.com> <16591.1239890835@sss.pgh.pa.us> <27f31620904162252t650c5205g1305a3cdbce15c1@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox