Re: [SQL] How to join from two tables at once?

2003-08-28 Thread Joseph Shraibman
Stephan Szabo wrote: Probably you want something like: SELECT u.uid, u.txt, p.val FROM u INNER JOIN a ON (a.id=u.aid) LEFT JOIN p ON (p.uid=u.uid AND p.pkey=a.pkey); From the docs: A CROSS JOIN or INNER JOIN is a simple Cartesian product, the same as you get from listing the two items at the

[SQL] Forcing a trigger to run

2003-08-28 Thread Michael A Nachbaur
Hello all, I have several tables with triggers on them that all collectively manage a series of summary tables. In any case, there are instances where changes to a given table may cause another trigger to need to be run. What I have is an EmailAddress table, with other tables describing aliase

[SQL] BEFORE UPDATE Triggers

2003-08-28 Thread Chris Anderson
PostgreSQL Version: 7.2.3 Procedural Language: PL/pgSQL I have a table which contains a field for the user who last modified the record. Whenever a row in this table is updated, I want to have an UPDATE trigger do the following things: 1) Ensure the UPDATE query supplied a value for the action_u

Re: [SQL] length of array

2003-08-28 Thread Joe Conway
Chris Faulkner wrote: I would like to do it like this in Oracle select field from table N where [conditions] and NVL(N.level[1],0) = 0 and NVL(N.level[2],0) = 0 and NVL(N.level[3],0) = 0 and NVL(N.level[4],0) = 0 So if a row only has two elements in the array, but the first two both had values "0"

Re: [SQL] interval conversion

2003-08-28 Thread Brett Dikeman
>> I have a possibly stupid question- I'm doing some time calculations yielding >> intervals, and for my purposes I need to convert the interval(say, "1 day 8 >> hours") into (floating point) hours. While there's a plethora of handy >> date_extract functionality and the like, I need a conversion.

Re: [SQL] length of array

2003-08-28 Thread Chris Faulkner
Hello Thanks for that solution, Joe - nice use of nested functions ! Related to this problem, I want to constrain a selection using elements of this variable length array. I want to constrain where all elements of the array are 0. I would like to do it like this in Oracle select field from tabl

Re: [SQL] interval conversion

2003-08-28 Thread Tomasz Myrta
Hello all! I have a possibly stupid question- I'm doing some time calculations yielding intervals, and for my purposes I need to convert the interval(say, "1 day 8 hours") into (floating point) hours. While there's a plethora of handy date_extract functionality and the like, I need a conversion.

[SQL] interval conversion

2003-08-28 Thread Brett Dikeman
Hello all! I have a possibly stupid question- I'm doing some time calculations yielding intervals, and for my purposes I need to convert the interval(say, "1 day 8 hours") into (floating point) hours. While there's a plethora of handy date_extract functionality and the like, I need a conversion.

Re: [SQL] lock row in table

2003-08-28 Thread Tom Lane
=?iso-8859-2?Q?Daniel_Micha=B3?= <[EMAIL PROTECTED]> writes: > I have to lock one row in table1 for user1. In the same time other users sh= > ould be able to read this record but when other user for example user2 want= > to edit this record user2 should get information "The row you try to edit= >

Re: [SQL] lock row in table

2003-08-28 Thread Daniel
Hi, No, I am sure that I can get this message from Delphi. Check it on web site www.microolap.com For example when I try to put a non-unique value in a primary key I get message from database that I get conflict with primary key :-) of course I use raise ... except ... but everything work perfe

Re: [SQL] lock row in table

2003-08-28 Thread Yudha Setiawan
  Of course I can lock record with syntax "Begin;     select * from table1 where ID=12 for update;  update table1 set field1="New value" where ID=12;  commit;" but I can not to inform other user that the record is edited?   MAIN TARGET: How to get i

[SQL] lock row in table

