Re: [SQL] Selecting sample data from large tables.

2004-06-04 Thread Greg Stark
Joseph Turner [EMAIL PROTECTED] writes: I have a table with a decent number of rows (let's say for example a billion rows). I am trying to construct a graph that displays the distribution of that data. However, I don't want to read in the complete data set (as reading a billion rows

[SQL] Difference between two times as a numeric value in a stored procedure.

2004-06-04 Thread Stijn Vanroye
Hello List, I am writing two stored procedure which alternatively returns the dayhours and nighthours of two times. (nighthours are considered between 00:00 and 06:00). As an example here is the getdayhours function:

[SQL] ERROR: duplicate key violates unique constraint

2004-06-04 Thread Khairul Azmi
Need help on this problem. I've created two functions. The function should perform a few sql processes. The problem is I got different results when I call the function and when I manually run the sql command. I'm using postgresql 7.4.2. The two functions involved are CREATE TABLE

[SQL] trigger data

2004-06-04 Thread hook
Does any one have any reasonably simple application example that uses or parses the HeapTuple (PointerGetDatum(rettuple) ) returned by 'c' trigger function? Also, what is the syntax to parse the HeapTuple within the trigger function? thanks ---(end of

Re: [SQL] Difference between two times as a numeric value in a stored procedure. [Scanned]

2004-06-04 Thread Stijn Vanroye
Stijn Vanroye [EMAIL PROTECTED] writes: I can't seem to find a way to substract two time values (or timestamp values) and get a numeric/float value. I always get the INTERVAL datatype. extract(epoch from interval) may help. regards, tom lane Indeed. I think I

Re: [SQL] Difference between two times as a numeric value in a stored procedure.

2004-06-04 Thread Bruno Wolff III
On Fri, Jun 04, 2004 at 10:11:57 +0200, Stijn Vanroye [EMAIL PROTECTED] wrote: The working of the functions is not the problem, but the return type is. I can't seem to find a way to substract two time values (or timestamp values) and get a numeric/float value. I always get the INTERVAL

[SQL] dynamic rules?

2004-06-04 Thread Christopher Dedels
Is it possible to create a select rule that returns results depending on a where clause in the original select statement? For Example (oversimplified): CREATE TABLE one (data int); CREATE TABLE two (data int); I make the query: SELECT data FROM number WHERE type=1; If the type is 1 (type=1) I

Re: [SQL] dynamic rules?

2004-06-04 Thread Bruno Wolff III
On Thu, Jun 03, 2004 at 21:32:47 -0700, Christopher Dedels [EMAIL PROTECTED] wrote: Is it possible to create a select rule that returns results depending on a where clause in the original select statement? For Example (oversimplified): CREATE TABLE one (data int); CREATE TABLE two (data

Re: [SQL] ERROR: duplicate key violates unique constraint

2004-06-04 Thread Josh Berkus
Khairul, Need help on this problem. I've created two functions. The function should perform a few sql processes. The problem is I got different results when I call the function and when I manually run the sql command. I'm using postgresql 7.4.2. Hmmm ... that's odd. I remember getting this

Re: [SQL] Difference between two times as a numeric value in a stored procedure.

2004-06-04 Thread Tom Lane
Stijn Vanroye [EMAIL PROTECTED] writes: I can't seem to find a way to substract two time values (or timestamp values) and get a numeric/float value. I always get the INTERVAL datatype. extract(epoch from interval) may help. regards, tom lane

Re: [SQL] dynamic rules?

2004-06-04 Thread Bruno Wolff III
On Fri, Jun 04, 2004 at 09:16:04 -0700, Christopher Dedels [EMAIL PROTECTED] wrote: Bruno, Thanks for the response. You should keep the discussion copied to the list as long as it is on topic. That way other people can help out. I was wondering if I was possible to union the tables if

[SQL] ANSI SQL-99 SYNTAX and WITH

2004-06-04 Thread Rein Petersen
Good morning,afternoon, and eveningEveryone, My research into PostgreSQL documentation has yet to yeild any information about PostgreSQL's support of ANSI SQL-99 syntax, and in particular, the "WITH" clause - which if I understand correctly,allows recursive joins in simple syntax without

Re: [SQL] ANSI SQL-99 SYNTAX and WITH

2004-06-04 Thread Yasir Malik
Good morning,afternoon, and evening Everyone, My research into PostgreSQL documentation has yet to yeild any information about PostgreSQL's support of ANSI SQL-99 syntax, and in particular, the WITH clause - which if I understand correctly, allows recursive joins in simple syntax without

Re: [SQL] ANSI SQL-99 SYNTAX and WITH

2004-06-04 Thread Bruno Wolff III
On Fri, Jun 04, 2004 at 15:37:41 -0400, Rein Petersen [EMAIL PROTECTED] wrote: My research into PostgreSQL documentation has yet to yeild any information about PostgreSQL's support of ANSI SQL-99 syntax, and in particular, the WITH clause - which if I understand correctly, allows recursive

Re: [SQL] ANSI SQL-99 SYNTAX and WITH

2004-06-04 Thread Tom Lane
Bruno Wolff III [EMAIL PROTECTED] writes: Rein Petersen [EMAIL PROTECTED] wrote: As you may have guessed, I hope PostgreSQL currently supports the WITH clause syntax or, will at least support it imminently. Postgres doesn't currently support that. Someone was working on it a while back, but