CRecordset::Open postgresql procedure call don't work

Started by jeanclaude marzinover 6 years ago3 messagesgeneral
Jump to latest
#1jeanclaude marzin
jeanclaude.marzin@sfr.fr

<span style="font-family:arial,helvetica,sans-serif">‌Hi<br>
I migrate from MSSQL to postgresql 11. I translate MSSQL stored procedure to Postgresql one :</span><br>
<br>
CREATE PROCEDURE procacp ()<br>
LANGUAGE SQL<br>
AS $$<br>
SELECT tabjdbexploit.jdbeid, tabjdbexploit.jdbeproc,<br>
&nbsp;&nbsp;&nbsp; tabjdbexploit.jdbedate, tabjdbexploit.jdbetypemsg,<br>
&nbsp;&nbsp;&nbsp; tabjdbexploit.jdbeurg, tabjdbexploit.jdbeconfid,<br>
&nbsp;&nbsp;&nbsp; tabjdbexploit.jdbeetat, tabmsgacp.acpid, &nbsp;<br>
&nbsp;&nbsp;&nbsp; tabmsgacp.acpnumserie,<br>
&nbsp;&nbsp;&nbsp; tabmsgacp.acpsignserv, tabmsgacp.acpnumligne,<br>
&nbsp;&nbsp;&nbsp; tabmsgacp.acpiaorigine, tabmsgacp.acpgdh,<br>
&nbsp;&nbsp;&nbsp; tabmsgacp.acperv,&nbsp; tabmsgacp.acpcdu,<br>
&nbsp;&nbsp;&nbsp; tabmsgacp.acpdir, tabmsgacp.acppere,<br>
&nbsp;&nbsp;&nbsp; tabmsgacp.acpcomplement, tabmsgacp.acpsection<br>
<br>
FROM tabjdbexploit INNER JOIN<br>
&nbsp;&nbsp;&nbsp; tabmsgacp ON tabjdbexploit.jdbeid = tabmsgacp.acpid<br>
<br>
ORDER BY tabjdbexploit.jdbedate ASC<br>
$$;<br>
<br>
<br>
<span style="font-family:arial,helvetica,sans-serif">All seems OK in PgAdmin 4, procedure is created<br>
<br>
I use ODBC and Crecorset in C++<br>
<br>
When i use the ca</span><span style="font-family:arial,helvetica,sans-serif; font-size:12px">ll </span>strSQL = "{CALL procacp()}". It don't work :<br>
<br>
Message error : ERROR: procacp() is a procedure<br>
<br>
I don't know what to do<br>
<br>
Thanks in advance for any assistance<br>
<br>
Jean-Claude

#2John McKown
john.archie.mckown@gmail.com
In reply to: jeanclaude marzin (#1)
Re: CRecordset::Open postgresql procedure call don't work

On Mon, Jul 15, 2019 at 6:40 AM jeanclaude marzin <jeanclaude.marzin@sfr.fr>
wrote:

‌Hi
I migrate from MSSQL to postgresql 11. I translate MSSQL stored procedure
to Postgresql one :

CREATE PROCEDURE procacp ()
LANGUAGE SQL
AS $$
SELECT tabjdbexploit.jdbeid, tabjdbexploit.jdbeproc,
tabjdbexploit.jdbedate, tabjdbexploit.jdbetypemsg,
tabjdbexploit.jdbeurg, tabjdbexploit.jdbeconfid,
tabjdbexploit.jdbeetat, tabmsgacp.acpid,
tabmsgacp.acpnumserie,
tabmsgacp.acpsignserv, tabmsgacp.acpnumligne,
tabmsgacp.acpiaorigine, tabmsgacp.acpgdh,
tabmsgacp.acperv, tabmsgacp.acpcdu,
tabmsgacp.acpdir, tabmsgacp.acppere,
tabmsgacp.acpcomplement, tabmsgacp.acpsection

FROM tabjdbexploit INNER JOIN
tabmsgacp ON tabjdbexploit.jdbeid = tabmsgacp.acpid

ORDER BY tabjdbexploit.jdbedate ASC
$$;

All seems OK in PgAdmin 4, procedure is created

I use ODBC and Crecorset in C++

When i use the call strSQL = "{CALL procacp()}". It don't work :

Message error : ERROR: procacp() is a procedure

I don't know what to do

Thanks in advance for any assistance

Jean-Claude

I am fairly sure that you need to make an FUNCTION and not a PROCEDURE.
Functions return values. Procedures do not. Why not try replacing the word
PROCEDURE with FUNCTION and give it another try?

ref: https://www.postgresql.org/docs/11/xfunc.html

--
We all agree on the necessity of compromise. We just can't agree on when
it's necessary to compromise. -- Larry Wall

Maranatha! <><
John McKown

#3Pavel Stehule
pavel.stehule@gmail.com
In reply to: jeanclaude marzin (#1)
Re: CRecordset::Open postgresql procedure call don't work

Hi

Dne po 15. 7. 2019 13:40 uživatel jeanclaude marzin <
jeanclaude.marzin@sfr.fr> napsal:

‌Hi
I migrate from MSSQL to postgresql 11. I translate MSSQL stored procedure
to Postgresql one :

CREATE PROCEDURE procacp ()
LANGUAGE SQL
AS $$
SELECT tabjdbexploit.jdbeid, tabjdbexploit.jdbeproc,
tabjdbexploit.jdbedate, tabjdbexploit.jdbetypemsg,
tabjdbexploit.jdbeurg, tabjdbexploit.jdbeconfid,
tabjdbexploit.jdbeetat, tabmsgacp.acpid,
tabmsgacp.acpnumserie,
tabmsgacp.acpsignserv, tabmsgacp.acpnumligne,
tabmsgacp.acpiaorigine, tabmsgacp.acpgdh,
tabmsgacp.acperv, tabmsgacp.acpcdu,
tabmsgacp.acpdir, tabmsgacp.acppere,
tabmsgacp.acpcomplement, tabmsgacp.acpsection

FROM tabjdbexploit INNER JOIN
tabmsgacp ON tabjdbexploit.jdbeid = tabmsgacp.acpid

ORDER BY tabjdbexploit.jdbedate ASC
$$;

It cannot to work - PostgreSQL procedures are like Oracle's procedures -
cannot returns any result. Only OUT variables can be changed.

Regards

Pavel

Show quoted text

All seems OK in PgAdmin 4, procedure is created

I use ODBC and Crecorset in C++

When i use the call strSQL = "{CALL procacp()}". It don't work :

Message error : ERROR: procacp() is a procedure

I don't know what to do

Thanks in advance for any assistance

Jean-Claude