2003-08-28 Thread Daniel Michał
Hallo everybody, I have a problem that I can not to solve in a simple way.   SOME INFORMATION: I have a postgresql database version 7.2.2 on Linux platform. I communicate with Postgresql from a Delphi application using microolap drivers and  everything works fine.   PROBLEM DESCRIPTION: I ha

Re: [SQL] How to optimize this query ?

2003-08-28 Thread ProgHome
You were right, Stephan ! The query below is still not correct ... because the second line shouldn't be shown ! Now I really don't know how I could rewrite this without a subquery because it doesn't seem to be possible with some LEFT or INNER joins ! Do you have an idea ? -Original Message

[SQL] Q: Multicolumn lookup, Join or Sub-query ?

2003-08-28 Thread Richard A. DeVenezia
I have a table T with many columns whose values are are lookup keys id_1, id_2, id_3, id_4, id_5, ..., id_26 The values corresponding to the keys live in table L, the lookup table: id, id_value T might have 100K rows and L 500K rows. I am wondering what would be the best view (performance-wise)

Re: [SQL] smallfloat with postgresql

2003-08-28 Thread Bruno Wolff III
On Wed, Aug 27, 2003 at 01:31:23 +0200, Alessandro Depetro <[EMAIL PROTECTED]> wrote: > > so, Can I safely use NUMERIC as a data type for monetary computation instead > of smallfloat ??? NUMERIC represents decimal numbers exactly so is suitable for monetary types using even decimal fractions.

Re: [SQL] [OT?]*_fsm_* parameters in postgresql.conf: which versions supports them?

2003-08-28 Thread Bruno Wolff III
On Wed, Aug 27, 2003 at 13:47:08 +0200, Marco Vezzoli <[EMAIL PROTECTED]> wrote: > Hi, > hope this is not too off topic: I run postgresql 7.1.3 on Solaris 8; > I've read on http://cbbrowne.com/info/postgresql.html that 'You will > only get effective nonblocking VACUUM queries if the dead tuples

[SQL] smallint with postgresql

2003-08-28 Thread Alessandro Depetro
hello folks! I havo to migrate some tables from Informix to Postgresql and I I'm in doubt if I can safely use NUMBER (as suggested for monetary computation in PGSQL guide) as a data type for smallint. TIA and gby Alessandro Depetro -- Coop Service Noncello s.c.a r.l. onlus http://www.mamcoop.it/

[SQL] smallint with postgresql

2003-08-28 Thread Alessandro Depetro
ooops NUMBER is NUMERIC excuse my french :) alessandro -- Coop Service Noncello s.c.a r.l. onlus http://www.mamcoop.it/ ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's

[SQL] smallfloat with postgresql

2003-08-28 Thread Alessandro Depetro
sorry again (I am not smoking crack, only drinking some good ceres...) smallint is not right (it is right for postgresql as a data type as read from the guide)... The real data type is "smallfloat" (found in my informix tables) so, Can I safely use NUMERIC as a data type for monetary computation

Re: [SQL] postgres 7.1.3: why does the query plan ignore indexes?

2003-08-28 Thread Gaetano Mendola
"Tom Lane" <[EMAIL PROTECTED]> wrote: > Bruce Momjian <[EMAIL PROTECTED]> writes: > > Should we consider adding some warning when someone creates an index on > > an int2 column? > > I don't think so. Better to expend our energy on solving the > fundamental problem. In the mean time that the fund

[SQL] [OT?]*_fsm_* parameters in postgresql.conf: which versions supports them?

2003-08-28 Thread Marco Vezzoli
Hi, hope this is not too off topic: I run postgresql 7.1.3 on Solaris 8; I've read on http://cbbrowne.com/info/postgresql.html that 'You will only get effective nonblocking VACUUM queries if the dead tuples can be listed in the Free Space Map': this could be done '[increasing], in postgresql.conf,

Re: [SQL] Restore deleted records

