Re: [GENERAL] plpgsql function with offset - Postgres 9.1

2017-06-15 Thread Peter J. Holzer
On 2017-06-16 10:19:45 +1200, Patrick B wrote: > 2017-05-29 19:27 GMT+12:00 Albe Laurenz : > Patrick B wrote: > > I am running a background task on my DB, which will copy data from > tableA > to tableB. For > > that, I'm writing a PL/PGSQL function which basically needs to do the >

Re: [GENERAL] plpgsql function with offset - Postgres 9.1

2017-06-15 Thread David G. Johnston
On Thu, Jun 15, 2017 at 3:49 PM, Patrick B wrote: > 2017-06-16 10:35 GMT+12:00 David G. Johnston : > >> On Thu, Jun 15, 2017 at 3:19 PM, Patrick B >> wrote: >> >>> 2017-05-29 19:27 GMT+12:00 Albe Laurenz : >>> Patrick B wrote: > I am running a background task on my DB, which will copy

Re: [GENERAL] plpgsql function with offset - Postgres 9.1

2017-06-15 Thread Patrick B
2017-06-16 10:35 GMT+12:00 David G. Johnston : > On Thu, Jun 15, 2017 at 3:19 PM, Patrick B > wrote: > >> 2017-05-29 19:27 GMT+12:00 Albe Laurenz : >> >>> Patrick B wrote: >>> > I am running a background task on my DB, which will copy data from >>> tableA to tableB. For >>> > that, I'm writing a

Re: [GENERAL] plpgsql function with offset - Postgres 9.1

2017-06-15 Thread David G. Johnston
On Thu, Jun 15, 2017 at 3:19 PM, Patrick B wrote: > 2017-05-29 19:27 GMT+12:00 Albe Laurenz : > >> Patrick B wrote: >> > I am running a background task on my DB, which will copy data from >> tableA to tableB. For >> > that, I'm writing a PL/PGSQL function which basically needs to do the >> follow

Re: [GENERAL] plpgsql function with offset - Postgres 9.1

2017-06-15 Thread Patrick B
2017-05-29 19:27 GMT+12:00 Albe Laurenz : > Patrick B wrote: > > I am running a background task on my DB, which will copy data from > tableA to tableB. For > > that, I'm writing a PL/PGSQL function which basically needs to do the > following: > > > > > > 1.Select the data from tableA > > 2.

Re: [GENERAL] plpgsql function with offset - Postgres 9.1

2017-05-29 Thread Albe Laurenz
Patrick B wrote: > I am running a background task on my DB, which will copy data from tableA to > tableB. For > that, I'm writing a PL/PGSQL function which basically needs to do the > following: > > > 1.Select the data from tableA > 2.The limit will be put when calling the function > 3.

[GENERAL] plpgsql function with offset - Postgres 9.1

2017-05-28 Thread Patrick B
Hi guys, I am running a background task on my DB, which will copy data from tableA to tableB. For that, I'm writing a PL/PGSQL function which basically needs to do the following: 1. Select the data from tableA 2. The limit will be put when calling the function 3. insert the selected dat

Re: [GENERAL] plpgsql function to insert or update problem

