From: | "Vilches, Alejandro" <alejandro(dot)vilches(at)intel(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, "pgsql-odbc(at)postgresql(dot)org" <pgsql-odbc(at)postgresql(dot)org> |
Subject: | Re: Problem calling a function from ODBC application |
Date: | 2017-02-03 19:41:44 |
Message-ID: | 9CE034E149417949A58AA9A4FA7E1C5586DC1016@ORSMSX115.amr.corp.intel.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-odbc |
Hi Adrian,
Thanks for your reply. To be honest, my application is a bit more complex and I simplified things to make the question easier to ask. I did go back and write up a small program as described in the question and now the error message I'm getting is different, but I'm still having issues calling my function from ODBC.
In essence, the problem I'm having is calling a function from ODBC that has an output parameter. I can call it just fine from psql by simply executing "select * from my_function(...)". But calling it from my application I get the following error: "ERROR: syntax error at end of input;"
Please find the source code attached. The stored function is very simple and silly:
CREATE OR REPLACE FUNCTION public.my_function(a integer, b bigint, c character varying, OUT d bigint)
RETURNS bigint
LANGUAGE plpgsql
AS $function$
BEGIN
d := a + b + char_length(c);
END
$function$
Thanks!
Alejandro
-----Original Message-----
From: Adrian Klaver [mailto:adrian(dot)klaver(at)aklaver(dot)com]
Sent: Wednesday, February 1, 2017 7:16 PM
To: Vilches, Alejandro <alejandro(dot)vilches(at)intel(dot)com>; pgsql-odbc(at)postgresql(dot)org
Subject: Re: [ODBC] Problem calling a function from ODBC application
On 02/01/2017 07:05 PM, Vilches, Alejandro wrote:
> Hi,
>
>
>
> I'm having an issue calling a stored function in my database from my
> application using ODBC. The application creates a prepared statement
> with the following string/text using SQLPrepare(): "{call
> my_function(?, ?, ?, ?)}" (where the fourth parameter is an out
> parameter). Then, it binds the parameters using SQLBindParameter()
> and specifying the correct data types. This is the function's signature:
>
> "my_function(in a integer, in b bigint, in c character varying, out d
> bigint)".
>
>
>
> However, when I execute the application, I get the following error:
>
> ERROR: function my_function(integer, bigint, unknown) does not exist;
>
>
>
> Why does it recognize the first two parameters correctly and not the
> third one? I've double checked everything including the binding of
> that parameter to make sure it's the correct type (SQL_VARCHAR).
I think this is going to require showing the actual entire code sequence that sets up the parameters and binds them and then calls the function.
>
>
>
> The details:
>
>
>
> Language: C/C++
>
> GCC: 4.8.5
>
> ODBC driver manager: unixODBC 2.3.1
>
> PostgreSQL: 9.4.5
>
> PostgreSQL ODBC driver: psqlodbc-09.05.0400
>
> OS: SLES 12-SP1
>
>
>
> Sorry if this is a repeated question. I tried searching and couldn't
> find a solution.
>
>
>
> Any help is greatly appreciated.
>
>
>
> Thanks!
>
> Alejandro
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
Attachment | Content-Type | Size |
---|---|---|
my_function.c | text/plain | 5.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Inoue, Hiroshi | 2017-02-04 00:15:05 | Re: Problem calling a function from ODBC application |
Previous Message | Daniil Megrabyan | 2017-02-03 17:15:16 | MyLog and CommLog options |