Re: [SQL] pl/pgsql or control structures outside of a function?

2009-04-06 Thread Peter Koczan
On Fri, Apr 3, 2009 at 11:28 PM, John DeSoi wrote: >> Is there any way to use PL/pgSQL code outside of a function? > > No. I kinda figured, but it doesn't hurt to ask. >> The reason I'm asking is that I'm porting some code from >> sybase/isql/SQR, and it allows some control code structures to be

Re: [SQL] pl/pgsql or control structures outside of a function?

2009-04-03 Thread John DeSoi
On Apr 3, 2009, at 5:03 PM, Peter Koczan wrote: Is there any way to use PL/pgSQL code outside of a function? No. The reason I'm asking is that I'm porting some code from sybase/isql/SQR, and it allows some control code structures to be used in an sql script. For instance, CASE might wor

Re: [SQL] PL/pgSQL function syntax question?

2008-09-09 Thread Lennin Caro
--- On Mon, 9/8/08, Ruben Gouveia <[EMAIL PROTECTED]> wrote: > From: Ruben Gouveia <[EMAIL PROTECTED]> > Subject: [SQL] PL/pgSQL function syntax question? > To: "pgsql-sql" > Date: Monday, September 8, 2008, 9:40 PM > i get the following error when i try and create the > following function: >

Re: [SQL] PL/pgSQL function syntax question?

2008-09-08 Thread imad
I see v_dt is not initialized before comparison, there should be some value in it before it is useful. --Imad On Tue, Sep 9, 2008 at 8:47 AM, Adrian Klaver <[EMAIL PROTECTED]> wrote: > > -- Original message -- > From: "Ruben Gouveia" <[EMAIL PROTECTED]> > > i get

Re: [SQL] PL/pgSQL function syntax question?

2008-09-08 Thread Adrian Klaver
-- Original message -- From: "Ruben Gouveia" <[EMAIL PROTECTED]> > i get the following error when i try and create the following function: > > Basically, i am trying to have two different dates compared and only the > most recent returned to me. This seems pretty

Re: [SQL] pl/PgSQL, variable names in NEW

2008-04-10 Thread Alvaro Herrera
Martin Edlman wrote: > |> I don't want to rewrite whole trigger to plPerl as I would have to use > |> DBD-PgSPI. > | > | Huh? Certainly not -- there are functions in PL/Perl for this. See > | spi_exec_query in > | http://www.postgresql.org/docs/8.3/static/plperl-database.html > > Oh, I see. I ha

Re: [SQL] pl/PgSQL, variable names in NEW

2008-04-10 Thread Martin Edlman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 |> I don't want to rewrite whole trigger to plPerl as I would have to use |> DBD-PgSPI. | | Huh? Certainly not -- there are functions in PL/Perl for this. See | spi_exec_query in | http://www.postgresql.org/docs/8.3/static/plperl-database.html Oh,

Re: [SQL] pl/PgSQL, variable names in NEW

2008-04-08 Thread Alvaro Herrera
Martin Edlman wrote: > I don't want to rewrite whole trigger to plPerl as I would have to use > DBD-PgSPI. Huh? Certainly not -- there are functions in PL/Perl for this. See spi_exec_query in http://www.postgresql.org/docs/8.3/static/plperl-database.html -- Alvaro Herrera

Re: [SQL] pl/PgSQL, variable names in NEW

2008-04-08 Thread Martin Edlman
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, | no, it's not possible in plpgsql. Please, use plperl or plpython. thanks for the response. It's as I expected and was afraid of :-( I select data from DB using pl/PgSQL in the replace_values trigger and then call plPerl function which retu

Re: [SQL] pl/PgSQL, variable names in NEW

2008-04-07 Thread Pavel Stehule
Hello no, it's not possible in plpgsql. Please, use plperl or plpython. Regards Pavel Stehule On 07/04/2008, Martin Edlman <[EMAIL PROTECTED]> wrote: > Hello, > > is it possible to use variables as field names in the NEW record? > Let's suppose I have a varchar attname containg the name

Re: [SQL] pl/pgsql and error handling

2008-02-28 Thread Bart Degryse
www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING would be the place to look. >>> Alex Hochberger <[EMAIL PROTECTED]> 2008-02-29 6:29 >>> I do not know. It's sounds like the Oracle PL/SQL behavior is what I want. Does PostgreSQL's pl/pgsql have such a f

Re: [SQL] pl/pgsql and error handling

2008-02-28 Thread Alex Hochberger
I do not know. It's sounds like the Oracle PL/SQL behavior is what I want. Does PostgreSQL's pl/pgsql have such a feature? It's not in the documentation anywhere. I'll check it from the office tomorrow. Alex On Feb 28, 2008, at 11:43 PM, Tom Lane wrote: Alex Hochberger <[EMAIL PROTECTE

Re: [SQL] pl/pgsql and error handling

2008-02-28 Thread Tom Lane
Alex Hochberger <[EMAIL PROTECTED]> writes: > Is it possible to grab access to the actually user-friendly error > message? Doesn't the SQLERRM variable do what you want? regards, tom lane ---(end of broadcast)--- TIP 4: Ha

Re: [SQL] PL/pgSQL question

2008-02-14 Thread Milen A. Radev
Sebastian Ritter написа: Hi all, I have a question regarding functions. How can I return zero rows from a function whose return type is a table row? I did the following test and it did not work as expected: [...] CREATE OR REPLACE FUNCTION foobar(boolean) RETURNS SETOF x AS $_$ DECLARE

Re: [SQL] PL/pgsql: function passing argument to IN operator

2007-12-28 Thread Pavel Stehule
Hello it has sense only for array type so you can try: create replace function foo(anyarray) returns bool as $$ begin return (select 1 = any($1)); end ; $$ language plpgsql; postgres=# select foo(array[1,2,3]); foo - t (1 row) postgres=# select foo(array[2,3]); foo - f (1 row) R

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread imad
On 5/11/07, Robins <[EMAIL PROTECTED]> wrote: Hi Gabriel, There are two ways to do this: 1. Imad's way (Define the function with the return type as RECORD). Its only problem is that while querying from this function, you need to give a proper SELECT query or else PG returns an error. Yeah ...

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread Robins
Hi Gabriel, There are two ways to do this: 1. Imad's way (Define the function with the return type as RECORD). Its only problem is that while querying from this function, you need to give a proper SELECT query or else PG returns an error. e.g. As Imad gives in his example ... CREATE FUNCTION x

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread imad
create a function with return type as a RECORD. CREATE FUNCTION xyz() RETURNS record AS $$ declare abc RECORD; begin abc := (1, 2); return abc; end; $$ language plpgsql; And execute the function in this fashion: select a, b from xyz() as (a int, b int); Do you like that ... :-) --Imad www

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread John DeSoi
You can use CREATE TYPE: http://www.postgresql.org/docs/8.2/interactive/sql-createtype.html Example from the documentation: CREATE TYPE compfoo AS (f1 int, f2 text); Then make your function return compfoo (or setof compfoo). Alternately, you can define your function with out or in/out par

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread Gábriel Ákos
On Fri, 11 May 2007 19:09:07 +0500 imad <[EMAIL PROTECTED]> wrote: > You might be looking for PostgreSQL RECORD data type. Thanks. Give me an example please. I saw the documentation already. > > --Imad > www.EnterpriseDB.com > > On 5/11/07, Gábriel Ákos <[EMAIL PROTECTED]> wrote: > > Hi, > > >

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread imad
You might be looking for PostgreSQL RECORD data type. --Imad www.EnterpriseDB.com On 5/11/07, Gábriel Ákos <[EMAIL PROTECTED]> wrote: Hi, How should I define a record type (there is no table with this record type) programmatically in pl/pgsql? I'd like to return a record with 3 string elements

Re: [SQL] PL/pgsql declaration of string / bit / number with given (variable!) length

2007-02-06 Thread Richard Huxton
sneumann wrote: Hi, I have a PL/pgsql function that creates a certain bit string based on the parameters. Things work fine if I use bit(10) throughout the function. Now I'd like to return a bit string with the given size "len", but that breaks with a syntax error: ret := B'0'::bit(len

Re: [SQL] PL/pgSQL and PHP 5 - thanks

2006-08-09 Thread PostgreSQL Admin
Thanks, The search path was the problem. Sometimes it's the simple things. Big thanks, J ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] PL/pgSQL and PHP 5

2006-08-09 Thread PostgreSQL Admin
Tom Lane wrote: PostgreSQL Admin <[EMAIL PROTECTED]> writes: CREATE OR REPLACE FUNCTION insert_staff_b (insert_firstname varchar) RETURNS VOID AS ... Still I get this error: Warning: pg_query(): Query failed: ERROR: function insert_staff_b(character varying) does not exist Sure lo

Re: [SQL] PL/pgSQL and PHP 5

2006-08-09 Thread Tom Lane
PostgreSQL Admin <[EMAIL PROTECTED]> writes: > CREATE OR REPLACE FUNCTION insert_staff_b > (insert_firstname varchar) > RETURNS VOID AS > ... > Still I get this error: > Warning: pg_query(): Query failed: ERROR: function > insert_staff_b(character varying) does not exist Sure looks like it ou

Re: [SQL] PL/PGSQL - How to pass in variables?

2006-05-14 Thread Jean-Paul Argudo
Scott Yohonn wrote: > Jean-Paul, > > Thanks! This did work. The output put the name of the function > (get_table_count) as the header. How would I display the name of the table > that I am requesting the row count of? The only way I know is to alias the output in the query calling the function, s

Re: [SQL] PL/PGSQL - How to pass in variables?

2006-05-14 Thread Jaime Casanova
On 5/14/06, Scott Yohonn <[EMAIL PROTECTED]> wrote: Using PL/PGSQL, I am trying to create a procedure to display the count of rows in any single table of a database. The End-user would pass in a table name and the prodecure would display the table name with the row count. I am able to hardcode t

Re: [SQL] PL/PGSQL - How to pass in variables?

2006-05-14 Thread Jean-Paul Argudo
Hi Scott, You'll have to execute dynamic SQL (see doc chapter "36.6.5. Executing Dynamic Commands") for your function to work: CREATE FUNCTION get_table_count(tablename text) RETURNS integer AS $$ DECLARE --tablename ALIAS FOR $1; rowcount INTEGER; BEGIN execute 'SELECT count(*) F

Re: [SQL] pl/PgSQL: Samples doing UPDATEs ...

2005-08-18 Thread Michael Fuhr
On Fri, Aug 19, 2005 at 02:38:01AM -0300, Marc G. Fournier wrote: > I have an older PostgreSQL book here, that has chapter on pl/PgSQL in it, > but no good samples > > What I'm looking for is a sample of a function that returns # of rows > updated, so that I can make a decision based on tha

Re: [SQL] pl/PgSQL: Samples doing UPDATEs ...

2005-08-18 Thread daq
MGF> I have an older PostgreSQL book here, that has chapter on pl/PgSQL in it, MGF> but no good samples MGF> What I'm looking for is a sample of a function that returns # of rows MGF> updated, so that I can make a decision based on that ... does anyone know MGF> where I could find such (a

Re: [SQL] pl/pgsql problem with return types

2005-03-11 Thread Juris Zeltins
Yep.. i have solved this problem by specifying the correct return type and variable type (should be the same) but as said, in some cases pl_exec executes with type conversion. as real example - i have : return type = SETOF new type "category_node(catid, pcatid)" variable = R, SR -> RECORD and FOR

Re: [SQL] pl/pgsql problem with return types

2005-03-11 Thread John DeSoi
On Mar 11, 2005, at 5:54 AM, Juris Zeltins wrote: FOR P IN select pageid from pages This way you are only getting the pageid column. I think what you want is FOR P in select * from pages so that P contains the complete pages record. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreS

Re: [SQL] PL/PgSQL - returning multiple columns ...

2005-02-03 Thread PFC
On Thu, 3 Feb 2005 12:48:11 -0400 (AST), Marc G. Fournier <[EMAIL PROTECTED]> wrote: Perfect, worked like a charm ... but the RETURNS still needs to be a SETOF, other then that, I'm 'away to the races' ... thanks :) No SETOF necessary : CREATE TYPE mytype AS ( number INTEGER, blah TEXT );

Re: [SQL] PL/PgSQL - returning multiple columns ...

2005-02-03 Thread Marc G. Fournier
Perfect, worked like a charm ... but the RETURNS still needs to be a SETOF, other then that, I'm 'away to the races' ... thanks :) On Wed, 2 Feb 2005, George Weaver wrote: Hi Marc, One option is to create a simple data type and return the rowtype of the datatype eg CREATE TYPE tserverload AS ("

Re: [SQL] PL/PgSQL - returning multiple columns ...

2005-02-02 Thread George Weaver
Hi Marc, One option is to create a simple data type and return the rowtype of the datatype eg CREATE TYPE tserverload AS ("server_name" text, "load_avg" int4); CREATE FUNCTION getserverload() RETURNS tserverload AS 'DECLARE r tserverload%rowtype; etc. You would then return r, comprise

Re: [SQL] PL/pgSQL, RETURN NEXT, ORDER

2004-10-12 Thread Markus Bertheau
Ð ÐÑÑ, 12.10.2004, Ð 15:24, Markus Bertheau ÐÐÑÐÑ: > Is the order of the rows guaranteed to be preserved? Neil clarified on IRC that - there is no interface guarantee - in the current implementation the order is preserved - a future implementation is likely to change that Thanks. -- Markus Ber

Re: [SQL] PL/pgSQL multidimension (matrix) array in function

2004-09-20 Thread Joe Conway
Sergio Fantinel wrote: I found how to use, inside a PL/pgSQL function, a two-dimensions array (matrix). There is a limitation: the number of the 'columns' of the matrix is fixed at declaration time (in DECLARE section) and you need to manually initialize all the elements in the first 'row' of th

Re: [SQL] PL/pgSQL Function Problem

2004-09-11 Thread Michalis Kabrianis
the inquirer wrote: I am trying to create a function that creates a user and adds a row to a table. It produces no warnings or errors when I create the function but when I attempt to execute it I get a syntax error. I do not understand why this is happening. Any help would be greatly appreciate

Re: [SQL] pl/pgsql and transaction locks

2004-06-07 Thread Marcus Whitney
Hello,   I have an instance where I have a series of pl/pgsql calls, that report stat results to a common table.  When other queries try to hit the stat table (with DML commands; SELECT, INSERT, UPDATE, DELETE etc.) they are forced to wait in a queue until the pl/pgsql has finished executing.  

Re: [SQL] PL/PGSQL TUTORIAL

2003-10-11 Thread Roberto Mello
On Sat, Oct 11, 2003 at 10:36:10AM +0100, Richard Huxton wrote: > > Oh - while I'm thinking of it, a couple of applications it might be worth > looking at are OpenACS or Bricolage, both web-based content-management > systems. OpenACS is not a content management system, but it provides a couple

Re: [SQL] PL/PGSQL TUTORIAL

2003-10-11 Thread Richard Huxton
On Saturday 11 October 2003 08:57, Muhyiddin A.M Hayat wrote: > Where can i find a complete full terminated database schema in SQL? > > I want to see a real complete database schema with views, triggers.. > etc,... Oh - while I'm thinking of it, a couple of applications it might be worth looking

Re: [SQL] PL/PGSQL TUTORIAL

2003-10-11 Thread Richard Huxton
On Saturday 11 October 2003 08:57, Muhyiddin A.M Hayat wrote: > Where can i find a complete full terminated database schema in SQL? > > I want to see a real complete database schema with views, triggers.. > etc,... Good places to start are: http://freshmeat.net/ http://sourceforge.net/ That's

Re: [SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > Do you know anything about good source of C functions documentation and > examples? Look in the main sources (backend/utils/adt/, mostly) and/or contrib modules for functions that do something like what you need. The only difference between a builtin fu

Re: [SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tomasz Myrta
I don't understand ERROR message at all: ERROR: SPI_prepare() failed on "SELECT $1 " > This is a bug. Or two bugs, actually: one of yours and one of PG's. I have repaired the PG bug with the attached patch. The bug in your code is that your C function needs to call SPI_connect and SPI_fin

Re: [SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tom Lane
Tomasz Myrta <[EMAIL PROTECTED]> writes: > I don't understand ERROR message at all: > ERROR: SPI_prepare() failed on "SELECT $1 " This is a bug. Or two bugs, actually: one of yours and one of PG's. I have repaired the PG bug with the attached patch. The bug in your code is that your C func

Re: [SQL] pl/pgsql how to return multiple values from a function

2003-03-09 Thread jack
Thanks Rajesh. It 's very useful reference site. Jack ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing lis

Re: [SQL] pl/pgsql how to return multiple values from a function

2003-03-09 Thread jack
Stephan , Both of two suggestion work. Thank you very much! Jack ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] PL/PGSQL EDITOR

2003-02-20 Thread Josh Berkus
Folks, One more note on the PostgreSQL SQL highlighting mode for Kate: Shane Wright, the author, has asked for feedback. So if you use it, please send feedback and requests to me and I'll forward them. -- -Josh Berkus Aglio Database Solutions San Francisco ---(end o

Re: [SQL] PL/PGSQL EDITOR

2003-02-19 Thread Josh Berkus
Folks, > > Well, Shane Wright just wrote an PostgreSQL syntax highlighter for Kate (part > > of the KDE project) Unfortunately, it's part of KDE 3.1, so if you're using a > > packaged distribution you'll have to wait for the next distribution version. Actually, Shane just sent me the XML fil

Re: [SQL] PL/PGSQL EDITOR

2003-02-14 Thread Tambet Matiisen
I use Editplus (http://www.editplus.com/) with PosgreSQL syntax highlighting (ftp://ftp.editplus.com/files/postgre.zip). I also define psql as external tool in Editplus and use shortcut (Ctrl + 1) to send file to server. Tambet - Original Message - From: "Eduardo" <[EMAIL PROTECTED]> To

Re: [SQL] PL/PGSQL EDITOR

2003-02-13 Thread Josh Berkus
Eduardo, > Do exists a PL/PGSQL editor? Not that I know of. We've talked about this for PGAccess, but nothing's come of it because nobody has the motivation to code it, yet. PGAccess does have a function editor, but it's rather limited. I've been told that TOra (http://www.globecom.se/tora/)

Re: [SQL] PL/PGSQL EDITOR

2003-02-13 Thread Frankie Lam
You can try Crimson Editor, a free powerful editor. http://www.crimsoneditor.com/ Regards Frankie "Eduardo" <[EMAIL PROTECTED]> wrote in message news:b2h2b0$uqd$[EMAIL PROTECTED]... > Do exists a PL/PGSQL editor? > > Thanks. > > > ---(end of broadcast)-

Re: [SQL] PL/pgSQL question

2003-02-02 Thread Josh Berkus
Jim, > Yes i'm aware this it is possible in 7.3 - can someone please confirm its > not possible in 7.2 or provide me with an example of how to go about it. It is sort of possible in 7.2, as a function can return a cursor to an interface language capable of handling cursors. However, implementa

Re: [SQL] pl/pgsql question

2002-12-18 Thread Tim Perdue
Josh Berkus wrote: Tim, That loop apparently does not find any matching rows, which would have been inserted just before this row was, inside the same transaction. It was successfully finding those rows before, when the trigger was AFTER INSERT. If I manually select those rows after the query

Re: [SQL] pl/pgsql question

2002-12-18 Thread Josh Berkus
Tim, > That loop apparently does not find any matching rows, which would > have been inserted just before this row was, inside the same > transaction. > > It was successfully finding those rows before, when the trigger was > AFTER INSERT. If I manually select those rows after the query is > commi

Re: [SQL] pl/pgsql question

2002-12-18 Thread Tim Perdue
Ludwig Lim wrote: Try changing the "AFTER" to "BEFORE" CREATE TRIGGER projtask_insert_depend_trig BEFORE... Changes made to the "NEW" will not be reflect in the AFTER trigger since, the row is already inserted. Thanks, however this seems to present a different problem now. FOR depe

Re: [SQL] pl/pgsql question

2002-12-17 Thread Ludwig Lim
--- Tim Perdue <[EMAIL PROTECTED]> wrote: > I have created a function in pl/pgsql to modify a > row before it gets put > into the database, but it seems my modification is > being ignored, and > the unmodified row is being inserted. > > I have confirmed with this RAISE EXCEPTION that my > "NEW"

Re: [SQL] pl/pgsql question

2002-12-17 Thread Tom Lane
Tim Perdue <[EMAIL PROTECTED]> writes: > I have created a function in pl/pgsql to modify a row before it gets put ^^^ > into the database, but it seems my modification is being ignored, and > the unmodified row is being inserted. > CREAT

Re: [SQL] PL/pgsql

2002-09-27 Thread Ian Barwick
On Wednesday 25 September 2002 21:38, Gustavo Tadao Okida wrote: (...) > After this, I wrote a function with > pgaccess : > > Name: spi_novo_parametro paramters: > returns: char language: plpgsql > > DECLARE > val INTEGER :=1; > BEGIN > insert into

Re: [SQL] pl/pgsql capabilities?

2002-07-01 Thread Roberto Mello
On Tue, Jul 02, 2002 at 01:37:08AM +0200, Ferenc Engard wrote: > > If I understand well, I can create a cursor for a SELECT statement, and > return that cursor. Well, it is better than nothing, but I fear it is > not flexible enogh for me. Maybe not for the solution you have right now, but you m

Re: [SQL] pl/pgsql capabilities?

2002-07-01 Thread Ferenc Engard
> > since it changed: can I use the procedural languages (any of them) to > > return a table- (or view-) like output, just like in Interbase, for > > example? E.g., if I have a metamodel and I want to write functions what > > perform complex computations and queries, can they return the result > >

Re: [SQL] pl/pgsql capabilities?

2002-07-01 Thread Roberto Mello
On Mon, Jul 01, 2002 at 01:43:29AM +0200, Ferenc Engard wrote: > Hi all, > > A long time ago (at version 6.3.2 or what :) I have asked, but maybe > since it changed: can I use the procedural languages (any of them) to > return a table- (or view-) like output, just like in Interbase, for > example

Re: [SQL] PL/pgSQL syntax for strings

2001-11-03 Thread Edward Grabczewski
I've sorted this one thanks to John Berkus. Thanks guys. I've included the solution below for your interest. === DROP TABLE rtest; DROP INDEX rtest_xz_index; DROP INDEX rtest_yz_index; DROP INDEX rtest_xy_index; CREATE TABLE rtest (

Re: [SQL] PL/pgSQL syntax for strings

2001-11-01 Thread Roberto Mello
On Thu, Nov 01, 2001 at 04:48:29PM +, Edward Grabczewski wrote: > > DROP FUNCTION threedpoint (float,float,float, float,float,float); > CREATE FUNCTION threedpoint (float,float,float,float,float,float) > RETURNS text > AS 'DECLARE > x1 ALIAS FOR $1; > y1 ALIAS FOR $2; > z1 A

Re: [SQL] PL/pgSQL triggers ON INSERT OR UPDATE

2001-10-24 Thread san
From [EMAIL PROTECTED] Tue Oct 23 18:33:27 2001 Content-Disposition: inline From: "Aasmund Midttun Godal" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [SQL] PL/pgSQL triggers ON INSERT OR UPDATE

Re: [SQL] PL/pgSQL triggers ON INSERT OR UPDATE

2001-10-23 Thread Aasmund Midttun Godal
First, I may be wrong but I do think they would prefer if you did not cross-post (especially to hackers). Second I think it probably make more sense to make two different triggers here. If you really wanted to do it that way you might want to try executing that part. Regards, Aasmund. On Mon

Re: [SQL] PL/PGSQL Regexe

2001-09-27 Thread rdear
Humm... 7.0.2, I'll upgrade and try again. Thanks! Tom Lane wrote: [EMAIL PROTECTED]">rdear <[EMAIL PROTECTED]> writes: I'm doing a check within a PL/PGSQL function using a regular expression and I get the error: ERROR: regcomp failed with error invalid character range This appears

Re: [SQL] PL/PGSQL Regexe

2001-09-19 Thread Tom Lane
rdear <[EMAIL PROTECTED]> writes: > I'm doing a check within a PL/PGSQL function using a regular expression > and I get the error: > ERROR: regcomp failed with error invalid character range > This appears to be because of the underscore "_" character. The regex I > want to use is ''[A-Za-z0-9

Re: [SQL] pl/pgsql - code review + question

2001-07-20 Thread Bruce Momjian
> Josh - if I try and do OFFSET at the same time (presumably it's the same > change) do you fancy acting as a sanity test site? > Both LIMIT and OFFSET seem to have that restriction. I will add this to the TODO list. -- Bruce Momjian| http://candle.pha.pa.us [EMAI

Re: [SQL] pl/pgsql - code review + question

2001-07-19 Thread Josh Berkus
Richard, > > Josh - if I try and do OFFSET at the same time (presumably it's the > same > > change) do you fancy acting as a sanity test site? > > What am I talking about - OFFSET is going to be parsed by the SQL > parser not > the plpgsql parser. Not so, not so! Try the following two PL/pgSQL

Re: [SQL] pl/pgsql - code review + question

2001-07-19 Thread Richard Huxton
From: "Richard Huxton" <[EMAIL PROTECTED]> > False Laziness perhaps (spot my Perl background) > > OK - stick me down for having a look at it. Had a quick peek and I think > it's within my abilities. Give me a couple of weeks, because I haven't > looked at a YACC file since my university days (gra

Re: [SQL] pl/pgsql - code review + question

2001-07-19 Thread Richard Huxton
From: "Tom Lane" <[EMAIL PROTECTED]> > "Richard Huxton" <[EMAIL PROTECTED]> writes: > > Don't know why the parser for RAISE doesn't like string concat. > > Laziness ;-). Someone should fix plpgsql so that RAISE does take > expressions, not just literals and simple variables. It probably > would

Re: [SQL] pl/pgsql - code review + question

2001-07-18 Thread Josh Berkus
Tom, Folks, > > Don't know why the parser for RAISE doesn't like string concat. > > Laziness ;-). Someone should fix plpgsql so that RAISE does take > expressions, not just literals and simple variables. It probably > wouldn't be a big change, but I've no time to look at it myself; > any volun

Re: [SQL] pl/pgsql - code review + question

2001-07-18 Thread Tom Lane
"Richard Huxton" <[EMAIL PROTECTED]> writes: > Don't know why the parser for RAISE doesn't like string concat. Laziness ;-). Someone should fix plpgsql so that RAISE does take expressions, not just literals and simple variables. It probably wouldn't be a big change, but I've no time to look at

Re: [SQL] pl/pgsql - code review + question

2001-07-18 Thread Tom Lane
Gary Stainburn <[EMAIL PROTECTED]> writes: > My problem now is that when I include the code to handle the record > not being there, from the pgsql chapter (section 23.2.3.3) I get the > following errors based of the function below. IIRC, there's an erroneous example in the 7.1 plpgsql documentati

Re: [SQL] pl/pgsql - code review + question

2001-07-18 Thread Richard Huxton
From: "Gary Stainburn" <[EMAIL PROTECTED]> > My problem now is that when I include the code to handle the record not being > there, from the pgsql chapter (section 23.2.3.3) I get the following errors Hey - stop that! If everyone starts reading the docs and quoting chapter refs all we'll be left

Re: [SQL] pl/pgsql - code review + question

2001-07-18 Thread Richard Huxton
From: "Gary Stainburn" <[EMAIL PROTECTED]> > Hi all, I've just written my first pl/pgsql function (code included below for > you to pull apart). Looks fine to me. Try it with "SELECT INTO" etc rather than "select into" and see if you prefer it - I find it makes the variables/fields stand out be

Re: [SQL] pl/pgsql - code review + question

2001-07-18 Thread Gary Stainburn
Okay, I've been hit round the back of the head, and I realised that the postgresql functions (inc subtring) are available in pl/pgsql, so that's my problem solved. I've written the getmid function as below, which is basically the same as the getunitno I included in my first post. My problem n

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ... :)

2001-07-17 Thread Josh Berkus
Crhis, > Thanks ;). I'm new to PostGreSQL and to PHP and to SQL - I have done > Progress RDBMS/4GL for the last 12 years and it absolutely spoils > you. But > in the last 2 weeks, I have hammered out an application (you can have > a look > at http://chill-025.bbnow.net, use user demo and password

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ...:)

2001-07-17 Thread Chris Ruprecht
Hi Josh, on 07/17/2001 18:31, Josh Berkus at [EMAIL PROTECTED] wrote: > Chris, > > Hmmph. People are in a bad mood this week; obviously few other people > on the list have had to write applications for the banking industry, > which trades everything in flat files. Give Chris a break! > Than

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ... :)

2001-07-17 Thread Josh Berkus
Chris, Hmmph. People are in a bad mood this week; obviously few other people on the list have had to write applications for the banking industry, which trades everything in flat files. Give Chris a break! > >From an input file where the records looks like this one: > > 020-13 016-05 07-15-200

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ... :)

2001-07-17 Thread Tom Lane
Chris Ruprecht <[EMAIL PROTECTED]> writes: > If life was easy, everything would just come in the format I'd like it. But > since it isn't, I need to create records like this one: > ... > From an input file where the records looks like this one: If it's just a data import issue, why do you want to

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ...:)

