Re: [SQL] Some more weird NULL behavior

2002-11-08 Thread Stephan Szabo
On Fri, 8 Nov 2002, Ludwig Lim wrote: > Hi: > > I tried the following: > CREATE TABLE x( >a NUMERIC(5,0), >b VARCHAR(5) > ); > > CREATE TABLE y( >a INTEGER, >b VARCHAR(5) > ); > > INSERT INTO x(b) VALUES ('LUDZ'); > INSERT INTO y(b) VALUES ('TEST')

Re: [SQL] More than 1 trigger of the same kind

2002-11-08 Thread Tom Lane
Stephan Szabo <[EMAIL PROTECTED]> writes: >> Does having more than 1 trigger of the same kind >> produces some side effect? I mean is the order of the >> trigger firing is always the same? > IIRC the triggers are fired in name order. That's true as of 7.3; I do not think prior versions promised a

[SQL] Some more weird NULL behavior

2002-11-08 Thread Ludwig Lim
Hi: I tried the following: CREATE TABLE x( a NUMERIC(5,0), b VARCHAR(5) ); CREATE TABLE y( a INTEGER, b VARCHAR(5) ); INSERT INTO x(b) VALUES ('LUDZ'); INSERT INTO y(b) VALUES ('TEST'); SELECT x.b,y.b FROM x,y WHERE x.a=y.a returns zero rows.

Re: [SQL] More than 1 trigger of the same kind

2002-11-08 Thread Stephan Szabo
On Fri, 8 Nov 2002, Ludwig Lim wrote: > Hi: > >Can I have more than 1 trigger of same kind on one > table? (i.e. 2 AFTER INSERT TRIGGER) on 1 table? Yes. >Does having more than 1 trigger of the same kind > produces some side effect? I mean is the order of the > trigger firing is always t

[SQL] More than 1 trigger of the same kind

2002-11-08 Thread Ludwig Lim
Hi: Can I have more than 1 trigger of same kind on one table? (i.e. 2 AFTER INSERT TRIGGER) on 1 table? I'm planning to split up a large trigger function (about 200 lines) into 2 seperate triggers. Since PL/PGSQL functions cannot accepts OPAQUE as arguments, I have to create 2 triggers inst

[SQL] Passing OLD/NEW as composite type PL/PGSQL

2002-11-08 Thread Ludwig Lim
Hi: Can I pass the the variables OLD and NEW (type OPAQUE) to another function is expecting a composite type as parameter? Are opaque considered as composite type? Thank you in advance, ludwig. __ Do you Yahoo!? New DSL Internet Access from

Re: [SQL] Permission on insert rules

2002-11-08 Thread Bruce Momjian
Josh Berkus wrote: > > Luis, > > > Just a question. > > I'm writing some rules to insert/update some data in my database, and I > > gave all the privileges on that view to the user, and only select on the > > tables. > > When that user inserts data using the view, I thought that was user > > p

Re: [SQL] Permission on insert rules

2002-11-08 Thread Josh Berkus
Luis, > Just a question. > I'm writing some rules to insert/update some data in my database, and I > gave all the privileges on that view to the user, and only select on the > tables. > When that user inserts data using the view, I thought that was user > postgres that will do the rest ! But I

Re: [SQL] Time difference without intervals

2002-11-08 Thread Tom Lane
Roberto Mello <[EMAIL PROTECTED]> writes: > Is there any way to make a timestamp difference operation not return an > interval? I'd like to get hours, minutes and seconds only, not the "1 day" > or whatnot. I think your complaint is not that you get an interval, but that you want it displayed diff

Re: [SQL] changing numeric into int

2002-11-08 Thread Robert Treat
There is no way to do this short of maybe hacking at the system tables, and even then thats likely to cause problems. If you cant recreate the table, your best bet is to create two new columns and copy the data in, delete the data from the old columns, rename the columns accordingly, and perhaps ad

Re: [SQL] Time difference without intervals

2002-11-08 Thread Bruno Wolff III
On Fri, Nov 08, 2002 at 11:20:02 -0700, Roberto Mello <[EMAIL PROTECTED]> wrote: > > Is there any way to make a timestamp difference operation not return an > interval? I'd like to get hours, minutes and seconds only, not the "1 day" > or whatnot. When you take a difference of two timestamps, y

[SQL] Time difference without intervals

2002-11-08 Thread Roberto Mello
I saw this question on another PG mailing list, and I don't know how to answer. I've tried casting the interval to a timestamp, but that doesn't seem to be supported in 7.2. Does anyone have an answer? Is there any way to make a timestamp difference operation not return an interval? I'd like to ge

[SQL] Permission on insert rules

