Re: [SQL] group by function, make SQL cleaner?

2006-03-16 Thread pgsql
this should work, # SELECT date_trunc('day',endtime),count(*) FROM eg_event where endtime >= '2006-02-01' and endtime < '2006-03-01' GROUP BY 1 ORDER BY 1; hope this helps best regards, Stefan Am Donnerstag, 16. März 2006 06:18 schrieb Bryce Nesbitt: > I've got a working query: >

Re: [SQL] About how to use "exception when ??? then "

2006-03-16 Thread Tom Lane
Emi Lu <[EMAIL PROTECTED]> writes: > Should I install any patches or do anything elese to have SQLSTATE and > SQLERRM work for me? Update to 8.1 ... regards, tom lane ---(end of broadcast)--- TIP 3: Have you checked our ext

Re: [SQL] About how to use "exception when ??? then "

2006-03-16 Thread Emi Lu
On Thursday 16 March 2006 19:32, Emi Lu wrote: |> Errors I got are: |> syntax error at or near "SQLSTATE" at character 2613 |> LINE 58:RAISE NOTICE 'H [%,%]', SQLSTATE, SQL... |> |> |> Should I install any patches or do anything elese to have SQLSTATE and |> SQLERRM work for me?

Re: [SQL] About how to use "exception when ??? then "

2006-03-16 Thread Emi Lu
From the page: "The PL/pgSQL condition name for each error code is the same as the phrase shown in the table, with underscores substituted for spaces. For example, code 22012, DIVISION BY ZERO, has condition name DIVISION_BY_ZERO. Condition names can be written in either upper or lower case

Re: [SQL] About how to use "exception when ??? then "

2006-03-16 Thread Emi Lu
Hi Pedro, |> The place where I have ???, what I should put there please? |> |> e.g., |> 1. WHEN sqlcode = '02000' THEN |> 2. WHEN no_data then |> 3. other ways? |> |> From the 8.0 docs, I am not be able to find Constant values of all |> error codes. |> http://www.postgresql.org/docs/8.

Re: [SQL] About how to use "exception when ??? then "

2006-03-16 Thread Richard Huxton
Emi Lu wrote: exception WHEN ??? THEN The place where I have ???, what I should put there please? e.g., 1. WHEN sqlcode = '02000' THEN 2. WHEN no_data then no_data See ch 35.7.5. "Trapping Errors" for an example 3. other ways? From the 8.0 docs, I am not be able to f

Re: [SQL] executing external command

2006-03-16 Thread A. Kretschmer
am 16.03.2006, um 13:39:57 -0500 mailte [EMAIL PROTECTED] folgendes: > > > Is there a way to execute an external i.e. system command from inside a > pl/pgsql function? You can call a untrusted function (plperlu, plsh, ...) and inside this function you can call system commands. HTH, Andreas --

[SQL] executing external command

2006-03-16 Thread alex-lists-pgsql
Is there a way to execute an external i.e. system command from inside a pl/pgsql function? Alex ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's data

[SQL] About how to use "exception when ??? then "

2006-03-16 Thread Emi Lu
Hello, I am using PostgreSQL 8.0.1. In a function, I try to use exception to catch sql errors: begin begin exception WHEN ??? THEN end; ... end; The place where I have ???, what I should put there please? e.g., 1. WHEN sqlcode = '02000' THEN 2. WHEN no_data then 3

Re: [SQL] group by function, make SQL cleaner?

2006-03-16 Thread Bryce Nesbitt
Tom Lane wrote: In this particular case you could say ... GROUP BY 1 ORDER BY 1; "ORDER BY n" as a reference to the n'th SELECT output column is in the SQL92 spec. (IIRC they removed it in SQL99, but we still support it, and I think most other DBMSes do too.) "GROUP BY n" is *not* in an

R: R: Re: [SQL] schema inspection

2006-03-16 Thread [EMAIL PROTECTED]
> pg_catalog.pg_constraint is your (only?) friend. I have already examintated this table without results. Seem not to be a "human-readable" table :( TIA Roberto Colmegna Tiscali ADSL 4 Mega Flat Naviga senza limiti con l'unica Adsl a 4 Mega di velocità a soli 19,95

Re: [SQL] help with function

2006-03-16 Thread Daniel Caune
> Hello, > > I have 2 tables where each table has a column named "comments" and the > tables are related as a one to many. I want to concatenate all the > comments of the many side to the one side so I wrote the following > plpgsql function to do so. > > > CREATE OR REPLACE FUNCTION fixcomment

Re: [SQL] help with function

2006-03-16 Thread Алексей Заяц
Hello > EXECUTE 'UPDATE sale SET comments = ' || Use PERFORM instead Alexey ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not

[SQL] help with function

2006-03-16 Thread lacou
Hello, I have 2 tables where each table has a column named "comments" and the tables are related as a one to many. I want to concatenate all the comments of the many side to the one side so I wrote the following plpgsql function to do so. CREATE OR REPLACE FUNCTION fixcomments() RETURNS

Re: [SQL] schema inspection

2006-03-16 Thread Achilleus Mantzios
O [EMAIL PROTECTED] έγραψε στις Mar 16, 2006 : > Hi, > > supposing to have a small DB: > > TABLE a ( > id SERIAL PRIMARY KEY > ); > > TABLE b ( > id SERIAL PRIMARY KEY, > idA INTEGER NOT NULL REFERENCES a(id) > ); > > How can I inspect pg_schema/information_schema to "detect" the > rela

[SQL] schema inspection

2006-03-16 Thread [EMAIL PROTECTED]
Hi, supposing to have a small DB: TABLE a ( id SERIAL PRIMARY KEY ); TABLE b ( id SERIAL PRIMARY KEY, idA INTEGER NOT NULL REFERENCES a(id) ); How can I inspect pg_schema/information_schema to "detect" the relation between "b" and "a" via "idB"? TIA Roberto Colmegna