Re: [SQL] Do it exist?

2003-08-16 Thread Rod Taylor
> In another language I would do: > find first Order where Order.Order_num = "". > if avaialble Order then it_exists = true. > > In PostgreSQL ?: > SELECT DISTINCT Order_num from Order_header where Order_num = ''; > > Is this close? If so, how to raise flage that row exists? >

[SQL] Do it exist?

2003-08-16 Thread Hal Davison
PostgreSQL Version 7.3.0 I hope I am not Cross Posting..with psql-novice..If so..sorry.. We have a situation where in our application the user provides the Order Number for a delivery document. When the Order Number is entered we need to determine if the Order Number already exists and raise a f

Re: [SQL] Optional join

2003-08-16 Thread Ian Barwick
On Thursday 14 August 2003 16:40, Slawek Jarosz wrote: > Hi, > > I trying to write a query that will join 2 tables. Here's the concept: > Table 1: table1, primary key pk1 > Table 2: table2, primary key pk2 > > One of the fields (f2) in table2 contains either the primary key of table1 > or a NUL

Re: [SQL] About primary keys -- made some progress

2003-08-16 Thread Tom Lane
Tim Andersen <[EMAIL PROTECTED]> writes: > I still have a question about how to get the > information about length and precision of a column > from pg_attributes.atttypmod. are there built-in > functions for PostgreSQL to extract this information? Best is to rely on the format_type() function. A