2002-11-08 Thread Luis Sousa
Hello everybody, Just a question. I'm writing some rules to insert/update some data in my database, and I gave all the privileges on that view to the user, and only select on the tables. When that user inserts data using the view, I thought that was user postgres that will do the rest ! But I g

Re: [SQL] pg_dump, no inserts but \copy?

2002-11-08 Thread Bruce Momjian
There is no way to force INSERT unless you are telling it to do that somehow. Are you perhaps using -d. That causes inserts too? What is your command line for the dump? --- Joost Witteveen wrote: > I remember the pg_dump

Re: [SQL] cast lo to oid

2002-11-08 Thread Nekta Katz
I didn't realize there was a contrib/lo, I only created the lo type as described in the psqlodbc faq. I have now installed the contrib/lo and everything is working fine. I am using PG version 7.2 thanks. From: Tom Lane <[EMAIL PROTECTED]> To: "Nekta Katz" <[EMAIL PROTECTED]> CC: [EMAIL PROTE

[SQL] pg_dump, no inserts but \copy?

2002-11-08 Thread Joost Witteveen
I remember the pg_dump command creating dumps with \copy in them But for some reason (upgrade of postgresql?) it now started to create dumps with inserts, as though I gave it the --inserts argument (but I don't). man pg_dump explains how to make it use inserts, but I cannot find anywhere how to ma

Re: [SQL] Alter table

2002-11-08 Thread Daniel Schuchardt
I think 7.3 has this feature. Daniel ""Rachel.Vaudron"" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:Pine.LNX.4.33.0211080811160.12232-10@;lazaret.unice.fr... > Hi, > > I wonder if it is possible to remove a field of a table ? > I haven't found anything about this into the reference manual

[SQL] get source table.field name from view's field

2002-11-08 Thread Prime Ho
Hi, Firstly , sorry about my poor english, I'll do my best to explain what I want. Actually, in most cases, We do query via view, in order to improve the query speed, we'll create index in physical table field that is mapped in view's where statement. So, I got an idea to store view statement in a

Re: [SQL] query optimization question

2002-11-08 Thread Masaru Sugawara
On Thu, 07 Nov 2002 09:57:27 +0100 Christoph Haller <[EMAIL PROTECTED]> wrote: > > ORDER BY proj.project_id ; > > What about simply replacing ORDER BY proj.project_id ; by > GROUP BY project_id, marketing_name ; You're right. Thanks a lot. Regards, Masaru Sugawara

Re: [SQL] query optimization question

2002-11-08 Thread Christoph Haller
> > This is the final query, can anyone see anything wrong with it?: > SELECT projects.project_id, projects.marketing_name, > COUNT(lots.lot_id) AS def_count, > COUNT(CASE WHEN dt.days_old_start_date < {d '2002-10-08'} > THEN lots.lot_id ELSE NULL END >

Re: [SQL] Generating a cross tab (pivot table)

2002-11-08 Thread Ludwig Lim
--- Christoph Haller <[EMAIL PROTECTED]> wrote: > It's obvious this approach is most inflexible. > As soon as there is a new vendor, one has to > re-write the query and add > SUM(CASE vendor WHEN 'mr. new' THEN ... , > > In an advanced example it is shown how to deal with > cross tabs in > gener

Re: [SQL] PLpgSQL FOR IN EXECUTE question

2002-11-08 Thread Christoph Haller
Thanks to Josh, Richard, Tom EXECUTE ''SELECT CAST('' || quote_ident($1) || '' AS TEXT) AS foo FROM '' || quote_ident($2) and then list := list || '', '' || this_record.foo ; works perfectly. Regards, Christoph ---(end of broadcast)--

Re: [SQL] Alter table

2002-11-08 Thread Rachel.Vaudron
Thanks a lot, but it's already what i am doing! It's very a pity that there is no way do to this more quickly!!! > alter table xxx rename to temp; > create table xxx as > select field1, field2, ...without some field... from temp; > drop table temp; > > Tomasz Myrta > > Rachel -

Re: [SQL] Alter table

2002-11-08 Thread Tomasz Myrta
Uz.ytkownik Rachel.Vaudron napisa?: Hi, I wonder if it is possible to remove a field of a table ? I haven't found anything about this into the reference manual. Can I do something like that ?: ALTER TABLE table DROP COLUMN column; alter table xxx rename to temp; create table xxx as select fiel

Re: [SQL] how to get the source table & field name of a view field

2002-11-08 Thread Christoph Haller
> > if I want to write a function for getting the view.field's source > table.field > how could I achieve it? > This sounds like a real challange. Throughout the years I've had to learn it's always a pain to retrieve system catalog information - no matter which DBMS is in use. On the other hand, yo