Re: [SQL] CREATE TABLE AS inside of a function

2006-07-24 Thread Stephan Szabo
On Mon, 24 Jul 2006, Kevin Nikiforuk wrote: > So, I've changed my code as Erik suggested: > > CREATE OR REPLACE FUNCTION rgio() RETURNS INTEGER as $$ > DECLARE > lv RECORD; > > BEGIN > FOR lv IN SELECT DISTINCT rg > FROM ldevrg > LOOP > >

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Bruno Wolff III
On Mon, Jul 24, 2006 at 18:53:20 +0100, Richard Jones <[EMAIL PROTECTED]> wrote: > > I'm not sure what this means. By "data integrity" I just meant that I > don't want applications to create page_contents.link_name fields which > could point to non-existent URLs. (A URL consists of a particula

Re: [SQL] CREATE TABLE AS inside of a function

2006-07-24 Thread Kevin Nikiforuk
So, I've changed my code as Erik suggested: CREATE OR REPLACE FUNCTION rgio() RETURNS INTEGER as $$ DECLARE lv RECORD; BEGIN FOR lv IN SELECT DISTINCT rg FROM ldevrg LOOP EXECUTE 'CREATE TABLE rgio_' || $lv || ' AS

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Richard Huxton
Richard Jones wrote: Simplified schema: create table hosts ( id serial primary key, hostname text not null ); create table pages ( id serial primary key, hostid int not null references hosts (id), url text not null, unique (hostid, url) ); create table page_co

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Richard Jones
On Mon, Jul 24, 2006 at 12:26:15PM -0500, Aaron Bono wrote: > On 7/22/06, Richard Jones <[EMAIL PROTECTED]> wrote: > > create table hosts ( > >id serial primary key, > >hostname text not null > > ); > > > > create table pages ( > >id serial primary key, > >hostid int not null ref

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Richard Jones
On Mon, Jul 24, 2006 at 12:51:48PM -0500, Bruno Wolff III wrote: > On Mon, Jul 24, 2006 at 09:59:07 +0100, > Richard Jones <[EMAIL PROTECTED]> wrote: > > On Sun, Jul 23, 2006 at 01:32:37PM -0500, Bruno Wolff III wrote: > > > On Sat, Jul 22, 2006 at 14:32:57 +0100, > > > Richard Jones <[EMAIL PR

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Bruno Wolff III
On Mon, Jul 24, 2006 at 09:59:07 +0100, Richard Jones <[EMAIL PROTECTED]> wrote: > On Sun, Jul 23, 2006 at 01:32:37PM -0500, Bruno Wolff III wrote: > > On Sat, Jul 22, 2006 at 14:32:57 +0100, > > Richard Jones <[EMAIL PROTECTED]> wrote: > > > > > > Now I want to add a column to page_contents,

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Aaron Bono
On 7/22/06, Richard Jones <[EMAIL PROTECTED]> wrote: Simplified schema:  create table hosts (id serial primary key,hostname text not null  );  create table pages (id serial primary key,hostid int not null references hosts (id), url text not null,unique (hostid, url)  );  cre

Re: [SQL] System catalog table privileges

2006-07-24 Thread Aaron Bono
On 7/21/06, Hilary Forbes <[EMAIL PROTECTED]> wrote: Aaron Thanks for this one - I had actually wondered about doing that but the trouble is that they say that they need up to the minute reports not "as of last night".  Indeed, I do have another app where I do just that because I find that reports

Re: [SQL] Primary key constraint violation without error?

2006-07-24 Thread Michael Fuhr
On Mon, Jul 24, 2006 at 02:12:39PM +0200, Mario Splivalo wrote: > Now I run the function again: > > l_netsms=# select punimessages(); > NOTICE: Ubacili smo za usera 4162. > NOTICE: Ubacili smo za usera 4161. > NOTICE: Ubacili smo za usera 4160. > NOTICE: Ubacili smo za usera 4159. > NOTICE: U

Re: [SQL] Primary key constraint violation without error?

2006-07-24 Thread Richard Huxton
Mario Splivalo wrote: Actually it's not violation, but I get no error message on violating it... CREATE OR REPLACE FUNCTION punimessages() RETURNS bool AS $BODY$ declare userId users%ROWTYPE; begin truncate table mes_del; ^^^ This at the star

[SQL] Primary key constraint violation without error?

2006-07-24 Thread Mario Splivalo
Actually it's not violation, but I get no error message on violating it... The story is like this. I have few tables from where I extract messageIds for particular users. Then, last 100 messages for each user I transfer to spare table, to do something with that. That spare table has strange behavi

Re: [SQL] Rows with exclusive lock

2006-07-24 Thread Martin Marques
On Sun, 23 Jul 2006, Alvaro Herrera wrote: Martin Marques escribió: After the SELECT FOR UPDATE other transactions can still see the locked rows. I want a read/write lock, so no one can access does rows. SELECT FOR UPDATE acquires an exclusive lock, but other transactions must try to acquire

Re: [SQL] Referential integrity (foreign keys) across multiple tables

2006-07-24 Thread Richard Jones
On Sun, Jul 23, 2006 at 01:32:37PM -0500, Bruno Wolff III wrote: > On Sat, Jul 22, 2006 at 14:32:57 +0100, > Richard Jones <[EMAIL PROTECTED]> wrote: > > > > Now I want to add a column to page_contents, say called link_name, > > which is going to reference the pages.url column for the particular