2001-07-17 Thread Chris Ruprecht
Hi Tom, If life was easy, everything would just come in the format I'd like it. But since it isn't, I need to create records like this one: cdate| ctime | countrycode | areacodex | success | carrier | duration| phonenumber | areacode | pseq | loadno | frline | entity | loaddate | loa

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ... :)

2001-07-17 Thread Peter Eisentraut
Chris Ruprecht writes: > I need to know how I can access a flat file from within a PL/PGSQL script. You can't. PL/TclU could help you there. -- Peter Eisentraut [EMAIL PROTECTED] http://funkturm.homeip.net/~peter ---(end of broadcast)--- T

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ... :)

2001-07-17 Thread Tom Lane
"Chris Ruprecht" <[EMAIL PROTECTED]> writes: > I need to know how I can access a flat file from within a PL/PGSQL script. You can't --- and you should ask yourself hard questions about why your system design needs that, or whether the data in question shouldn't be inside the database to begin wit

Re: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ... :)

2001-07-17 Thread Wei Weng
You can probably try to make a c extension that does open/close. On 17 Jul 2001 15:28:36 -0500, Chris Ruprecht wrote: > Hi all, > > I need to know how I can access a flat file from within a PL/PGSQL script. > I have an Oracle PL/SQL book here and they refer to FOPEN(...), FCLOSE(...) > but these

