Re: [SQL] Getting the latest unique items

2002-12-11 Thread Tom Lane
"A.M." <[EMAIL PROTECTED]> writes: > When I try to run the following query: > select distinct on(student_gradedmaterial.id) ... ^^ > ... order by submittime desc; ^^^ > I get the following error: > ERROR: SELECT DISTINCT ON expre

[SQL] Primary Key Help !

2002-12-11 Thread Waheed Rahuman
Hi Greetings Friends please help me in setting the primary key in a table how many primary key i can create. In MS access its only 10 column can be made into primary key !. My question is How many primary key i can assign in a PostGresql Table   Rowid    |  Parent1   |  Par

Re: [SQL] Getting the latest unique items

2002-12-11 Thread A.M.
When I try to run the following query: select distinct on(student_gradedmaterial.id) student_gradedmaterial.id from coursesection_student,student_gradedmaterial WHERE gradedmaterialid=1 AND coursesection_student.studentid=student_gradedmaterial.studentid AND coursesectionid=1 and score is not

Re: [SQL] convert NULL into a value

2002-12-11 Thread Bruce Momjian
No, the SQL standard command is COALESCE. --- Jonathan Man wrote: > Hi, > > There is a function on the Oracle. That is NVL(field, 0) to convert null into a >value (e.g. ZERO). > > Can I use this function on the PostgreS

Re: [SQL] convert NULL into a value

2002-12-11 Thread Ludwig Lim
--- Jonathan Man <[EMAIL PROTECTED]> wrote: > Hi, > > There is a function on the Oracle. That is > NVL(field, 0) to convert null into a value (e.g. > ZERO). > > Can I use this function on the PostgreSQL?? > -- The equivalent function is PostgreSQL is SELECT COALESCE(field,0) regards, lu

[SQL] convert NULL into a value

2002-12-11 Thread Jonathan Man
Hi,   There is a function on the Oracle. That is NVL(field, 0) to convert null into a value (e.g.  ZERO).   Can I use this function on the PostgreSQL??     Thank you for your help!!   Regards,   JONATHAN MAN

Re: [SQL] trigger to maintain relationships

2002-12-11 Thread Josh Berkus
David, > FYI, join should've looked like: > > create function pr_tr_i_nodes() returns opaque > as ' > insert into ancestors > select NEW.node_id, ancestor_id > from NEW left outer join ancestors on (NEW.parent_id = > ancestors.node_id); > > return NEW;' > language 'plpgsql'; > cr

[SQL] multi-user and multi-level database access

2002-12-11 Thread Tomasz Myrta
Hi I want to protect my database against unauthorised data destruction (Postgresql 7.2) I have some applications accesing database, each one does other things and there is a lot of users using these applications. Here is my solution: - each application has one postgresql group (create group...)

Re: [SQL] error in copy table from file

2002-12-11 Thread Manfred Koizar
On Wed, 11 Dec 2002 18:40:48 +0100, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: >copy table from 'path/file' using delimiters ';' > >it returns the following: > >'RROR: copy: line 1, Bad float8 input format '-0.123 ^ This belongs to the end of the error message. Finding it here at the beginni

Re: [SQL] Getting the latest unique items

2002-12-11 Thread Tomasz Myrta
I'm not sure if I understood your problem, but did you try with "distinct on"? select distinct on (id) from ... order by submittime desc Regards, Tomasz Myrta A.M. wrote: > I have a table as follows: > CREATE TABLE student_gradedmaterial( > id SERIAL, > studentid INT8 REFERENCES student

Re: [SQL] error in copy table from file

