Re: [SQL] Error saving image to PostgresSQL 8.x database

2005-06-29 Thread Josh Berkus
Fred, > In PostgreSQL 7.1 Documentation Chapter 8. JDBC Interface the example > below is used to store a  image file into the database. I am using J2SE > 5.02 and Pervasive Postgres  8 Release 2  with postgresql-8.0-310.jdbc3 > driver. Example 8-2. Using the JDBC Large Object Interface Why are yo

Re: [SQL] Foreign key pg_dump issue and serial column type

2005-06-29 Thread Tom Lane
"Vsevolod (Simon) Ilyushchenko" <[EMAIL PROTECTED]> writes: > However, when I pg_dump the database and import it on another server, > the tables are exported alphabetically, so when the 'people_roles' table > is created with its foreign keys, the table 'roles' does not exist yet. > Thus, the for

[SQL] Foreign key pg_dump issue and serial column type

2005-06-29 Thread Vsevolod (Simon) Ilyushchenko
Hi, As a relative newbie to postgres, I've run into to weirdisms that I don't quite know how to handle: 1. I have a many-to-many table 'people_roles' containing fields 'person_code' and 'role_code'. It links tables 'people' and 'roles'. There are foreign key constraints: ALTER TABLE PEOPLE

[SQL] Error saving image to PostgresSQL 8.x database

2005-06-29 Thread Fred Cunningham
In PostgreSQL 7.1 Documentation Chapter 8. JDBC Interface the example below is used to store a  image file into the database. I am using J2SE 5.02 and Pervasive Postgres  8 Release 2  with postgresql-8.0-310.jdbc3 driver. Example 8-2. Using the JDBC Large Object Interface For example, sup

Re: [SQL] ENUM like data type

2005-06-29 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > Rod Taylor wrote: >> Indeed. A CHECK constraint on a DOMAIN is an ENUM plus some. > Not really. A domain doesn't create a new type. If you base your enum > domains on the text type, as would usually be the case, then nothing > stops you from using

Re: [SQL] ENUM like data type

2005-06-29 Thread Peter Eisentraut
Rod Taylor wrote: > Indeed. A CHECK constraint on a DOMAIN is an ENUM plus some. Not really. A domain doesn't create a new type. If you base your enum domains on the text type, as would usually be the case, then nothing stops you from using, say, text concatenation operators and the like. I

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

2005-06-29 Thread Scott Marlowe
On Wed, 2005-06-29 at 09:22, Russell Simpkins wrote: > fair enough. but a simple order by id would never work. > Try this: select *, case when id=2003 then 1 when id=1342 then 2 when id=799 then 3 when id=1450 then 4

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

2005-06-29 Thread Michael Fuhr
On Wed, Jun 29, 2005 at 10:22:07AM -0400, Russell Simpkins wrote: > > fair enough. but a simple order by id would never work. I didn't mean to imply that it would -- I meant only that ORDER BY is necessary to guarantee a particular row order. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---

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

2005-06-29 Thread Russell Simpkins
fair enough. but a simple order by id would never work. From: Michael Fuhr <[EMAIL PROTECTED]> To: Russell Simpkins <[EMAIL PROTECTED]> CC: pgsql-sql@postgresql.org Subject: Re: [SQL] ORDER records based on parameters in IN clause Date: Wed, 29 Jun 2005 05:57:23 -0600 On Wed, Jun 29, 2005 at 07

Re: [SQL] ENUM like data type

2005-06-29 Thread Rod Taylor
On Wed, 2005-06-29 at 10:21 -0300, Martín Marqués wrote: > El Mié 29 Jun 2005 09:40, KÖPFERL Robert escribió: > > > > | > > |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

Re: [SQL] cross-table reference

2005-06-29 Thread Bruno Wolff III
Please keep replies copied to the list unless you have a specific reason not to. This lets more people potentially help you and lets others learn from the discussion. On Wed, Jun 29, 2005 at 14:09:16 +0530, Mukesh Ghatiya <[EMAIL PROTECTED]> wrote: > Hi Bruno, > > Thanks for the response. Ok, l

Re: [SQL] ENUM like data type

2005-06-29 Thread Martín Marqués
El Mié 29 Jun 2005 09:40, KÖPFERL Robert escribió: > > | > |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. > | > > I disagree. In several relations (views o

[SQL] Insert rule and default values for PK

2005-06-29 Thread KÖPFERL Robert
Hi, I've a prolem inserting records in a view using different ways. I want to insert either way, with PK given and without PK which should then be taken by its DEFAULT stanza: insert into a_and_b(a) values (537)# id not given, self assigned insert into a_and_b(x) values (true)# id not give

Re: [SQL] ENUM like data type

2005-06-29 Thread KÖPFERL Robert
| |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. | I disagree. In several relations (views of the world) one needs to have a hand full of well defined values while

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

2005-06-29 Thread Zac
SELECT table.* FROM table JOIN (SELECT id, count(id) AS count FROM... your subquery) AS x ORDER BY x.count Bye. Sorry: I forgot join condition: SELECT table.* FROM table JOIN (SELECT id, count(id) AS count FROM... your subquery) AS x ON (table.id = x.id) ORDER BY

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

2005-06-29 Thread Zac
Riya Verghese wrote: select * from table where id IN (2003,1342,799, 1450) I would like the records to be ordered as 2003, 1342, 799, 1450. The outer query has no knowledge of the count(id) that the inner_query is ordering by. I think this is the real problem: outer query must know count(id)

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

2005-06-29 Thread Michael Fuhr
On Wed, Jun 29, 2005 at 07:19:22AM -0400, Russell Simpkins wrote: > > Order by id will not do what you want, but this should. > Select * from table where id = 2003; > Union all > Select * from table where id = 1342; > Union all > Select * from table where id = 799; > Union all > Select * from tabl

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

2005-06-29 Thread Dawid Kuroczko
On 6/27/05, Riya Verghese <[EMAIL PROTECTED]> 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). > > The inner_quer

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

2005-06-29 Thread Russell Simpkins
>> 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 to be more specific and send us the exact qu

Re: [SQL] ENUM like data type

2005-06-29 Thread Dawid Kuroczko
On 6/28/05, Martín Marqués wrote: > El Mar 28 Jun 2005 13:58, PFC escribió: > > Personnally I use one table which has columns (domain, name) and which > > stores all enum values for all different enums. > > I have then CHECK( is_in_domain( column, 'domain_name' )) which is a > > simple