2012-03-24 Thread Andy Colson
On 03/24/2012 05:23 AM, Alban Hertroys wrote: On 23 Mar 2012, at 19:49, Andy Colson wrote: Anyway, the problem. I get a lot of DB Error messages: DB Error: ERROR: duplicate key value violates unique constraint "by_ip_pk" DETAIL: Key (ip, sessid, "time")=(97.64.237.59, 2qggi9gcdkcaoecqg3arvo1

Re: [GENERAL] plpgsql function to insert or update problem

2012-03-24 Thread Alban Hertroys
On 23 Mar 2012, at 19:49, Andy Colson wrote: > Anyway, the problem. I get a lot of DB Error messages: > DB Error: ERROR: duplicate key value violates unique constraint "by_ip_pk" > DETAIL: Key (ip, sessid, "time")=(97.64.237.59, 2qggi9gcdkcaoecqg3arvo1gu7, > 2012-03-23 13:00:00) already exists

[GENERAL] plpgsql function to insert or update problem

2012-03-23 Thread Andy Colson
Hi all, I am inserting apache log into into a database. Seem to have a little problem with this function: create or replace function insert_webstat( ivhost text, iip inet, isessid text, ihittime timestamp, iurl text, istatus integer, isi

Re: [GENERAL] plpgsql function confusing behaviour

2011-07-13 Thread Merlin Moncure
On Tue, Jul 12, 2011 at 12:10 PM, Shianmiin wrote: > > Merlin Moncure-2 wrote: >> >> One proposed solution is to cache plpgsql plans around the search path. >> > > I like the proposed solution, since search_path plays a part when generating > plpgsql plan, it make sense to be part of the cache. >

Re: [GENERAL] plpgsql function confusing behaviour

2011-07-13 Thread Shianmiin
Merlin Moncure-2 wrote: > > One proposed solution is to cache plpgsql plans around the search path. > I like the proposed solution, since search_path plays a part when generating plpgsql plan, it make sense to be part of the cache. Merlin Moncure-2 wrote: > > *) use sql functions for porti

Re: [GENERAL] plpgsql function confusing behaviour

2011-07-12 Thread Merlin Moncure
On Mon, Jul 11, 2011 at 3:23 PM, Shianmiin wrote: > We have recently gone thru an unexpected behavior of PostgreSQL function > written in plpgsql. > I wonder if anyone can help explain the ideas behind the design. > > Test scenario: > 1. create two identical schemas, let's call them tenant1 and te

[GENERAL] plpgsql function confusing behaviour

2011-07-12 Thread Shianmiin
We have recently gone thru an unexpected behavior of PostgreSQL function written in plpgsql. I wonder if anyone can help explain the ideas behind the design. Test scenario: 1. create two identical schemas, let's call them tenant1 and tenant2 -- set up tenant1 create schema tenant1; set search_pat

Re: [GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-09 Thread Clemens Schwaighofer
2011/6/9 Tom Lane : > Merlin Moncure writes: >> On Thu, Jun 9, 2011 at 4:46 AM, Craig Ringer >> wrote: >>> (as far as I know) It's not possible for a function to see data committed by >>> other transactions since that function began executing, whether or not those >>> other transactions have comm

Re: [GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-09 Thread Tom Lane
Merlin Moncure writes: > On Thu, Jun 9, 2011 at 4:46 AM, Craig Ringer > wrote: >> (as far as I know) It's not possible for a function to see data committed by >> other transactions since that function began executing, whether or not those >> other transactions have committed. > This is not corre

Re: [GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-09 Thread Merlin Moncure
On Thu, Jun 9, 2011 at 4:46 AM, Craig Ringer wrote: > On 9/06/2011 2:41 PM, Clemens Schwaighofer wrote: >> >> Hi, >> >> I have a plpgsql function where I read data from a table in a loop and >> update data in a different table. >> >> Is it possible to see the updated data from a different access d

Re: [GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-09 Thread Clemens Schwaighofer
2011/6/9 Craig Ringer : > On 9/06/2011 2:41 PM, Clemens Schwaighofer wrote: >> >> Hi, >> >> I have a plpgsql function where I read data from a table in a loop and >> update data in a different table. >> >> Is it possible to see the updated data from a different access during >> the run of this func

Re: [GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-09 Thread Craig Ringer
On 9/06/2011 2:41 PM, Clemens Schwaighofer wrote: Hi, I have a plpgsql function where I read data from a table in a loop and update data in a different table. Is it possible to see the updated data from a different access during the run of this function? Or is this impossible because the functi

Re: [GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-09 Thread Clemens Schwaighofer
I can try this, but I have never done anything with plperl yet. 2011/6/9 pasman pasmański : > If you rewrite your function in plperlu , you can store data in shared memory. > > 2011/6/9, Clemens Schwaighofer : >> Hi, >> >> I have a plpgsql function where I read data from a table in a loop and >> u

Re: [GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-09 Thread pasman pasmański
If you rewrite your function in plperlu , you can store data in shared memory. 2011/6/9, Clemens Schwaighofer : > Hi, > > I have a plpgsql function where I read data from a table in a loop and > update data in a different table. > > Is it possible to see the updated data from a different access du

[GENERAL] plpgsql function with update and seeing changed data from outside during run

2011-06-08 Thread Clemens Schwaighofer
Hi, I have a plpgsql function where I read data from a table in a loop and update data in a different table. Is it possible to see the updated data from a different access during the run of this function? Or is this impossible because the function is a "transaction" and no data change is visible

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-05 Thread C. Bensend
> By making this function sql and immutable, you give the database more > ability to inline it into queries which can make a tremendous > performance difference in some cases. You can also index based on it > which can be useful. Very nice, Merlin. These aren't really a concern in my case as I'

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-05 Thread Merlin Moncure
On Mon, Apr 4, 2011 at 7:12 PM, C. Bensend wrote: > > Hey folks, > >   So, I'm working on a little application to help me with my > budget.  Yeah, there are apps out there to do it, but I'm having > a good time learning some more too.  :) > >   I get paid every other Friday.  I thought, for schedu

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread C. Bensend
> generate_series(date '2001-01-05', date '2020-12-31', interval '2 weeks') > > > will return every payday from jan 5 2001 to the end of 2020 (assuming > the 5th was payday, change the start to jan 12 if that was instead). And THERE is the winner. I feel like an idiot for not even considering ge

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread C. Bensend
> Not sure if your needs are like mine, but here is the function I use. It > stores the date in a config table, and rolls it forward when needed. It > also calculates it from some "know payroll date", which I'm guessing was > near when I wrote it? (I'm not sure why I choose Nov 16 2008.) for m

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread C. Bensend
> It is a very simplistic approach since you do not take into account > holidays. But if it meets your needs what you want is the modulo operator > ( > "%"; "mod(x,y)" is the equivalent function ) which performs division but > returns only the remainder. > > N % 14 = [a number between 0 and (14 -

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread John R Pierce
generate_series(date '2001-01-05', date '2020-12-31', interval '2 weeks') will return every payday from jan 5 2001 to the end of 2020 (assuming the 5th was payday, change the start to jan 12 if that was instead). -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread Andy Colson
On 04/04/2011 07:12 PM, C. Bensend wrote: Hey folks, So, I'm working on a little application to help me with my budget. Yeah, there are apps out there to do it, but I'm having a good time learning some more too. :) I get paid every other Friday. I thought, for scheduling purposes in

Re: [GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread David Johnston
nd Sent: Monday, April 04, 2011 8:12 PM To: pgsql-general@postgresql.org Subject: [GENERAL] Plpgsql function to compute "every other Friday" Hey folks, So, I'm working on a little application to help me with my budget. Yeah, there are apps out there to do it, but I

[GENERAL] Plpgsql function to compute "every other Friday"

2011-04-04 Thread C. Bensend
Hey folks, So, I'm working on a little application to help me with my budget. Yeah, there are apps out there to do it, but I'm having a good time learning some more too. :) I get paid every other Friday. I thought, for scheduling purposes in this app, that I would take a stab at writing

Re: [GENERAL] PLPGSQL function to search function source for a list of terms

2010-09-17 Thread bricklen
On Fri, Sep 17, 2010 at 10:17 AM, bricklen wrote: > On Fri, Sep 17, 2010 at 10:16 AM, Raymond O'Donnell wrote: >> On 17/09/2010 18:12, bricklen wrote: >>> >>> On Fri, Sep 17, 2010 at 9:57 AM, Raymond O'Donnell  wrote: That could be pretty useful - why don't you put it on the wiki?

Re: [GENERAL] PLPGSQL function to search function source for a list of terms

2010-09-17 Thread bricklen
On Fri, Sep 17, 2010 at 10:16 AM, Raymond O'Donnell wrote: > On 17/09/2010 18:12, bricklen wrote: >> >> On Fri, Sep 17, 2010 at 9:57 AM, Raymond O'Donnell  wrote: >>> >>> That could be pretty useful - why don't you put it on the wiki? >>> >>> Ray. >>> >> I was going to put an entry at >> http://wi

Re: [GENERAL] PLPGSQL function to search function source for a list of terms

2010-09-17 Thread Raymond O'Donnell
On 17/09/2010 18:12, bricklen wrote: On Fri, Sep 17, 2010 at 9:57 AM, Raymond O'Donnell wrote: That could be pretty useful - why don't you put it on the wiki? Ray. I was going to put an entry at http://wiki.postgresql.org/wiki/Category:Library_Snippets, but I couldn't find the "edit" option.

Re: [GENERAL] PLPGSQL function to search function source for a list of terms

2010-09-17 Thread bricklen
On Fri, Sep 17, 2010 at 9:57 AM, Raymond O'Donnell wrote: > That could be pretty useful - why don't you put it on the wiki? > > Ray. > I was going to put an entry at http://wiki.postgresql.org/wiki/Category:Library_Snippets, but I couldn't find the "edit" option. Maybe I'm blind? I just noticed h

Re: [GENERAL] PLPGSQL function to search function source for a list of terms

2010-09-17 Thread Raymond O'Donnell
On 17/09/2010 17:37, bricklen wrote: Here is a plpsql function I put together to search db functions in schemas other than pg_catalog and information_schema. Not the greatest of coding, but it might help someone else trying to solve the same issue I was having: to search all public functions for

[GENERAL] PLPGSQL function to search function source for a list of terms

2010-09-17 Thread bricklen
Here is a plpsql function I put together to search db functions in schemas other than pg_catalog and information_schema. Not the greatest of coding, but it might help someone else trying to solve the same issue I was having: to search all public functions for a list of terms. Sample usage is below

Re: [GENERAL] Plpgsql function syntax error at first coalesce statement

2010-04-25 Thread Tom Lane
Jeff Ross writes: > On 04/25/10 14:20, Tom Lane wrote: >> Uh, you're using that as the destination for the FOR loop's SELECT. >> What exactly is the purpose of having a second SELECT within the loop? > How else do I get the results I want--name, address, city, state, and so > on through the list

Re: [GENERAL] Plpgsql function syntax error at first coalesce statement

2010-04-25 Thread Jeff Ross
On 04/25/10 14:20, Tom Lane wrote: Jeff Ross writes: Now I'm *really* confused. I thought the table structure I created at the beginning of the function was where the results would be returned to. Uh, you're using that as the destination for the FOR loop's SELECT. What exactly is the purpose

Re: [GENERAL] Plpgsql function syntax error at first coalesce statement

2010-04-25 Thread Tom Lane
Jeff Ross writes: > Now I'm *really* confused. I thought the table structure I created at > the beginning of the function was where the results would be returned > to. Uh, you're using that as the destination for the FOR loop's SELECT. What exactly is the purpose of having a second SELECT with

Re: [GENERAL] Plpgsql function syntax error at first coalesce statement

2010-04-25 Thread Raymond O'Donnell
On 25/04/2010 20:50, Jeff Ross wrote: > Now I'm *really* confused. I thought the table structure I created at > the beginning of the function was where the results would be returned > to. I tried a variety of queries including select into and create table > but they didn't work either. I think

Re: [GENERAL] Plpgsql function syntax error at first coalesce statement

2010-04-25 Thread Jeff Ross
On 04/25/10 12:32, Tom Lane wrote: Jeff Ross writes: I'm trying to write my first plpgsql function and I'm running into a problem that may or may not have to do with a coalesce statement. No, it's not the coalesce ... When I try to run this I get the following error: jr...@acer:/var/www/

Re: [GENERAL] Plpgsql function syntax error at first coalesce statement

2010-04-25 Thread Tom Lane
Jeff Ross writes: > I'm trying to write my first plpgsql function and I'm running into a > problem that may or may not have to do with a coalesce statement. No, it's not the coalesce ... > When I try to run this I get the following error: > jr...@acer:/var/www/stars/sql $ psql -f view_all_trai

[GENERAL] Plpgsql function syntax error at first coalesce statement

2010-04-25 Thread Jeff Ross
Hi all, I'm trying to write my first plpgsql function and I'm running into a problem that may or may not have to do with a coalesce statement. I wrote a very similar sql function that does basically the same thing for just one trainer where I pass in an id number and that one works fine. I

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-17 Thread Pavel Stehule
2009/8/17 David Fetter : > On Mon, Aug 17, 2009 at 07:50:14AM +0200, Pavel Stehule wrote: >> 2009/8/17 David Fetter : >> > On Mon, Aug 17, 2009 at 06:43:54AM +0200, Pavel Stehule wrote: >> >> Hello >> >> >> >> 2009/8/16 Andre Lopes : >> >> > Hi, >> >> > >> >> > I need a plpgsql function to validade

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-17 Thread Peter Eisentraut
On Sun, 2009-08-16 at 21:10 +0100, Andre Lopes wrote: > I need a plpgsql function to validade e-mail addresses. I have google > but I can't find any. > > My question: Anyone have a function to validate e-mails? I recommend something based on the following recipe in PL/Perl. http://wiki.postgres

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread David Fetter
On Mon, Aug 17, 2009 at 07:50:14AM +0200, Pavel Stehule wrote: > 2009/8/17 David Fetter : > > On Mon, Aug 17, 2009 at 06:43:54AM +0200, Pavel Stehule wrote: > >> Hello > >> > >> 2009/8/16 Andre Lopes : > >> > Hi, > >> > > >> > I need a plpgsql function to validade e-mail addresses. I have google >

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Pavel Stehule
2009/8/17 David Fetter : > On Mon, Aug 17, 2009 at 06:43:54AM +0200, Pavel Stehule wrote: >> Hello >> >> 2009/8/16 Andre Lopes : >> > Hi, >> > >> > I need a plpgsql function to validade e-mail addresses. I have google but I >> > can't find any. >> > >> > My question: Anyone have a function to valid

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread David Fetter
On Mon, Aug 17, 2009 at 06:43:54AM +0200, Pavel Stehule wrote: > Hello > > 2009/8/16 Andre Lopes : > > Hi, > > > > I need a plpgsql function to validade e-mail addresses. I have google but I > > can't find any. > > > > My question: Anyone have a function to validate e-mails? > > > > Best Regards,

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Pavel Stehule
Hello 2009/8/16 Andre Lopes : > Hi, > > I need a plpgsql function to validade e-mail addresses. I have google but I > can't find any. > > My question: Anyone have a function to validate e-mails? > > Best Regards, > André. > You don't need plpgsql. Important is only an using of regular expression.

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Lew
Tom Lane wrote: Andre Lopes writes: My question: Anyone have a function to validate e-mails? Check the PG archives --- this has been discussed before. IIRC you can't *really* validate them, short of actually sending mail. And getting a reply. But there are partial solutions in the archiv

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Tom Lane
Andre Lopes writes: > My question: Anyone have a function to validate e-mails? Check the PG archives --- this has been discussed before. IIRC you can't *really* validate them, short of actually sending mail. But there are partial solutions in the archives. regards, tom l

Re: [GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Raymond O'Donnell
On 16/08/2009 21:10, Andre Lopes wrote: > I need a plpgsql function to validade e-mail addresses. I have google > but I can't find any. > > My question: Anyone have a function to validate e-mails? There are lots of regular expressions which Google will find for you, which you can then use with on

[GENERAL] plpgsql function to validate e-mail

2009-08-16 Thread Andre Lopes
Hi, I need a plpgsql function to validade e-mail addresses. I have google but I can't find any. My question: Anyone have a function to validate e-mails? Best Regards, André.

Re: [GENERAL] plpgsql function

2008-02-24 Thread Tom Lane
Andreas Kendlinger <[EMAIL PROTECTED]> writes: > I wrote a little stored function to simulate the EXTRACT(YEAR_MONTH ...) > from mySQL. > ... > One Method call requires 53ms. Really? Near as I can tell, it takes about 130 microsec on my ancient HPPA machine, which is surely as slow as anything a

[GENERAL] plpgsql function

2008-02-24 Thread Andreas Kendlinger
Hello. I wrote a little stored function to simulate the EXTRACT(YEAR_MONTH ...) from mySQL. //- CREATE OR REPLACE FUNCTION "BiSCAT_combined".extractyearmonth(date timestamp without time zone) RETURNS character varying AS $BODY$ DECLARE i INTEGER; BE

Re: [GENERAL] Plpgsql function to join array elements with a string

2007-09-24 Thread Bastien Continsouzas
=== PROBLEM SOLVED === I found for what I was looking http://www.postgresql.org/docs/8.0/static/functions-array.html Function : array_to_string (anyarray, text) Return type : text Description : concatenates array elements using provided delimiter Example : array_to_string(array[1, 2, 3], '~^~') R

Re: [GENERAL] Plpgsql function and variable substitute

2007-05-16 Thread Alban Hertroys
Jiří Němec wrote: > SET expiretime = expiretime + interval 'lifetime days' > SET expiretime = expiretime + interval || lifetime || 'days' SET expiretime = expiretime + lifetime * interval '1 day' -- Alban Hertroys [EMAIL PROTECTED] magproductions b.v. T: ++31(0)534346874 F: ++31(0)534346876 M:

Re: [GENERAL] Plpgsql function and variable substitute

2007-05-16 Thread A. Kretschmer
am Wed, dem 16.05.2007, um 15:11:17 +0200 mailte Ji?í N?mec folgendes: > Hello, > > I have searched the Internet for an answer but nothing works for me. > > There is a plpgsql function which is used in a trigger. I need to > substitute a value "7" for "lifetime" (integer) SELECTed in a previous

[GENERAL] Plpgsql function and variable substitute

2007-05-16 Thread Jiří Němec
Hello, I have searched the Internet for an answer but nothing works for me. There is a plpgsql function which is used in a trigger. I need to substitute a value "7" for "lifetime" (integer) SELECTed in a previous query. DECLARE lifetime integer; BEGIN SELECT foo INTO lifetime FROM tblnam

Re: [GENERAL] PLPGSQL function schema or table parameter

2005-09-05 Thread A. Kretschmer
am 05.09.2005, um 14:26:31 -0300 mailte Sidnei de Souza folgendes: > Is it possible to pass a table name and/or schema name to a plpgsql > function? Yes. > How can I use them in the code? Which Types to use for each of the > parameters? varchar. > > E.g. > > create or replace function MyTe

[GENERAL] PLPGSQL function schema or table parameter

2005-09-05 Thread Sidnei de Souza
Is it possible to pass a table name and/or schema name to a plpgsql function? How can I use them in the code? Which Types to use for each of the parameters? E.g. create or replace function MyTest (mySchema WhichType?, myTable WhichType?) returns integer as ' declare result integer; Begin

Re: [GENERAL] plpgsql function changes?

2005-06-25 Thread Tom Lane
David Lazar <[EMAIL PROTECTED]> writes: > ERROR: RETURN cannot have a parameter in function returning set; use > RETURN NEXT at or near "pkg" at character 1149 > Did something change from pgsql 7.X series set returning function to > version 8.X series??? I think 8.0 actually complains that you

[GENERAL] plpgsql function changes?

2005-06-25 Thread David Lazar
Hi, I run a function that returns a setof custom type rows against pgsql 7.4.6 and it works great. The same type and function was migrated to pgsql 8.0.3 but fails to run, returning an error: ERROR: RETURN cannot have a parameter in function returning set; use RETURN NEXT at or near "pkg" at

Re: [GENERAL] plpgsql function not working

2005-04-25 Thread John DeSoi
On Apr 25, 2005, at 4:07 PM, Ruff, Jeffry C. SR. wrote: Thanks for the reply. After making the change I now get the following ERROR: unterminated string CONTEXT: compile of PL/pgSQL function "group_list" near line 6 Ok make that string text := ; I'm now spoiled with dollar quoting :) John DeS

Re: [GENERAL] plpgsql function not working

2005-04-25 Thread Michael Fuhr
On Mon, Apr 25, 2005 at 02:40:29PM -0500, Ruff, Jeffry C. SR. wrote: > > CREATE FUNCTION userinfo.group_list(text) RETURNS text AS' >DECLARE > rec RECORD; > string text := NULL; >BEGIN > FOR rec IN SELECT * FROM userinfo.userdb_groups WHERE username = $1 LOOP >

Re: [GENERAL] plpgsql function not working

2005-04-25 Thread John DeSoi
On Apr 25, 2005, at 3:40 PM, Ruff, Jeffry C. SR. wrote: I found this function on line [Thanks to Jeff Eckermann and Juerg Rietmann] that takes the results of a query and creates a comma delimited  string. However when I run it I get no values. Any help would be appreciated. I apologize if this i

[GENERAL] plpgsql function not working

2005-04-25 Thread Ruff, Jeffry C. SR.
Title: plpgsql function not working I found this function on line [Thanks to Jeff Eckermann and Juerg Rietmann] that takes the results of a query and creates a comma delimited  string. However when I run it I get no values. Any help would be appreciated. I apologize if this is the wrong forum

Re: [GENERAL] Plpgsql function with unknown number of args

2005-04-18 Thread Tony Caduto
You don't have to cast it as anything, just return a refcursor from your function. Say you return a refcursor called return_cursor select myfunction(your_in_array); fetch all from return_cursor; If you are calling from a development environment, you put the return value of the fuction (the refcu

Re: [GENERAL] Plpgsql function with unknown number of args

2005-04-18 Thread Tom Lane
"Relyea, Mike" <[EMAIL PROTECTED]> writes: > Thanks for the input. This looks very promising. I have one further > question. My SQL statement is going to pull data from more than one > table in a relatively complex query. How do I cast the RETURNS portion > of the function? In current releases

Re: [GENERAL] Plpgsql function with unknown number of args

2005-04-18 Thread Relyea, Mike
) INNER JOIN "tblBlockAC" ON "Targets"."TargetID" = "tblBlockAC"."TargetID" WHERE (("PrintSamples"."MachineID" = '2167' OR "PrintSamples"."MachineID" = '2168' OR "PrintSample

Re: [GENERAL] Plpgsql function with unknown number of args

2005-04-18 Thread Tony Caduto
you coud pass in criteria as a delimted string, then pull out each arg something like this CREATE or REPLACE FUNCTION test_func( varchar) RETURNS pg_catalog.void AS $BODY$ DECLARE IN_ARRAY text[] ; arg1 varchar; arg2 varchar; arg3 varchar begin IN_ARRAY = string_to_array($1,'~^~'); arg1= IN_ARR

Re: [GENERAL] Plpgsql function with unknown number of args

2005-04-18 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Relyea, Mike" <[EMAIL PROTECTED]> writes: > I need to create my very first function. I'm using 8.0.2 and I need a > function that I can call (from my client app) with an unknown number of > criteria for a select query. The function will then return the results >

[GENERAL] Plpgsql function with unknown number of args

2005-04-18 Thread Relyea, Mike
I need to create my very first function. I'm using 8.0.2 and I need a function that I can call (from my client app) with an unknown number of criteria for a select query. The function will then return the results of the query. In my mind, it would go something like what I've outlined below. I r

[GENERAL] plpgsql function with RETURNS SETOF refcursor AS. How to get it work via JDBC

2005-03-24 Thread David Gagnon
Hi all, I'm already able to get Refcursor from a stored procedure. But now I need to get a SETOF refcursor and I can't make it work... Is that possible to do this via JDBC? He is the code I did. The rsTmp.next() throws a Connection is closed. Operation is not permitted. Exception. pu

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Juan Casero (FL FLC)
-Original Message- From: Martijn van Oosterhout [mailto:[EMAIL PROTECTED] Sent: Friday, February 04, 2005 4:49 PM To: Juan Casero (FL FLC) Cc: Postgresql General Subject: Re: [GENERAL] plpgsql function errors On Fri, Feb 04, 2005 at 01:14:44PM -0600, Juan Casero (FL FLC) wrote: > Here is the output

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Martijn van Oosterhout
On Fri, Feb 04, 2005 at 01:14:44PM -0600, Juan Casero (FL FLC) wrote: > Here is the output of that command. I ran it in a unix shell and > redirected the psql output to a file so I haven't touched it... Well, here's the problem. Your definition is: > integer | public | trx_id | charact

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Juan Casero (FL FLC)
PM To: Juan Casero (FL FLC) Cc: Postgresql General Subject: Re: [GENERAL] plpgsql function errors On Fri, Feb 04, 2005 at 12:44:35PM -0600, Juan Casero (FL FLC) wrote: > Sorry about that. I did forget one parameter... > > customer_service=# select > trx_id('JUANCASERO3055128218&

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Juan Casero (FL FLC)
inal Message- From: Martijn van Oosterhout [mailto:[EMAIL PROTECTED] Sent: Friday, February 04, 2005 1:56 PM To: Juan Casero (FL FLC) Cc: Postgresql General Subject: Re: [GENERAL] plpgsql function errors On Fri, Feb 04, 2005 at 12:44:35PM -0600, Juan Casero (FL FLC) wrote: > Sorry about tha

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Martijn van Oosterhout
On Fri, Feb 04, 2005 at 12:44:35PM -0600, Juan Casero (FL FLC) wrote: > Sorry about that. I did forget one parameter... > > customer_service=# select > trx_id('JUANCASERO3055128218',805,'CREDIT','02/02/05','1','1','Aventura' > ,'02/01/05','Tom'); > ERROR: function trx_id("unknown", integer, "unk

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Martijn van Oosterhout
On Fri, Feb 04, 2005 at 12:22:43PM -0600, Juan Casero (FL FLC) wrote: > I tried putting those values into strings like you describe below but > then the server bombs. e.g... > > customer_service=# select > trx_id('JUANCASERO3055128218','CREDIT','02/02/05','1','1','Aventura','02 > /01/05','Tom');

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Juan Casero (FL FLC)
wanted to start with the simplest case possible to improve my chances of success with the procedure and optimize it later. Any ideas on why the function call fails? Thanks, Juan -Original Message----- From: Martijn van Oosterhout [mailto:[EMAIL PROTECTED] Sent: Friday, February 04, 2005 1:06 PM

Re: [GENERAL] plpgsql function errors

2005-02-04 Thread Martijn van Oosterhout
On Fri, Feb 04, 2005 at 11:40:50AM -0600, Juan Casero (FL FLC) wrote: > Hi Everyone - > > I am new to this list and although I have been using postgresql on and > off for about a year now. I am trying to develop a webapp using perl > and cgi with postgresql 7.4.6 as a backend database. One of th

[GENERAL] plpgsql function errors

2005-02-04 Thread Juan Casero (FL FLC)
Title: plpgsql function errors Hi Everyone - I am new to this list and although I have been using postgresql on and off for about a year now.  I am trying to develop a webapp using perl and cgi with postgresql 7.4.6 as a backend database.  One of the things I need is to create a transaction

[GENERAL] plpgsql function

2004-09-02 Thread chinni
Hey guys I have written a plpgsql function which takes anyelement as argument. If I pass a string as input It gives an error "invalid input for integer" . Cant I pass any datatype for anyelement ---(end of broadcast)--- TIP 8: explain analyze is your

[GENERAL] plpgsql function parameter questions

2001-08-31 Thread augie
these 2 questions are actually unrelated... 1. what version of pg do i need to go to in order to eliminate the '16 parameter maximum' restraint? 2. can i pass an array of integers to a function? can i return an array of integers? if so, what would the function definition look like? thanks

Re: [GENERAL] plpgsql function

2000-09-05 Thread Yury Don
Hello Marcin, Once, Tuesday, September 05, 2000, 8:42:59 PM, you wrote: MM> Hi, MM> creation of following function works just fine but usage not:): MM> mtldb=# select mtldb_wykonane(0); MM> ERROR: unexpected SELECT query in exec_stmt_execsql() MM> Can You help me find an error? MM> tia MM> CRE