On Apr 5, 2011, at 5:50 PM, Rob Sargent wrote:
>
>
> On 04/05/2011 04:02 PM, Perry Smith wrote:
>> I have five tables each with a "name" field. Due to limitations in my user
>> interface, I want a name to be unique amoung these five tables.
>>
>> I thought I could first create a view with so
On 04/05/2011 04:02 PM, Perry Smith wrote:
I have five tables each with a "name" field. Due to limitations in my user
interface, I want a name to be unique amoung these five tables.
I thought I could first create a view with something like:
SELECT name, 'table1' as type from table1
UNION
You can try restricting all name insertions (on any of the tables) to go
through one or more functions that serialize amongst themselves. Basically
lock a common table and check the view for the new name before inserting.
On Apr 5, 2011, at 18:02, Perry Smith wrote:
> I have five tables each
On Tue, 2011-04-05 at 17:02 -0500, Perry Smith wrote:
> CREATE OR REPLACE FUNCTION unique_xxx ( ) RETURNS boolean AS $$
>SELECT ( SELECT max(cnt) FROM ( SELECT count(*) AS cnt FROM xxx GROUP
> BY name ) AS foo ) = 1;
> $$ LANGUAGE SQL;
>
> Next I added a check constraint with:
>
> ALTER
I have five tables each with a "name" field. Due to limitations in my user
interface, I want a name to be unique amoung these five tables.
I thought I could first create a view with something like:
SELECT name, 'table1' as type from table1
UNION ALL
SELECT name, 'table2' as type from table2