Re: [GENERAL] numeric data type

2015-09-23 Thread Juan Pablo L .
Alvaro, thank you, that worked. > Date: Tue, 22 Sep 2015 18:57:38 -0300 > From: alvhe...@2ndquadrant.com > To: jpablolorenze...@hotmail.com > CC: t...@sss.pgh.pa.us; pgsql-general@postgresql.org > Subject: Re: [GENERAL] numeric data type > > Juan Pablo L. wrote: >

[GENERAL] numeric data type

2015-09-22 Thread Juan Pablo L .
Hi, i m writing a C module (extension), the procedure has a parameter that is of type numeric, inside the function i can not read the parameter or so it seems, this what is do: float8 db_balance,in_chgval; in_chgval = PG_GETARG_FLOAT8(2); elog(INFO,"in_chgval = %0.2f",in_chgval); The above

Re: [GENERAL] numeric data type

2015-09-22 Thread Juan Pablo L .
m > CC: t...@sss.pgh.pa.us; pgsql-general@postgresql.org > Subject: Re: [GENERAL] numeric data type > > Juan Pablo L. wrote: > > thank you for your answer, the function is declared as: > > > > FUNCTION wtt_discount_account(IN in_phonenumber varchar(20),IN in_balanceid > > i

Re: [GENERAL] numeric data type

2015-09-22 Thread Juan Pablo L .
16:07:36 -0400 > > "Juan Pablo L." <jpablolorenze...@hotmail.com> writes: > > Hi, i m writing a C module (extension), the procedure has a parameter that > > is of type numeric, > > inside the function i can not read the parameter or so it seems, t

[GENERAL] numeric

2015-09-19 Thread Juan Pablo L .
Hi, i m writing a C module (extension), the procedure has a parameter that is of type numeric, inside the function i can not read the parameter or so it seems, this what is do: float8 db_balance,in_chgval; in_chgval = PG_GETARG_FLOAT8(2); elog(INFO,"in_chgval = %0.2f",in_chgval); The above

[GENERAL] rollback in function

2015-02-23 Thread Juan Pablo L .
Hello, i have created a function (in C) that receives an array that contains tuples of ID's and values. The function is to execute updates on each ID assigning the value, but if one of these operation fails (does not meet certain criteria) inside the function i would like to rollback and

Re: [GENERAL] rollback in C functions

2015-02-20 Thread Juan Pablo L
:42, Juan Pablo L jpablolorenze...@gmail.com wrote: i tried this but the call to PQresultErrorField(PGresult, PG_DIAG_SQLSTATE) is returning NULL, this is what trigger the exception in the function code: ereport(ERROR,(errcode(ERRCODE_SQL_ROUTINE_EXCEPTION),errmsg(Plan with id %s does

[GENERAL] rollback in C functions

2015-02-19 Thread Juan Pablo L
Hello, i have created a function (in C) that receives an array that contains tuples of ID's and values. The function is to execute updates on each ID assigning the value, but if one of these operation fails (does not meet certain criteria) inside the function i would like to rollback and leave

Re: [GENERAL] rollback in C functions

2015-02-19 Thread Juan Pablo L
Hi Thanks Chris, yes i have already tested ereport and even made up my own sql state to report and error but from the application i can not access this error code directly (through the PQexec,PQresultErrorField,etc functions because the PGresult returns NULL) but i have to register a callback

Re: [GENERAL] rollback in C functions

2015-02-19 Thread Juan Pablo L
Thank you Alvaro, i m afraid ereport seems to be the way, that it is complicated to catch this error code in the code of the caller. cause you have to use a callback etc etc On 19 February 2015 at 15:57, Alvaro Herrera alvhe...@2ndquadrant.com wrote: Juan Pablo L wrote: Hi, i want previous

Re: [GENERAL] rollback in C functions

2015-02-19 Thread Juan Pablo L
Hi, i want previous updates to rollback ... like nothing happened (a normal begin/rollback behaviour) On 19 February 2015 at 15:34, Alvaro Herrera alvhe...@2ndquadrant.com wrote: Juan Pablo L wrote: Hello, i have created a function (in C) that receives an array that contains tuples of ID's

Re: [GENERAL] rollback in C functions

2015-02-19 Thread Juan Pablo L
Thank you, i will try this, honestly i was checking if PGResult is NULL, when i trigger the exception i always get NULL so i did not any further but i will try this . On 19 February 2015 at 16:22, John R Pierce pie...@hogranch.com wrote: On 2/19/2015 2:02 PM, Juan Pablo L wrote: Thank you

Re: [GENERAL] rollback in C functions

2015-02-19 Thread Juan Pablo L
something wrong ? thanks! On 19 February 2015 at 16:27, Juan Pablo L jpablolorenze...@gmail.com wrote: Thank you, i will try this, honestly i was checking if PGResult is NULL, when i trigger the exception i always get NULL so i did not any further but i will try this . On 19 February 2015

Re: [GENERAL] array in a store procedure in C

2015-02-02 Thread Juan Pablo L
Thanks. On Feb 2, 2015 8:58 PM, Jim Nasby jim.na...@bluetreble.com wrote: On 1/29/15 10:53 PM, Juan Pablo L wrote: i will look there ... i have been looking in a lot of source files and can not find anything that helps but i will look in those specific files. Thanks a lot. You might find

[GENERAL] array in a store procedure in C

2015-01-29 Thread Juan Pablo L
Hi, i m developing a store procedure that accepts an array of rows, this is the simplified code: http://pastebin.com/wC92Dh7f Please note that i left out everything that is not related, in the function, to the problem at hand, only the code related to my problem is included. The above does

Re: [GENERAL] array in a store procedure in C

2015-01-29 Thread Juan Pablo L
i will look there ... i have been looking in a lot of source files and can not find anything that helps but i will look in those specific files. Thanks a lot. On Jan 29, 2015 9:09 PM, Michael Paquier michael.paqu...@gmail.com wrote: On Thu, Jan 29, 2015 at 11:45 PM, Juan Pablo L jpablolorenze

[GENERAL] help replacing expresion in plpgsql

2013-12-17 Thread Juan Pablo L
Hi, i have a function that receives a parameter which represents days: FUNCTION aaa_recharge_account(expdays integer) i want to add those days to the CURRENT_DATE, but i do not know how to do it, i have tried several ways to replace that in an expresion like: newexpdate := CURRENT_TIMESTAMP +

[GENERAL] replacing expresion in plpgsql

2013-12-15 Thread Juan Pablo L
Hi, i have a function that receives a parameter which represents days: FUNCTION aaa_recharge_account(expdays integer) i want to add those days to the CURRENT_DATE, but i do not know how to do it, i have tried several ways to replace that in an expresion like: newexpdate := CURRENT_TIMESTAMP +

Re: [GENERAL] replacing expresion in plpgsql

2013-12-15 Thread Juan Pablo L
Hi i m working with timestamp cause i need the time too. i tried your solution and it works perfectly, it just does not adjust to my problem. thanks a lot for the answer. On 15 December 2013 18:17, Andreas Brandl m...@3.141592654.de wrote: Hi, - Ursprüngliche Mail - Hi, i have a

Re: [GENERAL] replacing expresion in plpgsql

2013-12-15 Thread Juan Pablo L
Hi, thank you very much, this worked flawlessly, this is the final code: execute 'select CURRENT_TIMESTAMP + $1 * interval ''1 day''' into newexpdate using expdays; works perfect, thanks a ton! On 15 December 2013 18:23, John R Pierce pie...@hogranch.com wrote: On 12/15/2013 4:17 PM, Andreas

Re: [GENERAL] replacing expresion in plpgsql

2013-12-15 Thread Juan Pablo L
thank you very much for clarifying . On 15 December 2013 19:02, Andreas Brandl m...@3.141592654.de wrote: John, - Ursprüngliche Mail - On 12/15/2013 4:17 PM, Andreas Brandl wrote: select current_timestamp, current_timestamp + interval '2' day; that should be interval '2