RE: [SQL] PL/PGSQL and external (flat ASCII) files - Urgent ... :)

2001-07-17 Thread Robby Slaughter
The hack and slash Perl programmer in me says--- if you only plan to do this once, (like importing data), then just write a Perl script that *generates* SQL code that does your inserts, updates, or whatever. You can then execute thsi with psql -f filename. But if you're trying to use flat files pr

Re: [SQL] PL/PGSQL

2001-06-12 Thread Roberto Mello
On Tue, Jun 05, 2001 at 08:18:03AM +0200, Andrzej Roszkowski wrote: > Hi! > I can't find any info about possible data types that can be returned from > procedure. I want to return tuple. When I use OPAQUE as a return type I > get error message that OPAQUE can be only returned from trigger. It is >

Re: [SQL] pl/pgsql and returning rows

2001-03-27 Thread Richard Huxton
From: "wade" <[EMAIL PROTECTED]> > create function get_details(int4) returns details as ' > declare > ret details%ROWTYPE; > site_recrecord; > cntct contacts%ROWTYPE; > begin > select into site_rec * sites_table where id = $1 limit 1; > select into cntct * from contacts where

Re: [SQL] PL/pgSQL "compilation error"

2001-03-15 Thread Jan Wieck
Josh Berkus wrote: > This brings up an important point. We have a medium-large user base for > PL/pgSQL out there, but it appears that Jan Wieck no longer has time to > develop the language ... nor should he be the sole developer. Howe do > we find more developers to expand & extend PL/pgSQL? I

