[SQL] UPDATE FROM problem, multiple updates of same row don't seem to work

2004-08-09 Thread David Stanaway
Here is an example: CREATE TABLE tablea( id int PRIMARY KEY, flag int ); CREATE TABLE tableb( aid int REFERENCES tablea(id), flag int ); INSERT INTO tablea VALUES(1,0); INSERT INTO tablea VALUES(2,0); -- Flags for 1st row of tablea - When ORed, should be 7 INSERT INTO tableb VALUES(1,1); IN

Re: [SQL] Exception handling from trigger

2004-08-09 Thread Vlad Dimitriu
I would design those columns as text and enforce value length restrictions with triggers. It's a false problem: I define the data type for a field and want to check his value after the exception that I can't fit larger data into my field. Thank you, Rod, Tom ---(end o

Re: [SQL] Suggestions on storing re-occurring calendar events

2004-08-09 Thread Josh Berkus
Matt, > I can think of two ways, > [a] Using application logic, create a finite number of future > occurrences --- for example, for 10 occurrences, 10 entries into > ftr_cal_events will be created. This seems like an ugly hack. > > [b] Create some new table that will be unioned onto my query to l

Re: [SQL] Exception handling from trigger

2004-08-09 Thread Vlad Dimitriu
Tom Lane wrote: You can't. From a logical perspective this is sensible, because the trigger is handed data already formed into a tuple. If the presented tuple contained a mycolumn value wider than 64 characters then it would not be a legal value of the rowtype (any more than if, say, the column v

Re: [SQL] surrogate keys and replication.

2004-08-09 Thread Josh Berkus
Sad, > Now I solve the GUID problem, with one sequence of IDs on the main server. > The clients ask the server to lease some IDs via special > (application-layer) protocol. Server remembers who and when and what IDs > have took. > (in terms of segments [a..b],[c..d]... etc) Sorry for long delay o

Re: [SQL] Exception handling from trigger

2004-08-09 Thread Tom Lane
Vlad Dimitriu <[EMAIL PROTECTED]> writes: > I would like to handle the exceptions that a database returns. For example, > if a "mycolumn" column is defined as varchar(64), I'd like to catch > if the new.mycolumn is larger than 64 with my own trigger You can't. From a logical perspective this is s

Re: [SQL] Exception handling from trigger

2004-08-09 Thread Rod Taylor
> Is this way of handling exceptions possible in postgres ? > If so, what is the normal way to handle this exceptions, from a > plpgsql/trigger(rule??) perspective ? 8.0 should allow you to do this. 7.4 you need to perform your own checks and catch whether they succeed or fail.

[SQL] Exception handling from trigger

2004-08-09 Thread Vlad Dimitriu
Hello, I would like to handle the exceptions that a database returns. For example, if a "mycolumn" column is defined as varchar(64), I'd like to catch if the new.mycolumn is larger than 64 with my own trigger (for cutoms, internationalized messages, etc ..). So I did, but the database catch this er

[SQL] Suggestions on storing re-occurring calendar events

2004-08-09 Thread Matt Nuzum
Hello, I've got an application and there is something that I just cannot get figured out. I currently store a bunch of events for various calendars in related tables that look like this: ftr_cal_master Column | Type | Modifiers +---+---

Re: [SQL] select

2004-08-09 Thread Christoph Haller
Knut P Lehre wrote: > I have a table with fields: > id A B C D E F > where id is an int4 primary key. > In this table there is information like: > 1 a1 b1 xxx xxx > 2 a1 b1 xxx xxx xxx xxx > 3 a2