Re: [GENERAL] PL/SQL & unset custom variable

2009-09-02 Thread Gordon Ross
ber 2009 19:16 To: Gordon Ross Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] PL/SQL & unset custom variable Gordon Ross writes: > Sorry, no joy :-( > grails=> SELECT current_setting('phone.id'); > ERROR: unrecognized configuration parameter "phone.id"

Re: [GENERAL] PL/SQL & unset custom variable

2009-09-02 Thread Tom Lane
Gordon Ross writes: > Sorry, no joy :-( > grails=> SELECT current_setting('phone.id'); > ERROR: unrecognized configuration parameter "phone.id" > grails=> SELECT coalesce(current_setting('phone.id'),'SYSTEM'); > ERROR: unrecognized configuration parameter "phone.id" You could use a SELECT fro

Re: [GENERAL] PL/SQL & unset custom variable

2009-09-02 Thread Gordon Ross
On 02/09/2009 15:39, "Andreas Kretschmer" wrote: > Gordon Ross wrote: >> Is there a way to either test if the custom variable is set, or to specify a >> global default for the custom variable ? > > I think, you can use COALESCE(your_variable, default_value) to solve > that problem. Try it, it is

Re: [GENERAL] PL/SQL & unset custom variable

2009-09-02 Thread Andreas Kretschmer
Gordon Ross wrote: > (I'm using Postgres 8.3) > > I have a trigger that references a custom variable. Most of the time this > custom variable is set, and I have no problems. > > However, in certain corner cases the custom variable is not set and the > trigger fails. > > Is there a way to eithe

[GENERAL] PL/SQL & unset custom variable

2009-09-02 Thread Gordon Ross
(I'm using Postgres 8.3) I have a trigger that references a custom variable. Most of the time this custom variable is set, and I have no problems. However, in certain corner cases the custom variable is not set and the trigger fails. Is there a way to either test if the custom variable is set, o

Re: [GENERAL] pl/sql resources for pl/pgsql?

2009-06-22 Thread Merlin Moncure
On Sat, Jun 20, 2009 at 4:01 PM, Pavel Stehule wrote: >> *) misc: >>  *) never declare a function to return void > > ??? why - when we have not procedures ? The main reason is that functions returning void can not be used with binary protocol. merlin -- Sent via pgsql-general mailing list (pgsq

Re: [GENERAL] pl/sql resources for pl/pgsql?

2009-06-21 Thread Peter Eisentraut
On Tuesday 16 June 2009 03:16:19 gvimrc wrote: > I'm fairly new to PostgreSQL and completely new to using pl/pgsql though > I've used MySQL's procedural language a little. I heard pl/pgsql is similar > to Oracle's pl/sql so would it be possible, given that pl/pgsql literature > is a bit thin on the

Re: [GENERAL] pl/sql resources for pl/pgsql?

2009-06-20 Thread Pavel Stehule
Hi it is funny, so I found similar rules for developing plpgsql :) > > *) style: > I suggest prefixing all local variables, including inputs to and > outputs from functions.  I prefix my variables with an underscore.  If > you neglect to do this you will end up having name clashes with your > tab

Re: [GENERAL] pl/sql resources for pl/pgsql?

2009-06-20 Thread Merlin Moncure
On Sat, Jun 20, 2009 at 1:54 AM, Gurjeet Singh wrote: > On Sat, Jun 20, 2009 at 10:52 AM, Jasen Betts wrote: >> >> On 2009-06-16, gvimrc wrote: >> > I'm fairly new to PostgreSQL and completely new to using pl/pgsql >> > though I've used MySQL's procedural language a little. >> > I heard pl/pgsql

Re: [GENERAL] pl/sql resources for pl/pgsql?

2009-06-19 Thread Gurjeet Singh
On Sat, Jun 20, 2009 at 10:52 AM, Jasen Betts wrote: > On 2009-06-16, gvimrc wrote: > > I'm fairly new to PostgreSQL and completely new to using pl/pgsql > > though I've used MySQL's procedural language a little. > > I heard pl/pgsql is similar to Oracle's pl/sql so would it be possible, > > giv

Re: [GENERAL] pl/sql resources for pl/pgsql?

2009-06-19 Thread Jasen Betts
On 2009-06-16, gvimrc wrote: > I'm fairly new to PostgreSQL and completely new to using pl/pgsql > though I've used MySQL's procedural language a little. > I heard pl/pgsql is similar to Oracle's pl/sql so would it be possible, > given that pl/pgsql literature is a bit thin on the ground, to use

Re: [GENERAL] pl/sql resources for pl/pgsql?

2009-06-15 Thread Pavel Stehule
Hello documentation is very good http://www.postgresql.org/docs/8.3/static/plpgsql.html and some articles: http://www.postgres.cz/index.php/PL/pgSQL_%28en%29 regards Pavel Stehule 2009/6/16 gvimrc : > I'm fairly new to PostgreSQL and completely new to using pl/pgsql though > I've used MySQL's p

[GENERAL] pl/sql resources for pl/pgsql?

2009-06-15 Thread gvimrc
I'm fairly new to PostgreSQL and completely new to using pl/pgsql though I've used MySQL's procedural language a little. I heard pl/pgsql is similar to Oracle's pl/sql so would it be possible, given that pl/pgsql literature is a bit thin on the ground, to use books on pl/sql for developing pl/p

Re: [GENERAL] PL/SQL: function call like $1($2)

2006-10-09 Thread Merlin Moncure
On 10/9/06, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Sun, Oct 08, 2006 at 05:49:11PM +0200, Jean-Gerard Pailloncy wrote: > I try EXECUTE f || ' ( ' || p || ' );' INTO res > But is does not work too. > There is no function to convert double precision[] to text. You could use the types' input an

Re: [GENERAL] PL/SQL: function call like $1($2)

2006-10-09 Thread Uyelik
Hi, you may try; execute 'select ' || f || '(' || p || ')' into res; Merlin Moncure wrote, On 09.10.2006 16:35: On 10/8/06, Jean-Gerard Pailloncy <[EMAIL PROTECTED]> wrote: I want to create a function in PL/SQL as CREATE OR REPLACE FUNCTION "f_do" (text, double precision[]) RETURNS

Re: [GENERAL] PL/SQL: function call like $1($2)

2006-10-09 Thread Michael Fuhr
On Sun, Oct 08, 2006 at 05:49:11PM +0200, Jean-Gerard Pailloncy wrote: > I try EXECUTE f || ' ( ' || p || ' );' INTO res > But is does not work too. > There is no function to convert double precision[] to text. You could use the types' input and output functions or perhaps array_to_string(). stmt

Re: [GENERAL] PL/SQL: function call like $1($2)

2006-10-09 Thread Merlin Moncure
On 10/8/06, Jean-Gerard Pailloncy <[EMAIL PROTECTED]> wrote: I want to create a function in PL/SQL as CREATE OR REPLACE FUNCTION "f_do" (text, double precision[]) RETURNS double precision AS ' DECLARE f text := $1; p double precision[] := $2; res double precision; BEGIN SELECT

Re: [GENERAL] PL/SQL: function call like $1($2)

2006-10-08 Thread David Fetter
On Sun, Oct 08, 2006 at 05:49:11PM +0200, Jean-Gerard Pailloncy wrote: > I want to create a function in PL/SQL as > CREATE OR REPLACE FUNCTION "f_do" (text, double precision[]) RETURNS > double precision AS ' > DECLARE > f text := $1; > p double precision[] := $2; > res double precisi

[GENERAL] PL/SQL: function call like $1($2)

2006-10-08 Thread Jean-Gerard Pailloncy
I want to create a function in PL/SQL as CREATE OR REPLACE FUNCTION "f_do" (text, double precision[]) RETURNS double precision AS ' DECLARE f text := $1; p double precision[] := $2; res double precision; BEGIN SELECT f(p) into res; RETURN res; END;' LANGUAGE "plpgsql" STABLE

[GENERAL] PL/SQL Optimum search

2006-10-06 Thread Pailloncy Jean-Gérard
Hi, I would to know if there is some libraries with general algorithm for Optimum search. Exemple: I have some function res := error_estimate(x real, y real, z real, t real) I wrote a function that set of res := iterate(nb_iteration, start_x real, step_x real, that return a res := ROW(b

[GENERAL] PL/SQL to PLpg/SQL - NO_DATA_FOUND

2005-07-12 Thread Matt Miller
I need to convert hundreds of Oracle stored procs across several developing databases. I'm focusing on scripting as much of this as possible, and I'm currently stuck on converting PL/SQL's NO_DATA_FOUND behavior. What approaches have other people used? I'm targeting PostgreSQL 8.1. The problem

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-13 Thread Adam Tomjack
Shaun Clements wrote: Hi Hate to ask, but it isnt obvious to me from the documentation. How do I perform a query in pgplsql, to check it a table exists of a particular name. Thanks in advance Kind Regards, Shaun Clements -- A list of tables: SELECT schemaname, tablename FROM pg_tables; -- Returns t

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists Hi Sim   Thanks for your input.   Kind Regards,Shaun Clements  -Original Message-From: Sim Zacks [mailto:[EMAIL PROTECTED]Sent: 10 March 2005 02:47 PMTo: pgsql-general@postgresql.orgSubject: Re: [GENERAL] pl sql

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Sim Zacks
Title: RE: [GENERAL] pl sql to check if table of table_name exists I'm glad to hear you got it working. In explanation to my response: the pg_class internal table lists all the relationships in the database. relkind='r' means that the relation you are looking for is a tabl

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists Hi Sim   Thanks for your response. I had it working from a previous post by Adam Tomjack. -- A list of tables: SELECT schemaname, tablename FROM pg_tables; -- Returns true if a table exists: SELECT count(*)>0 FROM pg_tab

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Sim Zacks
Title: RE: [GENERAL] pl sql to check if table of table_name exists i mean select * from pg_class where relkind='r' and relname=your_tablename "Sim Zacks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... select your_tablename from pg

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Sim Zacks
Title: RE: [GENERAL] pl sql to check if table of table_name exists select your_tablename from pg_class where relkind='r' "Shaun Clements" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]... Hi Hate to ask, but it isnt obvious to me from the

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Chris Travers
Shaun Clements wrote: Hi Hate to ask, but it isnt obvious to me from the documentation. How do I perform a query in pgplsql, to check it a table exists of a particular name. Check the manual. There are two ways to d othis. You could query the data catalogs directly (something like count(*) fro

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists Much appreciated. Thanks Kind Regards, Shaun Clements -Original Message- From: Adam Tomjack [mailto:[EMAIL PROTECTED]] Sent: 10 March 2005 11:04 AM To: Shaun Clements Cc: postgresql Subject: Re: [GENERAL] pl sql to

Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists Hi Hate to ask, but it isnt obvious to me from the documentation. How do I perform a query in pgplsql, to check it a table exists of a particular name. Thanks in advance Kind Regards, Shaun Clements

Re: [GENERAL] PL/SQL question

2004-04-21 Thread Mike Nolan
> In fact the problem seems to come from the "INSERT INTO". I delete > everything from the function and only keep the "INSERT INTO" and get the > same problem. Given that this is supposed to be a trigger function, what's your 'create trigger' statement look like? Part of the problem may be

Re: [GENERAL] PL/SQL question

2004-04-21 Thread Stephan Szabo
On Wed, 21 Apr 2004, Froggy / Froggy Corp. wrote: > In fact the problem seems to come from the "INSERT INTO". I delete > everything from the function and only keep the "INSERT INTO" and get the > same problem. A function like: create function fz1() returns void as ' begin INSERT INTO cate

Re: [GENERAL] PL/SQL question

2004-04-21 Thread Froggy / Froggy Corp.
Hello, In fact the problem seems to come from the "INSERT INTO". I delete everything from the function and only keep the "INSERT INTO" and get the same problem. Thx in advance for answers, regards, Stephan Szabo wrote: > > On Tue, 20 Apr 2004, Froggy / Froggy Corp. wrote: > > > I

[GENERAL] PL/SQL question

2004-04-20 Thread Froggy / Froggy Corp.
Hello everyone, I try to see if i can make a recursive function with a trigger set on INSERT and doing an insert under my trigger function. So i wrote a test function : CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF RECORD AS ' DECLARE use_t RECORD; BEGIN

[GENERAL] pl-sql

2001-07-18 Thread Aarmel
When would pl/sql be of any real benifit to boost performance? Or is it really only usefull for seperating code. e.g. would it be of a better performance using pl/sql instead of creating a view. so rather then queiring multiple tables we create a view or use pl/sql. -