2003-08-28 Thread Bruno Wolff III
> Konstantin Petrenko wrote, On 8/26/2003 11:37 AM: > > >Hello. > > > >I accidentally deleted some recordes from my table. How can I restore > >them? Is it possible in 7.3.3? > if you have a dump, or you are still in a transaction, you can rollback. I avoided responding earlier, hoping you could

[SQL] script to create a sample database

2003-08-28 Thread Popeanga Marian
Hello Guys, Does any of you have a script for creating a sample database witch will include all kinds of objects that postgres suports ? I will be very glad if someone can help me! Thanks, /Marian ---(end of broadcast)--- TIP 5: Have you ch

Re: [SQL] How to return a record set from function.

2003-08-28 Thread Richard Huxton
On Wednesday 27 August 2003 08:18, Kumar wrote: > Dear Friends, > > I am newbie to Postgres. I am running 7.3.4 on Linux 7.3. I am using > Pgadmin tool. I need to return the table rows via record set. > > Create table t1 (c1 int, c2 varchar, c3 varchar); > > Create or Replace function sel_t1 () ret

Re: [SQL] Canceling other backend's query

2003-08-28 Thread Bruce Momjian
daq wrote: > Hi, > > Can i cancel querys runing on other backends, or disconnect a client > from the server? I can kill the backend process, but sometimes this > causing shared memory troubles. See the 'postgres' manual page for a list of signals and their effects. -- Bruce Momjian

Re: [SQL] How to return a record set from function.

2003-08-28 Thread Stephan Szabo
On Wed, 27 Aug 2003, Kumar wrote: > Dear Friends, > > I am newbie to Postgres. I am running 7.3.4 on Linux 7.3. I am using > Pgadmin tool. I need to return the table rows via record set. > > Create table t1 (c1 int, c2 varchar, c3 varchar); > > Create or Replace function sel_t1 () returns setof r

Re: [SQL] Canceling other backend's query

2003-08-28 Thread scott.marlowe
On Wed, 27 Aug 2003, daq wrote: > Hi, > > Can i cancel querys runing on other backends, or disconnect a client > from the server? I can kill the backend process, but sometimes this > causing shared memory troubles. If you kill -9 a backend, you will cause the shared memory problem. Try just a

Re: [SQL] length of array

2003-08-28 Thread Joe Conway
Chris Faulkner wrote: Is there a function in postgres to return the length of an array field ? I have seen array_dims(array) but this returns a character value. Ideally, I'd like something numeric returned. Afraid not in 7.3.x or earlier. In 7.3.x (but not earlier) you *can* do this (for a one-dim

Re: [SQL] How to optimize this query ?

2003-08-28 Thread Stephan Szabo
On Wed, 27 Aug 2003, ProgHome wrote: > You were right, Stephan ! > The query below is still not correct ... because the second line > shouldn't be shown ! > Now I really don't know how I could rewrite this without a subquery > because it doesn't seem to be possible with some LEFT or INNER joins !

Re: [SQL] How to return a record set from function.

2003-08-28 Thread Joe Conway
Kumar wrote: Create table t1 (c1 int, c2 varchar, c3 varchar); Create or Replace function sel_t1 () returns setof records as ' select c1, c2, c3 from t1; ' Language SQL; It was fine and created a function. while i execute it as select sel_t1; I got the following error. ERROR: Cannot display

[SQL] length of array

2003-08-28 Thread Chris Faulkner
Hello Is there a function in postgres to return the length of an array field ? I have seen array_dims(array) but this returns a character value. Ideally, I'd like something numeric returned. Thanks Chris ---(end of broadcast)--- TIP 6: Have you

Re: [SQL] One-2-many relation - need distinct counts

2003-08-28 Thread Richard Huxton
On Tuesday 26 August 2003 14:54, PS PS wrote: > Select Count(Distinct(account_no)) > from A, B > where A.Account_no = B.Account_no > > I get the correct count. If I do this: > Select Count(Distinct(account_no)), B.Account_type > from A, B > where A.Account_no = B.Account_no > group by B.Account_ty