Thread: facing problem in outparameters in c

facing problem in outparameters in c

From
Mahesh Bodepati
Date:
Hi Team,

i am facing the problem in passing the outparameters in postgres package calling by using c language.can you please help us to solve the problem..

below is way iam calling the package.

 snprintf(buffer, sizeof(buffer),"SELECT  smp_ss7_mig_dev.pr_pkg_oss_networkserver_pr_sp_apply_sl_yn('%s','%s','%s', %d ,%d)",m_h_imsi.arr,m_h_hlraddress.arr,m_h_vlraddress.arr,m_ht_message,m_ht_msgType,allow_yn,po_ns_relay_reason,po_sl_relay_reason);

         res = PQexec(con,buffer);
         if (PQresultStatus(res) != PGRES_TUPLES_OK) {

                printf("No data retrieved\n");
                PQclear(res);
                PQfinish(con);
                exit(1);
                }



printf("allow_yn===%d\tpo_ns_relay_reason==%d\tpo_sl_relay_reason==%s\n",allow_yn,po_ns_relay_reason,po_sl_relay_reason.arr);




Thanks & Regards,
Mahesh Bodepati
Software Engineer- Engineering
XIUS
INNOVATE . LEAD.



Re: facing problem in outparameters in c

From
Laurenz Albe
Date:
On Mon, 2020-10-26 at 10:45 +0000, Mahesh Bodepati wrote:
> i am facing the problem in passing the outparameters in postgres package calling by using c language

There are no "packages" in PostgreSQL.
Can you clarify your question?

How is the function or procedure you are calling defined?

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




Re: facing problem in outparameters in c

From
Mahesh Bodepati
Date:
Actually i am calling a postgres function by using c language  which  description is defined in database side .when iam calling a postgres function by passing input and output parameters after excution of function in database side i need output  data in correcsponding  output parameters but iam not getting output like that. i am getting total output data in response pointer.if iam getting total data in response pointer it is hard to figure out which data  is for which output parameter. can you please check once attached two text files.




Thanks & Regards,
Mahesh Bodepati
Software Engineer- Engineering
XIUS
INNOVATE . LEAD.





From: Laurenz Albe <laurenz.albe@cybertec.at>
Sent: Tuesday, October 27, 2020 8:09 PM
To: Mahesh Bodepati <mahesh.bodepati@Xius.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: facing problem in outparameters in c
 
On Mon, 2020-10-26 at 10:45 +0000, Mahesh Bodepati wrote:
> i am facing the problem in passing the outparameters in postgres package calling by using c language

There are no "packages" in PostgreSQL.
Can you clarify your question?

How is the function or procedure you are calling defined?

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

Attachment

Re: facing problem in outparameters in c

From
Laurenz Albe
Date:
On Wed, 2020-10-28 at 04:57 +0000, Mahesh Bodepati wrote:
> Actually i am calling a postgres function by using c language  which  description
>  is defined in database side .when iam calling a postgres function by passing input
>  and output parameters after excution of function in database side i need output
> data in correcsponding  output parameters but iam not getting output like that.

Right; output parameters in a function are columns in the result set.

>  i am getting total output data in response pointer.if iam getting total data
>  in response pointer it is hard to figure out which data  is for which output parameter.

No, that is very simple.  You can call PQfnumber on the result set to find which
position in the result set belongs to a certain parameter name.

See https://www.postgresql.org/docs/current/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO

>  can you please check once attached two text files.

I looked, and the C code is unreadable.
You seem to be mixing embedded SQL and libpq calls, which you shouldn't.
There is great value in a consistent indentation style.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




Re: facing problem in outparameters in c

From
Mahesh Bodepati
Date:
whatever you said is correct but actually what i want is whenever iam calling the  postgres function by passing input and output parameters  in c ,after execution of postgres function in database side they will  return output paramers .after that when i print the output variable name i need that output parameter value diretcly without differenciating  with column names.



Thanks & Regards,
Mahesh Bodepati
Software Engineer- Engineering
XIUS
INNOVATE . LEAD.





From: Laurenz Albe <laurenz.albe@cybertec.at>
Sent: Wednesday, October 28, 2020 12:29 PM
To: Mahesh Bodepati <mahesh.bodepati@Xius.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: facing problem in outparameters in c
 
On Wed, 2020-10-28 at 04:57 +0000, Mahesh Bodepati wrote:
> Actually i am calling a postgres function by using c language  which  description
>  is defined in database side .when iam calling a postgres function by passing input
>  and output parameters after excution of function in database side i need output
> data in correcsponding  output parameters but iam not getting output like that.

Right; output parameters in a function are columns in the result set.

>  i am getting total output data in response pointer.if iam getting total data
>  in response pointer it is hard to figure out which data  is for which output parameter.

No, that is very simple.  You can call PQfnumber on the result set to find which
position in the result set belongs to a certain parameter name.

See https://www.postgresql.org/docs/current/libpq-exec.html#LIBPQ-EXEC-SELECT-INFO

>  can you please check once attached two text files.

I looked, and the C code is unreadable.
You seem to be mixing embedded SQL and libpq calls, which you shouldn't.
There is great value in a consistent indentation style.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com

Re: facing problem in outparameters in c

From
Matthias Apitz
Date:
El día miércoles, octubre 28, 2020 a las 04:57:12a. m. +0000, Mahesh Bodepati escribió:

> Actually i am calling a postgres function by using c language  which  description is defined in database side .when
iamcalling a postgres function by passing input and output parameters after excution of function in database side i
needoutput  data in correcsponding  output parameters but iam not getting output like that. i am getting total output
datain response pointer.if iam getting total data in response pointer it is hard to figure out which data  is for which
outputparameter. can you please check once attached two text files.
 
> 
> 

I'm hoping that you're not writing C as you write emails, top posted and
all in one single line. You should wrap mail around column 72.

Punchcards are your friend.

    matthias

-- 
Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045
Public GnuPG key: http://www.unixarea.de/key.pub
Без книги нет знания, без знания нет коммунизма (Влaдимир Ильич Ленин)
Without books no knowledge - without knowledge no communism (Vladimir Ilyich Lenin)
Sin libros no hay saber - sin saber no hay comunismo. (Vladimir Ilich Lenin)