Re: [SQL] plpgsql: debugging

2003-01-24 Thread Ludwig Lim
--- Oliver Vecernik [EMAIL PROTECTED] wrote: Hi, Searching Google I found a thread in July 2001 concerning the facilities for debugging plpgsql functions. The actual answer was: it should be improved. What is the best way to debug a plpgsql function? Oliver This may not be

[SQL] Race condition w/ FIFO Queue reappears!

2003-01-24 Thread Chris Gamache
Tom's suggested solution worked GREAT in 7.2.x ... I tried taking the plunge into 7.3.1 tonight. In 7.3.1, when my FIFO queue program goes to grab a row, TWO processes grab the same row, almost without fail. I even changed my locking statement to the dreaded LOCK TABLE fifo IN ACCESS EXCLUSIVE

Re: [SQL] calling function from rule

2003-01-24 Thread Tambet Matiisen
-Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 23, 2003 7:01 PM To: Tambet Matiisen Cc: [EMAIL PROTECTED] Subject: Re: [SQL] calling function from rule Tambet Matiisen [EMAIL PROTECTED] writes: Try 7.3, we changed the rules about

Re: [SQL] CAST from VARCHAR to INT

2003-01-24 Thread daq
Hello! Like others said you can't cast varchar to int directly. Make your life easier! :) You must write a function like this: create function int4(character varying) returns int4 as ' DECLARE input alias for $1; BEGIN return (input::text::int4);

Re: [SQL] quastions about primary key

2003-01-24 Thread Tomasz Myrta
jack wrote: Is that possible to have a two columns primary key on a table with null value on second column? Jack Probably not, because (1,2,null,null) is unique for postresql. Watch discussion on mailing list about unique indexes (on which primary key is based) several days ago. Regards,

Re: [SQL] Scheduling Events?

2003-01-24 Thread Bruno Wolff III
On Fri, Jan 24, 2003 at 00:45:38 -0800, David Durst [EMAIL PROTECTED] wrote: I can't be sure that cron will always be up when the DB is up, so lets say crond goes down for some random reason (User, System error, Etc..) One option would be to run the cron job fairly often and have it check

Re: [SQL] quastions about primary key

2003-01-24 Thread Stephan Szabo
On Fri, 24 Jan 2003, jack wrote: Is that possible to have a two columns primary key on a table with null value on second column? No, because primary key implies not null on all columns involved (technically I think it's that a non-deferrable primary key implies not null on all columns

Re: [SQL] Scheduling Events?

2003-01-24 Thread Tom Lane
Achilleus Mantzios [EMAIL PROTECTED] writes: On Fri, 24 Jan 2003, David Durst wrote: Here is the basic problem w/ using CRON in an accounting situation. I can't be sure that cron will always be up when the DB is up, so lets say crond goes down for some random reason (User, System error,

Re: [SQL] CAST from VARCHAR to INT

2003-01-24 Thread Tom Lane
daq [EMAIL PROTECTED] writes: Make your life easier! :) You must write a function like this: create function int4(character varying) returns int4 as ' DECLARE input alias for $1; BEGIN return (input::text::int4); END; ' language 'plpgsql';

Re: [SQL] Scheduling Events?

2003-01-24 Thread Wei Weng
Or if you are so paranoid about the stability of crond, you can probably do a check to see whether crond is up when you update the database. If crond is up then update else mail root the error reject the update end This is going to affect the performance dramatically though. -

Re: [SQL] SQL to list databases?

2003-01-24 Thread Guy Fraser
Hi To make it easier to do this in SQL you can create a view like this : CREATE VIEW db_list AS SELECT d.datname as Name, u.usename as Owner, pg_catalog.pg_encoding_to_char(d.encoding) as Encoding FROM pg_catalog.pg_database d LEFT JOIN pg_catalog.pg_user u ON d.datdba =

Re: [SQL] Scheduling Events?

2003-01-24 Thread Guy Fraser
Hi I would agree that cron is probably the best solution. You could have cron perform a query that has a trigger and performs all the tasks you need done. As well you could create a trigger on other queries that would perform the other things as well, but make sure it isn't a heavily used

Re: [SQL] Scheduling Events?

2003-01-24 Thread David Durst
here is a possible NON-Cron solution that a friend of mine came up w/ 1) Create a table w/ scheduled events and Account Ids attached to them. 2) Create a table w/ temporal event execution timestamps. 3) On journal entry check to see if there any schedule events for the Account 4) Check timestamp

Re: [SQL] Getting multiple rows in plpgsql function

2003-01-24 Thread Roberto Mello
On Fri, Jan 24, 2003 at 11:39:07AM -0800, David Durst wrote: I am wondering how you would handle a select that returns multiple rows in a plpgsql function? In other words lets say I wanted to iterate through the results in the function. There are examples in the PL/pgSQL documentation that

[SQL] Function for adding Money type

2003-01-24 Thread David Durst
Are there functions for adding and subtracting this type from itself? Or is there a simple way to do it? ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Function for adding Money type

2003-01-24 Thread Josh Berkus
David, Are there functions for adding and subtracting this type from itself? Or is there a simple way to do it? The MONEY type is depreciated, and should have been removed from the Postgres source but was missed as an oversight. Use NUMERIC instead. -- -Josh Berkus Aglio Database

Re: [SQL] Function for adding Money type

2003-01-24 Thread David Durst
David, Are there functions for adding and subtracting this type from itself? Or is there a simple way to do it? The MONEY type is depreciated, and should have been removed from the Postgres source but was missed as an oversight. Use NUMERIC instead. -- -Josh Berkus Aglio Database

Re: [SQL] Getting multiple rows in plpgsql function

2003-01-24 Thread Guy Fraser
NOTE: This is a feature in 7.3 it was either added or fixed, so you will not be able to do this unless you are using version 7.3. Remember to backup with pg_dumpall before you upgrade. This is a sample sent to me earlier this week, that iterates an integer array: Cut Here