[SQL] SELECT INTO returning more than one row

2005-06-28 Thread Zac
Hi. I have this problem in a plpgsql function: SELECT INTO myvar col FROM table WHERE ...; IF query returns more than one row THEN do something ELSE IF query returns no rows THEN do something else ELSE do other things If query returns no rows I know that myvar IS NULL

Re: [SQL] customising serial type

2005-06-28 Thread Stefan Becker
Am Dienstag, 21. Juni 2005 12:01 schrieben Sie: hi,in a table with a serial datatype, how do i get the sequence to start at a specific number like 10? Use START in the create sequence statement. # create sequence seq_xeingang increment 1 start 1000; ; CREATE TABLE xeingang ( id

[SQL] ENUM like data type

2005-06-28 Thread MRB
Hi All, I have something in mind I'm not certain is do-able. I'm working with a lot of data from MySQL where the MySQL ENUM type is used. This is not a big problem per se but creating the proper lookup tables is becoming a bit tedious so I was hoping to make something better of it. Here is

Re: [SQL] scroll cursor bug or me?

2005-06-28 Thread Sim Zacks
It seems to me that scroll cursors are not valid in plpgsql. The following query in PGAdmin works. run one line at a time. begin work; declare bob scroll cursor for select * from testtbl; fetch forward 5 from bob; fetch prior from bob; rollback work; Larry Morroni [EMAIL PROTECTED] wrote

Re: [SQL] ORDER records based on parameters in IN clause

2005-06-28 Thread Michael Fuhr
On Mon, Jun 27, 2005 at 09:15:15AM -0700, Riya Verghese wrote: I have a stmt where the outer-query is limited by the results of the inner query. I would like the outer query to return records in the same order as the values provided in the IN clause (returned form the inner query). If you

Re: [SQL] Unique primary index?

2005-06-28 Thread M.D.G. Lange
I would say that you should learn a bit about relational databases before you start working with them ;-) All unique fields (or combinations of fields that -combined- are unique) can serve as a primary key. In relational databases we call them 'candidate key'. if you have more than one

Re: [SQL] ENUM like data type

2005-06-28 Thread Kenneth Gonsalves
On Tuesday 21 Jun 2005 8:50 pm, MRB wrote: I'm working with a lot of data from MySQL where the MySQL ENUM type is used. just a thought - it took me five years after migrating from mysql to pg to start thinking like an sql programmer. I used to keep trying to write stuff for pg 'like' i used

[SQL] ERROR: TZ/tz not supported

2005-06-28 Thread Sergey Levchenko
When I execute query, I've got error message. test= SELECT to_timestamp('00:00:05.601 SAMST Tue Jun 28 2005', 'HH24:MI:SS.MS TZ Dy Mon DD '); ERROR: TZ/tz not supported How can I convert '00:00:05.601 SAMST Tue Jun 28 2005' (varchar type) to timestamp with time zone?

Re: [SQL] ENUM like data type

2005-06-28 Thread Bruno Wolff III
On Tue, Jun 21, 2005 at 17:20:19 +0200, MRB [EMAIL PROTECTED] wrote: Here is where I get uncertain as to if this is possible. My idea is to create a pseudo type that triggers the creation of it's lookup tables the same way the SERIAL type triggers creation of a sequence and returns an

Re: [SQL] Unique primary index?

2005-06-28 Thread PFC
index is... an index ! UNIQUE is an index which won't allow duplicate values (except for NULLS) PRIMARY KEY is exactly like UNIQUE NOT NULL, with the bonus that the database knows this column is the primary key so you can use stuff like NATURAL JOIN without telling which column you want to

Re: [SQL] ENUM like data type

2005-06-28 Thread Martín Marqués
El Mar 28 Jun 2005 13:58, PFC escribió: Here is where I get uncertain as to if this is possible. My idea is to create a pseudo type that triggers the creation of it's lookup tables the same way the SERIAL type triggers creation of a sequence and returns an int with the right default

Re: [SQL] ENUM like data type

2005-06-28 Thread Scott Marlowe
On Tue, 2005-06-28 at 13:22, Martín Marqués wrote: El Mar 28 Jun 2005 13:58, PFC escribió: Here is where I get uncertain as to if this is possible. My idea is to create a pseudo type that triggers the creation of it's lookup tables the same way the SERIAL type triggers creation of a

Re: [SQL] ENUM like data type

2005-06-28 Thread Nick Johnson
Martín Marqués wrote: I personally think that the ENUM data type is for databases that are not well designed. So, if you see the need for ENUM, that means you need to re-think your data design. You mean like all those instances in the PostgreSQL system catalogs where character(1) has

Re: [SQL] ORDER records based on parameters in IN clause

2005-06-28 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 when I say select * from table where id IN (2003,1342,799, 1450) I would like the records to be ordered as 2003, 1342, 799, 1450. Just say: select * from table where id IN (2003,1342,799, 1450) ORDER BY id; If that doesn't work, you will have