[SQL] foreign keys with on delete cascade and triggers

2006-01-11 Thread Dirk Jagdmann
; END; $$ language plpgsql; create trigger b_del before delete on b for each row execute procedure f(); insert into a values(5); insert into b values(5); delete from a where i=5; select * from a; -- 0 rows select * from b; -- 1 row containing '5' -- ---> Dirk Jagdmann > http://cubic.

Re: [SQL] foreign keys with on delete cascade and triggers

2006-01-12 Thread Dirk Jagdmann
know if the current order of deletions in PostgreSQL is intended in the top-down way or if that could be changed? -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] table constraint + INSERT

2006-05-18 Thread Dirk Jagdmann
ma I'd recommend using a view to calculate the R_RETAILPRICE column: CREATE TABLE PART ( P_PARTKEY int4 NOT NULL, CONSTRAINT PART_PRIMARY PRIMARY KEY (P_PARTKEY) ); create view PARTV as select P_PARTKEY, 9 + P_PARTKEY::numeric / 10 + P_PARTKEY::numeric / 100 as from PART; -- ---> Dirk Ja

Re: [SQL] table constraint + INSERT

2006-05-18 Thread Dirk Jagdmann
read: create view PARTV as select P_PARTKEY, 9 + P_PARTKEY::numeric / 10 + P_PARTKEY::numeric / 100 as P_RETAILPRICE from PART; -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 4:

Re: [SQL] keeping last 30 entries of a log table

2006-06-20 Thread Dirk Jagdmann
of 30 Entries in this table anyway. So even the most unoptimized select and delete combinations should be very fast... -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 3: Have y

Re: [SQL] Best way to simulate Booleans

2009-07-07 Thread Dirk Jagdmann
cle should look similar to PostgreSQL use the char(1). If you have lots of application code the int is probably better, since you can just use the created programming language variable (presumably an integer as well) in your programming language expressions (if, while). -- ---> Dirk Jagd

Re: [SQL] please help me on regular expression

2010-02-03 Thread Dirk Jagdmann
.5' ~ e'\\d+\\.\\d+'; ?column? -- t -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] optimal insert

2006-10-08 Thread Dirk Jagdmann
some plpgsql code. -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] optimal insert

2006-10-10 Thread Dirk Jagdmann
Hello Aaron, thank you for your suggestion. I will have to think if something similar would be of any benefit for my data. -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 1: i

Re: [SQL] optimal insert

2006-10-10 Thread Dirk Jagdmann
Hello George, And don't forget that \COPY and especially COPY are usually much faster (and, IMHO, easier to compose/maintain) than gobs of INSERTs. I did not forget, but my application uses embedded SQL (with the epcg preprocessor) and I don't think it can handle COPYs :( --

Re: [SQL] storing access rights in a postgres database

2006-10-10 Thread Dirk Jagdmann
ith the standard foreign key triggers/functions so you would have to write your own plpgsql triggers if this is a mandatory requirement. -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

[SQL] MD5 sums of large objects

2007-04-08 Thread Dirk Jagdmann
create the hashsums. -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column

Re: [SQL] MD5 sums of large objects

2007-04-08 Thread Dirk Jagdmann
stable strict; comment on FUNCTION md5(id oid) is 'Calculates the md5 sum of a large object.'; I vote for this function beeing included either somewhere in the contrib directories, as you often don't need the full power of pgcrypto is md5 suffices for your hashing needs. -- ---

Re: [SQL] MD5 sums of large objects

2007-04-09 Thread Dirk Jagdmann
y application and if I'm satisfied with this solution I'll post something on pgsql-hackers of pgfoundry. -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(end of broadcast)--- TIP 7: You can help sup

Re: [SQL] EXECUTE 'EXECUTE ...' or how to use dynamic prepared statements ?

2007-09-04 Thread Dirk Jagdmann
avoid using explicit for/loop constructs in your stored procedures if the action can be solved by a single SQL statement, because the optimizer can make a better execution plan. -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org ---(e

Re: [SQL] Composite UNIQUE across two tables?

2008-03-11 Thread Dirk Jagdmann
_unique_username before update on sites for each row execute procedure sites_check_unique_username(); -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Composite UNIQUE across two tables?

2008-03-12 Thread Dirk Jagdmann
her way. > Thank you for your taking the time to write this up, it's very much > appreciated. Most people reading this list like to think about/learn from other people's problems. -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org -- S

Re: [SQL] Insert a space between each character

2008-10-08 Thread Dirk Jagdmann
rbaz', E'(.)(?!$)', E'\\1 ', 'g'); regexp_replace --- f o o b a r b a z (1 row) -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Add: Special sort querstion

2009-04-01 Thread Dirk Jagdmann
uld work, I'm interested in a working example code :-) -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Add: Special sort querstion

2009-04-01 Thread Dirk Jagdmann
uld work, I'm interested in a working example code :-) -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] ENUM vs DOMAIN vs FKyed loookup table

2009-04-12 Thread Dirk Jagdmann
nteger, code_value integer, code_type text not null references code_type ); -- ---> Dirk Jagdmann > http://cubic.org/~doj -> http://llg.cubic.org -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql