Re: [SQL] need some help with a delete statement

2003-07-01 Thread Matthew Hixson
On Monday, June 30, 2003, at 12:00 PM, scott.marlowe wrote: On Mon, 30 Jun 2003, Matthew Hixson wrote: On Monday, June 30, 2003, at 05:06 AM, scott.marlowe wrote: On Fri, 27 Jun 2003, Matthew Hixson wrote: Hi, I have a bunch of records that I need to delete from our database. These records re

[SQL] Immutable attributes?

2003-07-01 Thread Troels Arvin
Hello, I have a table like this: create table test ( "test_id" serial primary key, "created" timestamp with time zone default current_timestamp check(created = current_timestamp), "some_datum" int not null ); My question concerns the "created" attribute: I want this to reflect wh

Re: [SQL] need some help with a delete statement

2003-07-01 Thread scott.marlowe
On Tue, 1 Jul 2003, Matthew Hixson wrote: > > On Monday, June 30, 2003, at 12:00 PM, scott.marlowe wrote: > > > On Mon, 30 Jun 2003, Matthew Hixson wrote: > > > >> On Monday, June 30, 2003, at 05:06 AM, scott.marlowe wrote: > >> > >>> On Fri, 27 Jun 2003, Matthew Hixson wrote: > >>> > Hi, I

[SQL] Failed to initialize lc_messages to ''

2003-07-01 Thread Rado Petrik
Hi, I have problem start database. 1) I compile postgresql 7.3.3 with parameters. ./configure --enable-nls --enable-multibyte --enable-locale 2) Then set env variables , export LANG=cs_CZ 3) initdb -D /my_cz_db Initdb returned : The files belonging to this database system will be owned b

Re: [SQL] CREATE SEQUENCE fails in plpgsql function

2003-07-01 Thread Tom Lane
Erik Erkelens <[EMAIL PROTECTED]> writes: > DECLARE > new_max_records ALIAS FOR $1; > BEGIN > CREATE SEQUENCE my_sequence MAXVALUE new_max_records CYCLE; > ERROR: parser: parse error at or near "$1" at character 39 You'll need to use EXECUTE to construct and execute that

Re: [SQL] help with "delete joins"

2003-07-01 Thread Robert Treat
On Mon, 2003-06-30 at 20:35, Josh Berkus wrote: > Robert, > > > delete * from foo where not (foo.a = bar.a and foo.b=bar.b and > > foo.c=bar.c) ; > > > > so i end up with > > > > postgres=# select * from foo; > > a | b | c | d > > ---+---+---+--- > > 1 | 2 | 4 | A > > 4 | 5 | 6 | b > > (2

Re: [SQL] CREATE SEQUENCE fails in plpgsql function

2003-07-01 Thread Rod Taylor
On Tue, 2003-07-01 at 13:33, Tom Lane wrote: > Erik Erkelens <[EMAIL PROTECTED]> writes: > > DECLARE > > new_max_records ALIAS FOR $1; > > BEGIN > > CREATE SEQUENCE my_sequence MAXVALUE new_max_records CYCLE; > > > ERROR: parser: parse error at or near "$1" at character 3

Re: [SQL] Failed to initialize lc_messages to ''

2003-07-01 Thread Tom Lane
Rado Petrik <[EMAIL PROTECTED]> writes: > export LANG=cs_CZ > Failed to initialize lc_messages to '' > FATAL: invalid value for option 'LC_MESSAGES': 'cs_CZ' Evidently your platform doesn't have complete support for setting locale to cs_CZ. Try it again with a combination like export L

[SQL] help with rpm script

2003-07-01 Thread Craig Jensen
Hello, I am building an rpm for Mitle SME (a scaled down redhat 7.3) and have all functions working except: I need to have the rpm when installed create a database and a user with privilege to that database. These are the command functions I need to execute within the rpm... # service postgres

Re: [SQL] help with "delete joins"

2003-07-01 Thread Bruno Wolff III
On Mon, Jun 30, 2003 at 18:26:38 -0400, Robert Treat <[EMAIL PROTECTED]> wrote: > what i want to do is: > > delete * from foo where not (foo.a = bar.a and foo.b=bar.b and > foo.c=bar.c) ; For the case without not (which appears to be what you really want) you can pretty much do this. See below