2002-12-11 Thread Stephan Szabo
On Wed, 11 Dec 2002, [iso-8859-1] [EMAIL PROTECTED] wrote: > 'RROR: copy: line 1, Bad float8 input format '-0.123 Looks like you have end of line issues (given the fact that the second quote is at the beginning of the line. You probably have carriage returns at the end of lines. If you get rid

[SQL] Getting the latest unique items

2002-12-11 Thread A.M.
I have a table as follows: CREATE TABLE student_gradedmaterial( id SERIAL, studentid INT8 REFERENCES student, gradedmaterialid INT8 REFERENCES gradedmaterial, caid INT8 REFERENCES ca, ... submittime TIMESTAMP, gradedtime TIMESTAMP, score INT4 ); Every time a student submits a homewo

[SQL] error in copy table from file

2002-12-11 Thread [EMAIL PROTECTED]
hi i'm using postgreSQL 7.3 b1. when i try to populate my tables with the files that contain all the data, i have some troblues: for example, my table has the following fields: -date (date) -id_street (int2) -flux_h_0_1 (float8) -flux_h_1_2 (float8) . . . -flux_h_23_0 (float8) the i

Re: [SQL] trigger to maintain relationships

2002-12-11 Thread David M
I think I figured out my join syntax error (sorry for confusing the issue with noise like that). I'd still be interested in general comments on design. FYI, join should've looked like: create function pr_tr_i_nodes() returns opaque as ' insert into ancestors select NEW.node_id, ancestor_

[SQL] trigger to maintain relationships

2002-12-11 Thread David M
I am maintaining a set of hierarchical data that looks a lot like a tree. (And my SQL is very rusty. And I'm new to postgres.) Questions: - 1.) Is the following a reasonable solution? Is there a postgres-specific way to handle this better? Is there a good generic SQL way to handle

Re: [SQL] union query doubt:

2002-12-11 Thread Jean-Luc Lachance
I think you meant: SELECT date, sum( case when point = 1 then flow else 0 end) as flow1, sum( case when point = 2 then flow else 0 end) as flow2, sum( case when point = 3 then flow else 0 end) as flow3, sum( case when point = 4 then flow else 0 end) as flow4, sum( case when point = 5 then flow els

Re: [SQL] union query doubt:

2002-12-11 Thread Frank Bax
At 11:21 AM 12/11/02, javier garcia wrote: I've got a table with three fields: DATE, POINT, FLOW. The POINT field can have values among 1 and 6. So, for a same date I have six different points with the correspondings flows. I would like to make a query to obtain something like: DATE POINT1 POINT2

[SQL] union query doubt:

2002-12-11 Thread javier garcia
Hi; I've got a table with three fields: DATE, POINT, FLOW. The POINT field can have values among 1 and 6. So, for a same date I have six different points with the correspondings flows. I would like to make a query to obtain something like: DATE POINT1 POINT2 POINT3 POINT4 POINT5 POINT6 where for

Re: [SQL] Backup to data base how ?

2002-12-11 Thread Frank Bax
At 10:36 PM 12/11/02, ksql wrote: This is vital for my, please send me an example about like I can make me to support my database with name WAREHOUSE pg_dump -o -c warehouse | gzip > warehouse.gz http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/backup.html

[SQL] Backup to data base how ?

2002-12-11 Thread ksql
This is vital for my, please send me an example about like I can make me to support my database with name WAREHOUSE -- Saludos de Luis, Mi correo: mailto:[EMAIL PROTECTED] _ Do You Yahoo!? La emoción e intensidad

Re: [SQL] Problem with timestamp

2002-12-11 Thread Henshall, Stuart - Design & Print
Title: RE: [SQL] Problem with timestamp Beatrice Yueksel wrote: > Hello, > > I try to check the time needed by a function. > I would like to : >  . select current_timestamp, >  . execute 5000 times a function >  . select the current_timestamp and return the interval. > Problem : the interval

[SQL] Problem with timestamp

2002-12-11 Thread Beatrice Yueksel
Hello, I try to check the time needed by a function. I would like to : . select current_timestamp, . execute 5000 times a function . select the current_timestamp and return the interval. Problem : the interval is always '00:00', the two timestamps have always the same value. Could you help me ? h

Re: [SQL] Adding foreign key constraint post table creation

2002-12-11 Thread Richard Huxton
On Monday 09 Dec 2002 4:11 pm, Charles Hauser wrote: > All, > > A couple of novice questions: > > > I would like to modify an existing TABLE by addinga new column (FOREIGN > KEY): > >type_id int not null, >foreign key (type_id) references cvterm (cvterm_id), > > > Will this work ( r

Re: [SQL] Question II

2002-12-11 Thread Christoph Haller
> > I would like to get all field name of a table within a stored procedure > using pgsql. How to do it?? > SELECT a.attname FROM pg_class c, pg_attribute a WHERE c.relname = '' AND a.attnum > 0 AND a.attrelid = c.oid ORDER BY a.attnum ; gives you the field names of . If you start a psql session

Re: [SQL] sql query

2002-12-11 Thread Christoph Haller
> > Hi I have a problem forming a query > I have 3 tables salary(hrs, clock_in , clock_out) > Break ( date, employe_id, net_time, break_in, break_out) > Employee(employee_id, pay_rate, name) > > I need to get an hourly report till the current time for that day > stating name, hour, no of hours, sal

Re: [SQL] Question

2002-12-11 Thread Christoph Haller
> Can I get a table structure on a function using pgsql?? I think so. What are your intentions? You should be more specific. Regards, Christoph ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe