Re: [GENERAL] Foreign Key 'walker'?

2008-11-19 Thread Craig Ringer
Erwin Moller wrote: No, that is not the kind of chicken I was talking about. ;-) My chicken is more along these lines: I often have some tables to which everything is related (eg tblcourse that contains everything belonging to a certain course). I don't want to make a single simple mistake

Re: [GENERAL] Foreign Key 'walker'?

2008-11-19 Thread Erwin Moller
Craig Ringer schreef: Erwin Moller wrote: No, that is not the kind of chicken I was talking about. ;-) My chicken is more along these lines: I often have some tables to which everything is related (eg tblcourse that contains everything belonging to a certain course). I don't want to make a

Re: [GENERAL] Foreign Key 'walker'?

2008-11-19 Thread Erwin Moller
Hi Pavel, Thanks for that. But I already wrote a nice extension to my DB-class in PHP that uses Thomas Kellerer's approach. It was simple once you know how to retrieve the info from the systemtables. :-) Regards, Erwin Moller Pavel Stehule schreef: Hello I used this code CREATE OR

Re: [GENERAL] Foreign Key 'walker'?

2008-11-19 Thread Erwin Moller
Erwin Moller schreef: Craig Ringer schreef: Erwin Moller wrote: No, that is not the kind of chicken I was talking about. ;-) My chicken is more along these lines: I often have some tables to which everything is related (eg tblcourse that contains everything belonging to a certain course). I

[GENERAL] Foreign Key 'walker'?

2008-11-18 Thread Erwin Moller
Hi group, Considering following (simplified) example: CREATE TABLE tblnr1( nr1id SERIAL PRIMARY KEY, firstname TEXT ); CREATE TABLE tblnr2( nr2id SERIAL PRIMARY KEY, nr1id INTEGER REFERENCES tblnr1(nr1id) ); CREATE TABLE tblnr3( nr3id SERIAL PRIMARY KEY, nr2id INTEGER REFERENCES

Re: [GENERAL] Foreign Key 'walker'?

2008-11-18 Thread ries van Twisk
On Nov 18, 2008, at 9:47 AM, Erwin Moller wrote: Hi group, Considering following (simplified) example: CREATE TABLE tblnr1( nr1id SERIAL PRIMARY KEY, firstname TEXT ); CREATE TABLE tblnr2( nr2id SERIAL PRIMARY KEY, nr1id INTEGER REFERENCES tblnr1(nr1id) ); CREATE TABLE tblnr3( nr3id SERIAL

Re: [GENERAL] Foreign Key 'walker'?

2008-11-18 Thread Thomas Kellerer
Erwin Moller, 18.11.2008 15:47: Suppose I want to delete a record in tblnr1. Does Postgres has some command/procedure/function to list tables that have FK constraints on that table (tblnr1) That could be resolved with a query against the INFORMATION_SCHEMA Something like SELECT c.table_name

Re: [GENERAL] Foreign Key 'walker'?

2008-11-18 Thread Erwin Moller
ries van Twisk schreef: On Nov 18, 2008, at 9:47 AM, Erwin Moller wrote: Hi group, Considering following (simplified) example: CREATE TABLE tblnr1( nr1id SERIAL PRIMARY KEY, firstname TEXT ); CREATE TABLE tblnr2( nr2id SERIAL PRIMARY KEY, nr1id INTEGER REFERENCES tblnr1(nr1id) ); CREATE

Re: [GENERAL] Foreign Key 'walker'?

2008-11-18 Thread Erwin Moller
Thomas Kellerer schreef: Erwin Moller, 18.11.2008 15:47: Suppose I want to delete a record in tblnr1. Does Postgres has some command/procedure/function to list tables that have FK constraints on that table (tblnr1) That could be resolved with a query against the INFORMATION_SCHEMA Something

Re: [GENERAL] Foreign Key 'walker'?

2008-11-18 Thread Shane Ambler
ries van Twisk wrote: On Nov 18, 2008, at 9:47 AM, Erwin Moller wrote: Hi group, Considering following (simplified) example: snip Suppose I want to delete a record in tblnr1. Does Postgres has some command/procedure/function to list tables that have FK constraints on that table (tblnr1)

Re: [GENERAL] Foreign Key 'walker'?

2008-11-18 Thread Erwin Moller
Shane Ambler schreef: ries van Twisk wrote: On Nov 18, 2008, at 9:47 AM, Erwin Moller wrote: Hi group, Considering following (simplified) example: snip Suppose I want to delete a record in tblnr1. Does Postgres has some command/procedure/function to list tables that have FK constraints

Re: [GENERAL] Foreign Key 'walker'?

2008-11-18 Thread Pavel Stehule
Hello I used this code CREATE OR REPLACE FUNCTION list_user_tables_sort_depend (owner VARCHAR, revers BOOLEAN) RETURNS SETOF VARCHAR AS ' DECLARE tabulky VARCHAR[]; i INTEGER; opakovat BOOLEAN = ''t''; pom VARCHAR; exportovano VARCHAR[] = ''{}''; r RECORD; mohu_exportovat BOOLEAN; BEGIN