[SQL] catching errors in function

2005-10-06 Thread padmanabha konkodi
hello sql developers, i have written function in which while executing it may throw error. if the error thrown i want rollback the transaction if not i want commit. how can i achive this task. how can catch exception thrown in the function plz help me regards konkodi

Re: [SQL] catching errors in function

2005-10-06 Thread Eugene E.
i have written function in which while executing it may throw error. if the error thrown i want rollback the transaction if not i want commit. BEGIN; SELECT you_function(args); ... many sql commands; ... COMMIT; that's all if your function raises an error whole transaction will be aborted

[SQL] Noob question about types and lists

2005-10-06 Thread xchris
Hi, i'm really new to postgres and have some doubts. Hope somebody could explain. Let say i have a table of clients and every client has a small number of addresses. (let say 3) My approch is to create a type address like this (simplified) CREATE TYPE address AS ( street

Re: [SQL] Noob question about types and lists

2005-10-06 Thread Richard Huxton
xchris wrote: CREATE TYPE address AS ( street VARCHAR(160), cityINTEGER, cap INTEGER, country INTEGER (those are referring to other table) ); and then composing table client CREATE TABLE client ( id

Re: [SQL] Noob question about types and lists

2005-10-06 Thread xchris
On gio, 2005-10-06 at 12:20 +0100, Richard Huxton wrote: From the manuals... I didn't search very well.Sorry! However - I don't think you want to anyway. If you're going to use a relational database, try a relational approach! Typically, you would do something like [cut] I wanted to

Re: [SQL] Noob question about types and lists

2005-10-06 Thread Richard Huxton
xchris wrote: On gio, 2005-10-06 at 12:20 +0100, Richard Huxton wrote: From the manuals... I didn't search very well.Sorry! Easy enough to miss. However - I don't think you want to anyway. If you're going to use a relational database, try a relational approach! Typically, you would do

Re: [SQL] Scripting GRANT on functions

2005-10-06 Thread Russell Simpkins
You could continue with this function, with an additional cursor to get the parameters for the function. If this is a one off thing, that you just need to do once, you could use pg_dump to get the create function statements and then simply alter them with an re in your favorite editor.

Re: [SQL] Scripting GRANT on functions

2005-10-06 Thread Tom Lane
Stewart Ben (RBAU/EQS4) * [EMAIL PROTECTED] writes: Is there any easy way to script granting privileges to a number of functions? I've got as far as the following code before realising that I'll need to pass in the arguments, and the arguments are stored as OIDs in pg_proc. Is there any easy

Re: [SQL] catching errors in function

2005-10-06 Thread John DeSoi
On Oct 6, 2005, at 2:55 AM, padmanabha konkodi wrote: i have written function in which while executing it may throw error. if the error thrown i want rollback the transaction if not i want commit. how can i achive this task. how can catch exception thrown in the function The function

Re: [SQL] UNION index use help

2005-10-06 Thread Tom Lane
Dmitri Bichko [EMAIL PROTECTED] writes: Ok, I'm thoroughly confused. You didn't say which PG version you are using, but if it's something reasonably recent then it should be able to push upper qual conditions down into a UNION. I think you are getting bit by this restriction: * 3. For

Re: [SQL] UNION index use help

2005-10-06 Thread Dmitri Bichko
That's exactly it - thanks, works perfectly now! For the record, it's 8.0.3 Dmitri -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Thursday, October 06, 2005 12:32 PM To: Dmitri Bichko Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] UNION index use help

[SQL] DATESTYLE and 0000-00-00

2005-10-06 Thread Joshua Kramer
Greetings, I have my DATESTYLE set to ISO MDY. When I try to create a table with a default date of -00-00, psql says that this is an invalid date. Why, and can (or how can I) get it to accept -00-00 as a valid date? Thanks, -Josh ---(end of

Re: [SQL] DATESTYLE and 0000-00-00

2005-10-06 Thread D'Arcy J.M. Cain
On Thu, 6 Oct 2005 09:01:22 -0400 (EDT) Joshua Kramer [EMAIL PROTECTED] wrote: I have my DATESTYLE set to ISO MDY. When I try to create a table with a default date of -00-00, psql says that this is an invalid date. Why, and can (or how can I) get it to accept -00-00 as a valid

Re: [SQL] DATESTYLE and 0000-00-00

2005-10-06 Thread Andrew Sullivan
On Thu, Oct 06, 2005 at 09:01:22AM -0400, Joshua Kramer wrote: I have my DATESTYLE set to ISO MDY. When I try to create a table with a default date of -00-00, psql says that this is an invalid date. Why, and can (or how can I) get it to accept -00-00 as a valid date? You can't.

[SQL] Selecting records not present in related tables

2005-10-06 Thread Hector Rosas
Hello, I'm trying to select records in a table not present in a related table, in example, I've a table with message information (subject, message, date, etc) and another (usermessages) with where user(s) has that message, its state, etc. Records in this table will be deleted in a certain time

Re: [SQL] MOVE in SQL vs PLPGSQL

2005-10-06 Thread Greg Stark
Tom Lane [EMAIL PROTECTED] writes: Richard Huxton dev@archonet.com writes: Ah, now I see what you're saying. You're quite right in your suspicions, MOVE... isn't supported for plpgsql cursors. You could probably do something with EXECUTE and returning a refcursor from a previous

Re: [SQL] Selecting records not present in related tables

2005-10-06 Thread Frank Bax
At 03:43 PM 10/6/05, Hector Rosas wrote: Hello, I'm trying to select records in a table not present in a related table, in example, I've a table with message information (subject, message, date, etc) and another (usermessages) with where user(s) has that message, its state, etc. Records in

Re: [SQL] Selecting records not present in related tables

2005-10-06 Thread Scott Marlowe
On Thu, 2005-10-06 at 14:43, Hector Rosas wrote: Hello, I'm trying to select records in a table not present in a related table, in example, I've a table with message information (subject, message, date, etc) and another (usermessages) with where user(s) has that message, its state, etc.

Re: [SQL] Selecting records not present in related tables

2005-10-06 Thread Anthony Molinaro
Jeziel, there are a couple techniques you can try, two I like are set difference and anti-joins. heres the set diff: select id from messages except select id from usermessages that will returns all id from messages not in usermessages if ID is indexed on both

[SQL] RULES on SELECT with JDBC/perlDBI from other RDBMS products?

2005-10-06 Thread Bath, David
Folks, I'm looking at using pg to be the main platform for integrating info from other RDBMS products (particularly Oracle) as pg seems to be the most flexible RDBMS around. Disregarding writing to foreign products, query-plan efficiencies, or differences of SQL dialect, I'd like to have a way

[SQL] How to delete Large Object from Database?

2005-10-06 Thread Premsun Choltanwanich
Dear All, I use '$libdir/lo' for manage my PostgreSQL Large Object. It work fine for me to get and put Large Object from and to database. However I found something that may not correct when I try to backup my data. It seem that I cannot delete Large Object from database. It seem the thing I can