Fwd: [SQL] how to use record type

2001-08-16 Thread Horst Herb
I have difficulties understanding how to use variable of "record" or "row" type. How do I actually insert the variables OLD or NEW or a record type into a table from within a trigger? Like doing the following: drop table th1; create table th1( id serial, text text ); drop table th_audit; crea

Re: [SQL] Nested JOINs

2001-08-16 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > Second, you can't alias a JOINed set of tables; Actually you can, according to my reading of SQL92: ::= [ [ AS ] [] ] | [ AS ] [] | ::

Re: [SQL] Interval FAQ - please review

2001-08-16 Thread Peter Eisentraut
Josh Berkus writes: > 1. The difference between two TIMESTAMPs is always an INTERVAL > '1999-12-30'::TIMESTAMP - '1999-12-11'::TIMESTAMP = '19 days'::INTERVAL > 2. You may add or subtract an INTERVAL to a TIMESTAMP to produce another > TIMESTAMP: > '1999-12-11'::TIMESTAMP + '19 days':

Re: [SQL] Nested JOINs

2001-08-16 Thread Josh Berkus
Oleg, > Below is the query I am trying to execute and the error I am getting: > SELECT media > FROM(dtrowmedia a INNER JOIN dtrow b ON (a.dtrow = b.objectid)) c > INNER JOIN dtcol d ON (c.dtcol = d.objectid) First, the "INNER" keyword is not required on Postgres; you may omit

Re: [SQL] Nested JOINs

2001-08-16 Thread Tom Lane
Oleg Lebedev <[EMAIL PROTECTED]> writes: > What am I doing wrong? Using 7.0, perhaps? The query parses fine for me in 7.1. regards, tom lane ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://www.

Re: [SQL] Re: Interval FAQ - please review

2001-08-16 Thread Josh Berkus
Vivek, > JB> Q. What about TIMESTAMP WITH TIME ZONE? > JB> A. An important topic, and datatype, that I don't want to get > into here. > JB> See the PostgreSQL docs. > > Those docs are lacking an explanation that there is no such thing in > PostgreSQL as a timestamp *without* time zone. Hmmm .

[SQL] Re: Interval FAQ - please review

2001-08-16 Thread Josh Berkus
Jeff, > Why not just include examples of DATEDIFF and DATEADD functions? > For example: > CREATE FUNCTION datediff(timestamp, timestamp) > RETURNS integer AS ' > BEGIN > RETURN $2 - $1; > END; > ' LANGUAGE 'plpgsql'; Not a bad idea. Unfortunately, DATEDIFF & DATEADD are more complicated than th

Re: [SQL] Re: Interval FAQ - please review

2001-08-16 Thread Vivek Khera
> "JB" == Josh Berkus <[EMAIL PROTECTED]> writes: >> Those docs are lacking an explanation that there is no such thing in >> PostgreSQL as a timestamp *without* time zone. JB> Hmmm OK, I'll revise the A: but I *don't* want to go into Time Zone JB> issues in this intro. Any docs I can

[SQL] Nested JOINs

2001-08-16 Thread Oleg Lebedev
Hello, I am trying to execute an SQL query that contains nested joins, but I get parser error for some reason. Below is the query I am trying to execute and the error I am getting: SELECT media FROM(dtrowmedia a INNER JOIN dtrow b ON (a.dtrow = b.objectid)) c INNER JOIN dtcol d

Re: [SQL] Re: Help!!! Trying to "SELECT" and get a tree structure back.

2001-08-16 Thread Mark Stosberg
--CELKO-- wrote: > > >> The table causing my headache: > > CREATE TABLE app_components > (idNUMERIC(7) NOT NULL PRIMARY KEY, > name VARCHAR(100) NOT NULL, > description VARCHAR(500) NULL, > parent_id NUMERIC(7) NULL >REFERENCES app_components(id) >

[SQL] Re: Interval FAQ - please review

2001-08-16 Thread Jeff Eckermann
Why not just include examples of DATEDIFF and DATEADD functions? For example: CREATE FUNCTION datediff(timestamp, timestamp) RETURNS integer AS ' BEGIN RETURN $2 - $1; END; ' LANGUAGE 'plpgsql'; And similarly with DATEADD. You will increase the scope (and length) of your article, but only slightly

[SQL] Re: Interval FAQ - please review

2001-08-16 Thread Vivek Khera
> "JB" == Josh Berkus <[EMAIL PROTECTED]> writes: JB> Q. What about TIMESTAMP WITH TIME ZONE? JB> A. An important topic, and datatype, that I don't want to get into here. JB> See the PostgreSQL docs. Those docs are lacking an explanation that there is no such thing in PostgreSQL as a time

[SQL] Interval FAQ - please review

2001-08-16 Thread Josh Berkus
Folks, Please review this for inaccuracies before I post it to pgsql-newbie and the docs. -Josh FAQ: Working with Dates and Times in PostgreSQL This FAQ is intended to answer the following questions: Q: Where are the DATEADD() and DATEDIFF() functions in PostgreSQL? Q: How do I tell the amou

RE: [SQL] Temp tables being written to disk. Avoidable?

2001-08-16 Thread Paul McGarry
Howdy, > If the temp table doesn't fit in memory, we will have to put it in > backing store somewhere, and a disk is the logical place, right? I > don't see a huge advantage of putting it in memory. We could prevent > WAL writes for temp tables. That would help. Yes, if it won't fit in memory