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

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

2009-04-03 Thread Peter Koczan
Hi all, Is there any way to use PL/pgSQL code outside of a function? 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, begin if ((select count(*) from users where login = 'foo') = 0)

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 tr

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

2008-09-08 Thread imad
t > or > > near "loop" > > SQL state: 42601 > > Character: 195 > > You need to DECLARE v_record as a RECORD variable. > v_record RECORD; > > -- > Adrian Klaver > [EMAIL PROTECTED] > > > > > > -- Forwarded message --

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

[SQL] PL/pgSQL function syntax question?

2008-09-08 Thread Ruben Gouveia
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 straight forward, what I am doing wrong here? create or replace function fcn_pick_date(v_dt date) returns

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

2008-04-10 Thread Alvaro Herrera
Tom Lane wrote: > "Joshua D. Drake" <[EMAIL PROTECTED]> writes: > > From what I can see on CPAN (unless I am missing something) DBD::PgSPI > > hasn't been updated since 2004 and is at version 0.2. > > Oh, if it's not a live project then that changes things entirely. > +1 for just dropping the ment

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

2008-04-10 Thread Tom Lane
"Joshua D. Drake" <[EMAIL PROTECTED]> writes: > From what I can see on CPAN (unless I am missing something) DBD::PgSPI > hasn't been updated since 2004 and is at version 0.2. Oh, if it's not a live project then that changes things entirely. +1 for just dropping the mention.

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

2008-04-10 Thread Tom Lane
Alvaro Herrera <[EMAIL PROTECTED]> writes: > Question for plperl hackers: Should we remove the mention of DBD::PgSPI > from the PL/Perl manual? It seems like a reasonable suggestion to me, since perl database users probably already know DBD and don't have to learn something new if they go that wa

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

[SQL] pl/PgSQL, variable names in NEW

2008-04-07 Thread Martin Edlman
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 of the field and I want to know a value that field of the NEW record. Problem is that I get an error 'record "new" has no field "attname"'. Of course I want to u

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

[SQL] pl/pgsql and error handling

2008-02-28 Thread Alex Hochberger
Is it possible to grab access to the actually user-friendly error message? I have a bunch of files that come into my database, each slightly different. The submitter fills out a form that records the info, and sticks it into a table. If the file is malformed (wrong number of columns in a

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

[SQL] PL/pgSQL question

2008-02-14 Thread 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 fn_get_user (integer) RETURNS usertable AS ' DECLARE in_userid A

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

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

2007-12-28 Thread Daniel Myers
Hello list, I'm trying to write a function that uses one of its arguments as an input to an IN operator in a WHERE clause. I.e., something like: -- ids are actually integers CREATE FUNCTION foo(ids SOMETYPE) RETURNS [whatever] AS $$ BEGIN SELECT id, [other stuff] FROM table WHERE [other cond

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

[SQL] PL/PGSQL Record type question

2007-05-11 Thread Gábriel Ákos
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, 2 integers and 1 date. Rgds, Akos -- Üdvözlettel, Gábriel Ákos -=E-Mail :[EMAIL PROTECTED]|Web: http://www.i-logic.hu =- -=Tel/fax

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

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

2007-02-05 Thread sneumann
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); LINE 1:

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

[SQL] PL/pgSQL and PHP 5

2006-08-09 Thread PostgreSQL Admin
I'm having this problem inserting data from my form using PL/pgSQL. Here is the simplified version of my table and function (this example does not work, also ): CREATE TABLE theirry.sample ( staff_id serial PRIMARY KEY NOT NULL, firstname varchar(100), lastname varchar(150), usern

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

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

2006-05-14 Thread Scott Yohonn
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 the variable for table and get the appropriate results

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

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

