[SQL] Make Trigger run after completion of ENTIRE transaction

2006-09-19 Thread Henry Ortega
This maybe more of a theoretical question, can you actually make a Trigger run after completion of the entire transaction?   Here's what I have: LOG user   |    startdate   |   enddate   enddate is getting updated by a trigger (on insert or update).   I have the following transaction: BEGIN

[SQL] Fastest way to get max tstamp

2006-08-28 Thread Henry Ortega
This is my table: name | program | effective  |   tstamp   | rate --+-+++-- jdoe | AAA | 2006-07-01 | 2006-07-16 23:42:13.809214 |   20  jdoe | BBB | 2006-07-01 | 2006-07-16 23:42:13.809214 |   20 jdoe | AAA | 2006-

Re: [SQL] Trigger on Insert to Update only newly inserted fields?

2006-08-28 Thread Henry Ortega
tive limit 1);RETURN NEW;END;' LANGUAGE 'plpgsql'; That updates ALL of the records in the table which takes so long.Should I be doing things like this? Or is the update query on my trigger function so wrong?On 8/28/06, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Mon, Aug 2

[SQL] Trigger on Insert to Update only newly inserted fields?

2006-08-28 Thread Henry Ortega
I have a On Insert Trigger that updates one of the columns in that same table.Is there a way for the trigger to run only for the newly inserted records? Instead of all records in the database?E.g.:ID      Start_Date End_Date 001   08-01-2006    002   08-02-2006On Insert/Update, Update End_Date=

Re: [SQL] Best way to do this query..

2006-08-25 Thread Henry Ortega
Yes the data does not change once it is logged.I am quite new to this whole thing, do you mind elaborating moreabout the OLAP data model you mentioned about?On 8/25/06, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: I would assume that your data does not change after it is logged.  If this is the

[SQL] Best way to do this query..

2006-08-25 Thread Henry Ortega
I have the following:name  effective tstamp   rateJohn   01-01-2006 2005-12-07 13:39:07.614945    115.00John   01-16-2006 2006-01-07 13:39:07.614945     125.00 John   01-16-2006 2006-01-09 15:13:04.416935    1885.00 I want the outp

Re: [SQL] Given 02-01-2006 to 02-28-2006, output all days.

2006-02-19 Thread Henry Ortega
ectively obsolete (37 releases old); there are a number of bugfixes and performance improvements in more recent versions.-Owen-Original Message----- From: Henry Ortega [mailto:[EMAIL PROTECTED]]Sent: Friday, February 17, 2006 2:06 PMTo: Owen JacobsonSubject: Re: [SQL] Given 02-01-2006 to 02-28-

[SQL] Given 02-01-2006 to 02-28-2006, output all days.

2006-02-17 Thread Henry Ortega
Is there a real quick way to do a query that will show me all the dates given a startdate and an end date?Given: 02-01-2006 and 02-28-2006it should give me:02-01-200602-02-2006..02-27-2006 02-28-2006Can this be done by a built-in function perhaps?

Re: [SQL] insert only if conditions are met?

2005-09-02 Thread Henry Ortega
.. insert.   if sum(hours)>N then ROLLBACK END; Is that possible? Maybe with just plain SQL? (and one transaction) On 8/31/05, Philip Hallstrom <[EMAIL PROTECTED]> wrote: > On Wed, 2005-08-31 at 12:49 -0400, Henry Ortega wrote:>> Ok. Here's TABLE A>>>> em

Re: [SQL] insert only if conditions are met?

2005-08-31 Thread Henry Ortega
    8    VAC #1 should fail because there is already 8 hours entered as being Worked on 08-15-2005 (same date). Any suggestions? On 8/31/05, Ragnar Hafstað <[EMAIL PROTECTED]> wrote: On Wed, 2005-08-31 at 11:49 -0400, Henry Ortega wrote:> What I am trying to do is> * Insert a record

Re: [SQL] insert only if conditions are met?

2005-08-31 Thread Henry Ortega
What I am trying to do is * Insert a record for EMPLOYEE A to TABLE A IF the sum of the hours worked by EMPLOYEE A on TABLE A is not equal to N Is this possible? On 8/31/05, Michael Fuhr <[EMAIL PROTECTED]> wrote: On Wed, Aug 31, 2005 at 11:09:54AM -0400, Henry Ortega wrote:> I

[SQL] insert only if conditions are met?

2005-08-31 Thread Henry Ortega
Is there a way to insert a record only if a certain condition is met? Something like: insert into employee values('lastname','firstname',8) where (condition here.. select sum(ofsomething) from xx where sum(ofsomething)>0 ) Is this possible at all with just plain SQL?

Re: [SQL] sum but not grouped by?

2005-08-05 Thread Henry Ortega
Is it possible at all to do this without any joins or subselect? On 8/5/05, Mischa Sandberg <[EMAIL PROTECTED]> wrote: > Quoting Henry Ortega <[EMAIL PROTECTED]>: > > > I have the ff data: > > > > id | date | hours > > AAA07

[SQL] sum but not grouped by?

2005-08-05 Thread Henry Ortega
I have the ff data: id | date | hours AAA07-01-2005 3 AAA07-02-2005 4 BBB07-01-2005 6 BBB07-02-2005 2 BBB07-03-2005 7 Would it be possible to get the ff: id | date | hours | id_t

[SQL] Breakdown results by month

2005-08-02 Thread Henry Ortega
I have the ff table: id |total| effective|end_date john 6 01-01-200502-28-2005 john 8 03-01-200506-30-2005 How can I return: id |total| effective|end_date john 6

[SQL] best way to auto-update a field when row is updated

2005-03-10 Thread Henry Ortega
I have the following table FIELD_A| FIELD_B | TSTAMP x y 2005-03-10 14:56:47.456431 TSTAMP = not null

[SQL] drop view even with dependencies?

2005-03-07 Thread Henry Ortega
Is there a way to drop a VIEW in postgres without the need to drop all the dependencies? VIEW 3 | VIEW 2 | VIEW 1 In my case, VIEW 3 depends on VIEW 2, and VIEW 2 depends on VIEW 1. Is there a way to drop VIEW 3 without dropping VIEW 1 and 2? I tried CREATE OR REPLACE VIEW but replace wi