[SQL] three-way join

2004-04-19 Thread Gary Stainburn
Hi folks, here's a straight forward join that I simply can't get my head round. I've got consumables:cs_id, cs_make, cs_comments cons_locations: cl_id, cl_desc cons_stock: cs_id, cl_id, status (1=ordered, 2=in-stock) (one stock record per stock item, qty=3 means 3 records) I'm struggling

Re: [SQL] Concatenate results of a single column query

2004-04-19 Thread Christoph Haller
> > > Marco Lazzeri <[EMAIL PROTECTED]> writes: > > > SELECT > > p.name, ARRAY(SELECT nicknames FROM people WHERE people.id = p.id) > > FROM people AS p > > > Any suggestions? > > Something like: > > db=> create aggregate array_aggregate (basetype = integer, sfunc = array_append, > stype =

Re: [SQL] Concatenate results of a single column query

2004-04-19 Thread Greg Stark
Christoph Haller <[EMAIL PROTECTED]> writes: > Interesting feature, but I cannot find function array_append: > ERROR: AggregateCreate: function array_append(integer[], integer) does not exist It's new in Postgres 7.4 I think you could do this in 7.3 though, it would just be more awkward. Try |

Re: [SQL] three-way join

2004-04-19 Thread Stijn Vanroye
Gary wrote: > Hi folks, > > here's a straight forward join that I simply can't get my head round. > > I've got > > consumables: cs_id, cs_make, cs_comments > cons_locations: cl_id, cl_desc > cons_stock: cs_id, cl_id, status (1=ordered, 2=in-stock) > > (one stock record per stock item, qty=3 m

Re: [SQL] three-way join

2004-04-19 Thread Gary Stainburn
On Monday 19 April 2004 3:06 pm, Stijn Vanroye wrote: > Gary wrote: > > Hi folks, > > > > here's a straight forward join that I simply can't get my head round. > > > > I've got > > > > consumables:cs_id, cs_make, cs_comments > > cons_locations: cl_id, cl_desc > > cons_stock: cs_id, cl_id, s

Re: [SQL] Update is very slow on a bigger table

2004-04-19 Thread scott.marlowe
On Sat, 17 Apr 2004, Bruno Wolff III wrote: > On Fri, Apr 16, 2004 at 12:47:58 -0500, > Yudie <[EMAIL PROTECTED]> wrote: > > Hi guys, > > I would like to create a trigger that execute some programs, > > is there a way to create a plpgsql function that execute shell command or > > any other way t

[SQL] Prepared Statements and large where-id-in constant blocks?

2004-04-19 Thread James Robinson
Howdy: Java middlewares like JBossCMP issue many queries in the general form of: SELECT t1.att1, t1.att2 ... t1.attN FROM t1 WHERE (t1.id = X) or (t1.id = Y) where there may be anywhere between 1 and thousands of "(id = N)" blocks ORed together. These may be transformed to the "WHERE

Re: [SQL] three-way join - solved

2004-04-19 Thread Gary Stainburn
On Monday 19 April 2004 4:01 pm, Gary Stainburn wrote: > On Monday 19 April 2004 3:06 pm, Stijn Vanroye wrote: > > Gary wrote: > > > Hi folks, > > > > > > here's a straight forward join that I simply can't get my head round. > > > > > > I've got > > > > > > consumables: cs_id, cs_make, cs_comm

Re: [SQL] Concatenate results of a single column query

2004-04-19 Thread CoL
hi, Christoph Haller wrote: Interesting feature, but I cannot find function array_append: ERROR: AggregateCreate: function array_append(integer[], integer) does not exist try with pg 7.4 C. ---(end of broadcast)--- TIP 9: the planner will ignore

[SQL] Concatenate results of a single column query

2004-04-19 Thread Marco Lazzeri
Hi All, I would like to concatenate results of a single column query, something like the futurable (dev docs for 7.5) SELECT p.name, ARRAY(SELECT nicknames FROM people WHERE people.id = p.id) FROM people AS p Any suggestions? Thanks Marco ---(end of broadcast)

[SQL] Querying From two databases

2004-04-19 Thread Pallav Kalva
Hi, I am new to postgres and I need to do a query which joins two tables from different databases. Can you please advice me on how to achieve this in postgres. Thanks! Pallav ---(end of broadcast)--- TIP 2: you can get off all lists at once wit

[SQL] What is the best way of writing update rule on view with joined tables?

2004-04-19 Thread Cornelius Grotjahn
Please, how can I rewrite the rule below so that it works as intended for this update: update v set ad=0, bd=0 where ad=1; As it is now, this will change ad but not bd, presumably because when the rule's first action has updated ad, the "where ad=1" returns 0 rows for the second action. I wan

[SQL] ANN: www.SQL-Scripts.Com

2004-04-19 Thread Greg
Hello,Announcing the release of a new web site : www.SQL-Scripts.comAt www.SQL-Scripts.Com you can find a collection of SQL Scripts for manydifferent database system.  Using our search system you can find scriptsthat you need quickly and simply.  If you have scripts that you use why notlodge

Re: [SQL] Function for numbering rows?

2004-04-19 Thread CoL
hi, Tony Reina wrote, On 4/10/2004 18:12: Simple question: Is there a function that will allow me to number the returned tuples? e.g. CREATE TABLE test ( field1 text ): INSERT INTO test VALUES ('first'); INSERT INTO test VALUES ('second'); INSERT INTO test VALUES ('third'); INSERT INTO test V

[SQL] relation X does not exist

2004-04-19 Thread Laura Scott
Morning, I see lots of references to this error, but currently no fix for my situation. I am converting an INFORMIX ESQL/C system to PostgreSQL embedded C. I have hit several road blocks along the way and running out of time to complete and test this convert - so I am coming to the pros for some

Re: [SQL] Database triggers

2004-04-19 Thread Charles Wilt
Do you have access to the SQL Reference Manual: http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/db2/rbafzmsthctri gger.htm#HDRHCTRIGGER There's an example of what you want to do: CREATE TRIGGER SAL_ADJ AFTER UPDATE OF SALARY ON EMPLOYEE REFERENCING OLD AS OLD_EMP NEW AS NEW_E

Re: [SQL] problem porting MySQL SQL to Postgres

2004-04-19 Thread CoL
hi, Dan Field wrote: I've stumbled across a query I don't quite understand the error message for. This query is pulled from a working MySQL setup: SELECT DEWEY_ID, DEWEY_HUNDREDS, DEWEY_TENS, DEWEY_ONES, DEWEY_POINT_ONES, DEWEY_POINT_TENS, DEWEY_POINT_HUNDREDS, DEWEY_POINT_THO

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-19 Thread Jeff Boes
Troels Arvin wrote: See http://www.acm.org/sigmod/record/issues/0403/index.html#standards for an article which summarizes the news in SQL:2003. This is a very useful page; thank you for creating it and for noting it in this thread! -- (Posted from an account used as a SPAM dump. If you really wan

[SQL] Database triggers

2004-04-19 Thread Charity M
I have a lab assignment that I have been struggling with. We are using oracle sql. Can someone please help me. See the lab below. I have done ques 1 - 3 thus far and am now stuck on triggers ques 4 - 6. THIS IS THE LAB: 1. Create a table called QUOTE. · Give the table an initial and n

Re: [SQL] three-way join

2004-04-19 Thread Bruno Wolff III
On Mon, Apr 19, 2004 at 13:47:28 +0100, Gary Stainburn <[EMAIL PROTECTED]> wrote: > Hi folks, > > here's a straight forward join that I simply can't get my head round. > > I've got > > consumables: cs_id, cs_make, cs_comments > cons_locations: cl_id, cl_desc > cons_stock: cs_id, cl_id, statu

Re: [SQL] Database triggers

2004-04-19 Thread Charity M
Thank you, will look at the reference manual. This is how I've done it to this point. It runs and the trigger is created but am not quite sure if its the right thing. CREATE OR REPLACE TRIGGER QUOTE_TRG BEFORE INSERT or DELETE OR UPDATE ON QUOTE FOR EACH ROW DECLARE today_date date;

Re: [SQL] Update is very slow on a bigger table

2004-04-19 Thread CoL
hi, Dimitar Georgievski wrote, On 4/15/2004 23:07: hi, i'm running an update procedure on a table with approximately 100,000 records. The problem is the procedure is running endlessly even when the update is very simple like in the following example: update mytable set client_id = 1 where mytabl

Re: [SQL] Querying From two databases

2004-04-19 Thread Bruce Momjian
Pallav Kalva wrote: > Hi, > > I am new to postgres and I need to do a query which joins two tables > from different databases. Can you please advice me on how to achieve > this in postgres. Sure, see /contrib/dblink in the source distribution. -- Bruce Momjian|

[SQL] SQL script

2004-04-19 Thread vickr1z
good day toall.. imm running postgreSQL on linux. my main goal is to create a script that will dump a data from our server too my local PC. the content of the script would be execute sql command in one shot: 1. dump data 2. update and insert some rows to selected table. how can i accommplish th

Re: [SQL] SQL script

2004-04-19 Thread scott.marlowe
On Thu, 15 Apr 2004 [EMAIL PROTECTED] wrote: > good day toall.. > imm running postgreSQL on linux. > my main goal is to create a script that will dump a data from our server too my > local PC. the content of the script would be execute sql command in one shot: > 1. dump data > 2. update and ins

Re: [SQL] Prepared Statements and large where-id-in constant blocks?

2004-04-19 Thread Tom Lane
James Robinson <[EMAIL PROTECTED]> writes: > where there may be anywhere between 1 and thousands of "(id = N)" > blocks ORed together. These may be transformed to the "WHERE t1.id IN > (X, Y, ...)" form for possibly a little performance gain (possibly -- > I've not yet checked to see if this pla

Re: [SQL] relation X does not exist

2004-04-19 Thread Tom Lane
Laura Scott <[EMAIL PROTECTED]> writes: > I have a table defined with only two fields. The create table statement > did not have " " around the table name. I can cut and paste the query > from my debug statement into psql and get the desired result set back. > However, in the .pgc file, the query