Re: [SQL] Immutable attributes?

2003-07-01 Thread Troels Arvin
Hello, On Tue, 2003-07-01 at 18:28, Robert Treat <[EMAIL PROTECTED]> wrote: > > want to make sure that the "crated" attribut for a tuple is > > not changed once it has been set. > > > > I'm thinking about implementing it through a trigger, but is there a > > better way to create such "immutable"

Re: [SQL] Failed to initialize lc_messages to ''

2003-07-01 Thread Peter Eisentraut
It seems that one of the other locale variables (LC_ALL?) still contains values that are not accepted. Note that initdb reports about cs_CS, which is not what you set. Rado Petrik writes: > Hi, > I have problem start database. > > 1) I compile postgresql 7.3.3 with parameters. > > ./configure -

Re: [SQL] Immutable attributes?

2003-07-01 Thread Robert Treat
On Tue, 2003-07-01 at 05:59, Troels Arvin wrote: > Hello, > > I have a table like this: > > create table test ( > "test_id" serial primary key, > "created" timestamp with time zone > default current_timestamp > check(created = current_timestamp), > "some_datum" int not null > ); >

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Greg Stark
Josh Berkus <[EMAIL PROTECTED]> writes: > Stefan, > > > I know the LEAST and GREATEST functions are not part > > of standard SQL, but they sure were handy where I came > > from (Oracle-land). > > Um, what's wrong with MAX and MIN, exactly? MAX and MIN are single-parameter aggregate functions. L

Re: [SQL] need some help with a delete statement

2003-07-01 Thread Matthew Hixson
On Tuesday, July 1, 2003, at 05:47 AM, scott.marlowe wrote: what does the output of psql say if you have the /timing switch on? # select cart_id from carts except (select distinct cart_id from cart_contents) limit 1; cart_id - 2701 (1 row) Time: 10864.89 ms # explain analyze delete f

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Bruno Wolff III
On Tue, Jul 01, 2003 at 12:29:16 -0400, Greg Stark <[EMAIL PROTECTED]> wrote: > > SELECT greatest(a,b) FROM bar > > would return one tuple for every record in the table with a single value > representing the greater of bar.a and bar.b. You can do this with case. SELECT CASE WHEN a >= b THEN a

Re: [SQL] need some help with a delete statement

