pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedfacing problem in outparameters in c
6+ messages / 3 participants
[nested] [flat]
* facing problem in outparameters in c
@ 2020-10-26 10:45 Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-27 14:39 ` Re: facing problem in outparameters in c Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 6+ messages in thread
From: Mahesh Bodepati @ 2020-10-26 10:45 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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.
mahesh.bodepati@xius.com<mailto:battini.subrahmanyam@xius.com>
http://www.xius.com<http://www.xius.com/;
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: facing problem in outparameters in c
2020-10-26 10:45 facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
@ 2020-10-27 14:39 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 04:57 ` Re: facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
0 siblings, 1 reply; 6+ messages in thread
From: Laurenz Albe @ 2020-10-27 14:39 UTC (permalink / raw)
To: Mahesh Bodepati <mahesh.bodepati@Xius.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: facing problem in outparameters in c
2020-10-26 10:45 facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-27 14:39 ` Re: facing problem in outparameters in c Laurenz Albe <laurenz.albe@cybertec.at>
@ 2020-10-28 04:57 ` Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-28 06:59 ` Re: facing problem in outparameters in c Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 10:39 ` Re: facing problem in outparameters in c Matthias Apitz <guru@unixarea.de>
0 siblings, 2 replies; 6+ messages in thread
From: Mahesh Bodepati @ 2020-10-28 04:57 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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.
mahesh.bodepati@xius.com<mailto:battini.subrahmanyam@xius.com>
http://www.xius.com<http://www.xius.com/;
________________________________
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
Attachments:
postgres_db_function.txt (text/plain, 102.1K) download
program.txt (text/plain, 4.1K) download
int isPreferred(int i_message,int msgType, char * i_imsi, char *i_hlr, char *i_vlr, int *o_isAllowed, int *o_nsRelayReason, char *o_relayReason, char *o_planName, char *o_planType, int *o_isKnown, int *o_listPriority, int *o_opCode, int *o_attemptCount, char *prevVLR, int *mapVersion, char *clgPty, int *o_vlrErrCode, int *o_diffVPLMN,char *o_listId,char *o_networkName, int *timerS, int *o_inContext,int *o_hlrErrorCode,int *o_invokeId,PGconn *con)
{
int release = 0;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR po_plantype[1];
VARCHAR po_sl_relay_reason[1];
VARCHAR m_h_imsi[30];
VARCHAR po_prev_vlr[30];
VARCHAR po_clg_address[30];
VARCHAR m_h_hlraddress[30];
VARCHAR m_h_vlraddress[30];
VARCHAR po_planname[31];
VARCHAR po_network_name[31];
VARCHAR po_list_id[10];
//int m_ht_diffVPLMN;
int m_ht_msgType;
int m_ht_message;
int po_opcode;
int allow_yn;
int prefflag;
int po_map_version;
int po_ns_relay_reason;
//int m_ht_isKnown;
int po_list_priority;
int po_attemptcount;
// int m_ht_vlrErrCode;
int po_errorcode;
int po_error_code;
int po_gprs_log;
int po_timer_s_yn;
int po_context_yn;
int po_hlr_error_code;
int po_invoke_id;
char buffer[512];
EXEC SQL END DECLARE SECTION;
printf("entered into ispreffered\n");
m_ht_msgType = msgType;
m_ht_message = i_message;
memset((char *)m_h_imsi.arr,'\0', sizeof((char *)m_h_imsi.arr));
m_h_imsi.len=0;
memset((char *)m_h_hlraddress.arr,'\0', sizeof((char *)m_h_hlraddress.arr));
m_h_hlraddress.len=0;
memset((char *)m_h_vlraddress.arr,'\0', sizeof((char *)m_h_vlraddress.arr));
m_h_vlraddress.len=0;
memset(buffer,'\0',sizeof(buffer));
m_h_imsi.len = strlen(i_imsi);
strcpy((char *)m_h_imsi.arr, i_imsi);
m_h_hlraddress.len = strlen(i_hlr);
strcpy((char *)m_h_hlraddress.arr, i_hlr);
m_h_vlraddress.len = strlen(i_vlr);
strcpy((char *)m_h_vlraddress.arr, i_vlr);
allow_yn = 1;
prefflag = 0;
po_map_version = 0;
po_timer_s_yn = 0;
po_context_yn = 0;
po_ns_relay_reason = 0;
memset((char *)po_prev_vlr.arr,'\0', sizeof((char *)po_prev_vlr.arr));
po_prev_vlr.len=0;
memset((char *)po_clg_address.arr,'\0', sizeof((char *)po_clg_address.arr));
po_clg_address.len=0;
po_sl_relay_reason.len = 0;
memset((char *)po_sl_relay_reason.arr, '\0', sizeof((char *)po_sl_relay_reason.arr));
po_plantype.len = 0;
memset((char *)po_plantype.arr, '\0', sizeof((char *)po_plantype.arr));
po_planname.len = 0;
memset((char *)po_planname.arr, '\0', sizeof((char *)po_planname.arr));
po_network_name.len = 0;
memset((char *)po_network_name.arr, '\0', sizeof((char *)po_network_name.arr));
po_list_id.len = 0;
memset((char *)po_list_id.arr, '\0', sizeof((char *)po_list_id.arr));
po_list_priority = 0;
po_attemptcount = 0;
po_error_code = 0;
po_errorcode = 0;
po_hlr_error_code =0;
po_invoke_id =0;
*mapVersion = 0;
*timerS = 0;
*o_inContext = 0;
PGresult *res = PQexec(con, "BEGIN");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(con));
PQclear(res);
PQfinish(con);
exit(1);
}
PQclear(res);
//allow_yn,po_ns_relay_reason,po_sl_relay_reason=======these are output paraneters (total 21 output parameters are there but checking purpose iam passing only 3 parameters)
printf("imsi==%s\tvlr==%s\thlr==%s\tmessahe===%d\tmsg_type==%d\n",m_h_imsi.arr,m_h_vlraddress.arr,m_h_hlraddress.arr,m_ht_message,m_ht_msgType);
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);
}
PQclear(res);
res = PQexec(con, "END");
PQclear(res);
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: facing problem in outparameters in c
2020-10-26 10:45 facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-27 14:39 ` Re: facing problem in outparameters in c Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 04:57 ` Re: facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
@ 2020-10-28 06:59 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 10:05 ` Re: facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
1 sibling, 1 reply; 6+ messages in thread
From: Laurenz Albe @ 2020-10-28 06:59 UTC (permalink / raw)
To: Mahesh Bodepati <mahesh.bodepati@Xius.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: facing problem in outparameters in c
2020-10-26 10:45 facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-27 14:39 ` Re: facing problem in outparameters in c Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 04:57 ` Re: facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-28 06:59 ` Re: facing problem in outparameters in c Laurenz Albe <laurenz.albe@cybertec.at>
@ 2020-10-28 10:05 ` Mahesh Bodepati <mahesh.bodepati@Xius.com>
0 siblings, 0 replies; 6+ messages in thread
From: Mahesh Bodepati @ 2020-10-28 10:05 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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.
mahesh.bodepati@xius.com<mailto:battini.subrahmanyam@xius.com>
http://www.xius.com<http://www.xius.com/;
________________________________
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: facing problem in outparameters in c
2020-10-26 10:45 facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-27 14:39 ` Re: facing problem in outparameters in c Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 04:57 ` Re: facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
@ 2020-10-28 10:39 ` Matthias Apitz <guru@unixarea.de>
1 sibling, 0 replies; 6+ messages in thread
From: Matthias Apitz @ 2020-10-28 10:39 UTC (permalink / raw)
To: Mahesh Bodepati <mahesh.bodepati@Xius.com>; +Cc: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
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 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.
>
>
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)
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2020-10-28 10:39 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 10:45 facing problem in outparameters in c Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-27 14:39 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 04:57 ` Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-28 06:59 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-10-28 10:05 ` Mahesh Bodepati <mahesh.bodepati@Xius.com>
2020-10-28 10:39 ` Matthias Apitz <guru@unixarea.de>
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