Re: [SQL] PL/PgSQL and NULL

2001-03-15 Thread Jan Wieck
Jie Liang wrote: > > I think that is a bug in plpgsql, > when passing a NULL into a plpgsql defined function, it treats > other arguments as NULL also, you can use raise notice in > your function to watch this buggy thing(see following). You're blaming the wrong code for it. It's an insuffi

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Bruce Momjian
> I'm happy to do my bit on the documentation side, but I don't want to end > up duplicating the cookbook - does anyone know the status of this? I'd > guess 90% of plpgsql functions will be on the same "theme" as something > in a cookbook so it's the perfect format for learning/cut & paste. I

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Richard H
On 3/14/01, 4:28:03 PM, Josh Berkus <[EMAIL PROTECTED]> wrote regarding Re: [SQL] PL/pgSQL "compilation error": > Tim, > > Hello all - I apologize for the newbie-esque question, but the debug output > > from postgres when you have a bug in your PL/pgSQL pr

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Peter Eisentraut
Bruce Momjian writes: > There is a PL/PgSQL HowTo that we are trying to integrate into the docs > for 7.1. Anyone have a URL or status on that? It's not a PL/pgSQL Howto, it's just a documentation how to port from Oracle's PL/SQL. The status is "done". The author expressed interest in more wo

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Bruce Momjian
> Bruce Momjian writes: > > > There is a PL/PgSQL HowTo that we are trying to integrate into the docs > > for 7.1. Anyone have a URL or status on that? > > It's not a PL/pgSQL Howto, it's just a documentation how to port from > Oracle's PL/SQL. The status is "done". The author expressed inter

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Richard Huxton
From: "Tim Perdue" <[EMAIL PROTECTED]> > Hello all - I apologize for the newbie-esque question, but the debug output > from postgres when you have a bug in your PL/pgSQL procedure is none to > detailed. > > I've created the following procedure and am getting an error when I try to > update the ta

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Bruce Momjian
> IF NEW.status_id <> OLD.status_id THEN > IF new.status_id = 1 THEN > UPDATE artifact_counts_agg SET open_count=open_count+1 \ >WHERE group_artifact_id=new.group_artifact_id; > ELSE IF new.status_id = 2 THEN > UPDATE artifact_counts_

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Josh Berkus
Tim, > Hello all - I apologize for the newbie-esque question, but the debug output > from postgres when you have a bug in your PL/pgSQL procedure is none to > detailed. It's an improvement over the query parser errors -- at least in PL/pgSQL you get a line number! Although in your case, the l

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Tim Perdue
On Wed, Mar 14, 2001 at 10:33:49AM -0500, Bruce Momjian wrote: > It is hard to test this without the table schema, but I think you are > missing some END IF's in the code above. Those are not elif's, but > actual new IF's that need their own END IF, I think. Oh wow - this is almost like going ba

Re: [SQL] PL/pgSQL "compilation error"

2001-03-14 Thread Tom Lane
Don't you have one END IF too many? regards, tom lane ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://www.postgresql.org/search.mpl

  1   2   >