2003-07-01 Thread scott.marlowe
On Tue, 1 Jul 2003, Matthew Hixson wrote: > > On Tuesday, July 1, 2003, at 05:47 AM, scott.marlowe wrote: > >>> > >>> what does the output of psql say if you have the /timing switch on? > >> > >> # select cart_id from carts except (select distinct cart_id from > >> cart_contents) limit 1; > >>

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Joe Conway
Greg Stark wrote: SELECT greatest(a,b) FROM bar would return one tuple for every record in the table with a single value representing the greater of bar.a and bar.b. You could define your own functions to do this but it would be tiresome to define one for every datatype. In 7.4devel (just starting

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Stefan Bill
> Um, what's wrong with MAX and MIN, exactly? MIN and MAX are aggregate functions, LEAST and GREATEST are not. See the examples on the following table: foo A B - - 1 4 2 3 3 2 > SELECT LEAST(a, b), GREATEST(a, b) FROM foo; LEAST(a, b) GREATEST(a, b) --- -- 1 4 2

[SQL] mergejoin error message executing in 7.2

2003-07-01 Thread kevin rowe
hi there, I have a problem trying to execute a complex query that was designed in 7.3.2 to a machine running 7.2.x this is the error message FULL JOIN is only supported with mergejoinable join conditions this is the source string for a jdbc prepared statement. (it has ordering clause added at t

[SQL] passing a record as a function argument in pl/pgsql

2003-07-01 Thread Alon Noy
Is it possible?   From what I tried it is possible to create such a function but it is not possible to call it ?! Can anyone provide an example?   Tnx.  

Re: [SQL] mergejoin error message executing in 7.2

2003-07-01 Thread Tom Lane
"kevin rowe" <[EMAIL PROTECTED]> writes: > I have a problem trying to execute a complex query that was designed in > 7.3.2 to a machine running 7.2.x > this is the error message > FULL JOIN is only supported with mergejoinable join conditions Nested FULL JOINs don't work in 7.2.*. The fix is not

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Joe Conway
Joe Conway wrote: In 7.4devel (just starting beta) you can do this: Actually to correct myself, we just started "feature freeze" for 7.4, with beta planned to start on or about July 15th. Sorry for any confusion caused. Joe ---(end of broadcast)--

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Josh Berkus
Joe, > create or replace function greatest(anyelement, anyelement) returns > anyelement as 'select case when $1 > $2 then $1 else $2 end' language > 'sql'; Way cool. I'd have to imagine that it would blow up if you did this, though: select greatest ( 512, now() ); With an "Operator is not defi

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Joe Conway
Josh Berkus wrote: create or replace function greatest(anyelement, anyelement) returns anyelement as 'select case when $1 > $2 then $1 else $2 end' language 'sql'; Way cool. I'd have to imagine that it would blow up if you did this, though: select greatest ( 512, now() ); With an "Operator is no

Re: [SQL] passing a record as a function argument in pl/pgsql

2003-07-01 Thread Joe Conway
Alon Noy wrote: From what I tried it is possible to create such a function but it is not possible to call it ?! Can anyone provide an example? create table foo (f1 int, f2 text); insert into foo values(1,'a'); insert into foo values(2,'b'); insert into foo values(3,'c'); create or replace function

[SQL] columnar format

2003-07-01 Thread Don Soledad
good day! i would like to ask for the sql statement to the output: ITEM DESC Jan Feb Mar Apr ... Sep Total xx 999 999 999 999 ... 999 9,999 where "Jan" column is sum of all "x" items purchased on Jan, "Feb" column as sum of Feb purchases, and so on up to "Sep", and "Tot

[SQL] Timeout for lock table

2003-07-01 Thread Jonathan Man
Dear All,   I begin a transaction. I then execute a SQL command "SELECT FOR UPDATE" to lock some records on the first session. Besides, I also lock some rows using the same method on the second session. Is it possible to return an error message to indicate that some records were locked by an

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Ang Chin Han
Greg Stark wrote: MAX and MIN are single-parameter aggregate functions. LEAST and GREATEST are two-parameter (though in postgres they could be defined for 3 and more parameters) scalar functions. If LEAST and GREATEST can accept any number of parameters, wouldn't it make sense to code it like the

[SQL] Break referential integrity.

2003-07-01 Thread Rudi Starcevic
Hi, I know that if you have a trigger and function then drop/replace the function the trigger needs to be drop/replaced too so that it can see the new function. Is it the same for Ref. Integ. on table's too ? If table B's foreign key references table A and you drop/replace table A then the refe

Re: [SQL] Break referential integrity.

2003-07-01 Thread Stephan Szabo
On Wed, 2 Jul 2003, Rudi Starcevic wrote: > Hi, > > I know that if you have a trigger and function then drop/replace the > function the trigger needs > to be drop/replaced too so that it can see the new function. > > Is it the same for Ref. Integ. on table's too ? > > If table B's foreign key refe

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Tom Lane
Ang Chin Han <[EMAIL PROTECTED]> writes: > If LEAST and GREATEST can accept any number of parameters, wouldn't it > make sense to code it like the way COALESCE works, rather than defining > a function for it? This way we don't need define all the various > functions with different types. But CO

[SQL] About Postgresql Service on SUN OS

2003-07-01 Thread Atul Pedgaonkar
Hello, Any one who knows, how to start the postgresql service on sun solaris server. Please help me in this regards. Thank you. Regards, Atul Pedgaonkar ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Ang Chin Han
Tom Lane wrote: But COALESCE is a special feature hard-wired into the parser. There's no free lunch --- you pay for your extensibility somewhere. That's what I'm suggesting: hard-wiring LEAST and GREATEST into the parser. 7.5, maybe? The question is: is it worth hard-wiring vs functions? (time

[SQL] SQL

2003-07-01 Thread Jonathan Man
Dear All,   May I execute a SQL to find out user's information (e.g. user id or ip address) who are connecting to a database?   THX!!     JMAN  

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Tom Lane
Ang Chin Han <[EMAIL PROTECTED]> writes: > I'd say we need to have LEAST and GREATEST at least somewhere in contrib > (as functions) if not core, to make transition from other RDBMS to > postgresql easier. > A brief test shows that we would incur quite a performance penalty (I > compared COALESC