2005-08-18 Thread Marc G. Fournier
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 that ... does anyone know where I could find such (and others, would be gre

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

[SQL] pl/pgsql problem with return types

2005-03-11 Thread Juris Zeltins
Hello! i have problem with pl/pgsql function; === ERROR: wrong record type supplied in RETURN NEXT CONTEXT: PL/pgSQL function "tests" line 6 at return next === -- Function: tests(int8) -- DROP FUNCTION tests(int8); CREATE OR REPLACE FUNCTION te

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
uot;Marc G. Fournier" <[EMAIL PROTECTED]> To: Sent: Wednesday, February 02, 2005 3:10 PM Subject: [SQL] PL/PgSQL - returning multiple columns ... I have a function that I want to return 'server_name, avg(load_avg)' ... if I wanted to return matching rows in a table, I ca

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

2005-02-02 Thread George Weaver
. You would then return r, comprised of r.server_name and r.load_avg. George - Original Message - From: "Marc G. Fournier" <[EMAIL PROTECTED]> To: Sent: Wednesday, February 02, 2005 3:10 PM Subject: [SQL] PL/PgSQL - returning multiple columns ... I have a function that I

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

2005-02-02 Thread Marc G. Fournier
I have a function that I want to return 'server_name, avg(load_avg)' ... if I wanted to return matching rows in a table, I can do a 'setof ', with a for loop inside ... but what do I set the 'RETURNS' to if I want to return the results of query that returns only two fields of a table, or, in th

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

[SQL] PL/pgSQL, RETURN NEXT, ORDER

2004-10-12 Thread Markus Bertheau
Hi, When I call a PL/pgSQL function that looks roughly like the following: ... FOR x IN SELECT ... ORDER BY ... LOOP RETURN NEXT x; END LOOP; RETURN; END; Is the order of the rows guaranteed to be preserved? Thanks. -- Markus Bertheau <[EMAIL PROTECTED]> ---(

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

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

2004-09-18 Thread Sergio Fantinel
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 the matrix. The number of

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

[SQL] PL/pgSQL Function Problem

2004-09-10 Thread the inquirer
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 appreciated. SELECT create_aut

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

[SQL] PL/PGSQL TUTORIAL

2003-10-11 Thread Muhyiddin A.M Hayat
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,...  

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

[SQL] pl/pgsql, cursors and C function

2003-09-23 Thread Tomasz Myrta
Hi I'm making my first steps in C functions. I want to avoid doing all the SQL job in them, pl/pgsql looks a better choice. I tried to do this by passing opened cursor from pl/pgsql function to C function. Here is simple C function: #include #include PG_FUNCTION_INFO_V1(test2); Datum test2(PG_

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
AIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 13, 2003 11:20 PM Subject: [SQL] PL/PGSQL EDITOR > Do exists a PL/PGSQL editor? > > Thanks. > > > > > ---(end of broadcast)--- > TIP 1: subscrib

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)-

[SQL] PL/Pgsql trigger function problem.

2003-02-10 Thread James C. Ousley
  This is suppose to pull all the columns of the table that initiated the trigger func from the sys catalogs, loop through them and put everything that has changed between OLD and NEW into a comma delimited string for input into a log like table for future analysis via middleware (php,perl.

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

[SQL] pl/pgsql question

2002-12-17 Thread Tim Perdue
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" row is modified properly, however it is not being stored

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

[SQL] PL/pgsql

2002-09-27 Thread Gustavo Tadao Okida
Hi, I'm a new PostgreSql user but I have some experience in Oracle. So I decided to use PL/pgsql to build my procedure (functions). I create an database called MyDatabase and add this language into it with: createlang plpgsql MyDatabase. After this, I wrote a function with pgaccess : Nam

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

[SQL] pl/pgsql capabilities?

2002-06-30 Thread Ferenc Engard
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? E.g., if I have a metamodel and I want to write functions what perform co

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

[SQL] PL/pgSQL syntax for strings

2001-11-01 Thread Edward Grabczewski
Could someone please tell me the correct syntax for the following problem in plpgsql: The following expression code sample works but now (for example) I'd like to subsitute the variables $1 and $2 for the numbers 0 and 2 in the following expression: INSERT INTO rtest(xz,yz,xy) VALUES ( \'(0,2),

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

[SQL] PL/pgSQL triggers ON INSERT OR UPDATE

2001-10-23 Thread san
Hello, I'm trying to set up a trigger on insert or update but when using the predefined variable ``OLD'' I get a NOTICE from the trigger function about OLD not being defined yet. Of course OLD is not defined when the function is triggered on INSERT event, and I did not mention it if not inside a

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

[SQL] PL/PGSQL Regexe

2001-09-19 Thread rdear
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_]'' but this doesn't work. Any suggestions

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

  1   2   >