Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-03-02 Thread Ben Morrow
Quoth lists-pg...@useunix.net (Wayne Cuddy): > On Thu, Feb 28, 2013 at 06:02:05PM +, Ben Morrow wrote: > > > > (If you wanted to you could instead rename the table, and use rules on > > the view to transform DELETE to UPDATE SET state = 'deleted' and copy > > across INSERT and UPDATE...) > >

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-03-02 Thread Wayne Cuddy
On Thu, Feb 28, 2013 at 06:02:05PM +, Ben Morrow wrote: > Quoth m...@summersault.com (Mark Stosberg): > > > > We are working on a project to start storing some data as "soft deleted" > > (WHERE state = 'deleted') instead of hard-deleting it. > > > > To make sure that we never accidentally exp

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Mark Stosberg
On 02/28/2013 02:08 PM, Tom Lane wrote: > Mark Stosberg writes: >> # Explicitly grant access to the view. >> db=> grant select on entities_not_deleted to myuser; >> GRANT > >> # Try again to use the view. Still fails >> db=> SELECT 1 FROM entities_not_deleted WHERE some_col = 'y'; >> ERROR: perm

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Tom Lane
Mark Stosberg writes: > # Explicitly grant access to the view. > db=> grant select on entities_not_deleted to myuser; > GRANT > # Try again to use the view. Still fails > db=> SELECT 1 FROM entities_not_deleted WHERE some_col = 'y'; > ERROR: permission denied for relation entities What's failin

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Mark Stosberg
On 02/28/2013 01:02 PM, Ben Morrow wrote: > Quoth m...@summersault.com (Mark Stosberg): >> >> We are working on a project to start storing some data as "soft deleted" >> (WHERE state = 'deleted') instead of hard-deleting it. >> >> To make sure that we never accidentally expose the deleted rows thro

Re: [SQL] Need help revoking access WHERE state = 'deleted'

2013-02-28 Thread Ben Morrow
Quoth m...@summersault.com (Mark Stosberg): > > We are working on a project to start storing some data as "soft deleted" > (WHERE state = 'deleted') instead of hard-deleting it. > > To make sure that we never accidentally expose the deleted rows through > the application, I had the idea to use a

Re: [SQL] need help

2013-02-22 Thread denero team
Hey, Thanks Russell and all others. The query worked well. I got result what I expected. Thanks again, Dhaval On Fri, Feb 22, 2013 at 4:11 PM, denero team wrote: > Thanks Russell, > > let me check the query. > > On Fri, Feb 22, 2013 at 2:56 PM, Russell Keane > wrote: >>> Or every destinatio

Re: [SQL] need help

2013-02-22 Thread Russell Keane
> Or every destination location of the product in that time period? Ok, I've had another look at this this morning on the assumption you need every location that a product has been in that time period. This also assumes you're getting all the data you're interested in from the product_move table

Re: [SQL] need help

2013-02-22 Thread denero team
Thanks Russell, let me check the query. On Fri, Feb 22, 2013 at 2:56 PM, Russell Keane wrote: >> Or every destination location of the product in that time period? > > Ok, I've had another look at this this morning on the assumption you need > every location that a product has been in that time

Re: [SQL] need help

2013-02-22 Thread Russell Keane
> Sorry, why do you need the joins? > > Best, > Oliver Strictly speaking, for the examples and results given, the joins are pointless when you can get all the info from the 'move' table (but then the problem is like the 'hello world' of SQL) But then the other 2 tables are completely redundant

Re: [SQL] need help

2013-02-21 Thread Jaime Casanova
On Thu, Feb 21, 2013 at 3:20 PM, denero team wrote: > Hi, > > Thanks for replying me. yes you are right at some level for my case. > but its not what I want. I am explaining you a case by example. > [...] > > Now I really don't know how to do this. > > can you advise me more ? > I'm not really su

Re: [SQL] need help

2013-02-21 Thread Oliver d'Azevedo Cristina
Sorry, why do you need the joins? Best, Oliver Enviado via iPhone Em 21/02/2013, às 09:28 PM, Russell Keane escreveu: >>> Now I really don't know how to do this. >>> >>> can you advise me more ? >>> >>> >>> Thanks, >>> >>> Dhaval >> >> >> I think these are the sqls you are looking for: >

Re: [SQL] need help

2013-02-21 Thread Russell Keane
> > Now I really don't know how to do this. > > > > can you advise me more ? > > > > > > Thanks, > > > > Dhaval > > > I think these are the sqls you are looking for: > > SELECT pm.id as move_id, p.id as product_id, l.id as location_id > FROM product_move pm inner join product p on pm.product_id

Re: [SQL] need help

2013-02-21 Thread Russell Keane
> Consider following are data in each table > > Location : > id , name, code > 1, stock, stock > 2, customer, customer > 3, asset, asset > > Product : > id, name, code, location > 1, product1, p1, 1 > 2, product2, p2, 3 > > > Product_Move : > id, product_id, source_location, destination_locatio

Re: [SQL] need help

2013-02-21 Thread Oliver d'Azevedo Cristina
SELECT move_id, product_id,destination_location as location_id FROM product_move Where datetime BETWEEN $first AND $last Have you tried something like this? Best, Oliver Enviado via iPhone Em 21/02/2013, às 08:20 PM, denero team escreveu: > Hi, > > Thanks for replying me. yes you are right a

Re: [SQL] need help

2013-02-21 Thread denero team
Hi, Thanks for replying me. yes you are right at some level for my case. but its not what I want. I am explaining you a case by example. Consider following are data in each table Location : id , name, code 1, stock, stock 2, customer, customer 3, asset, asset Product : id, name, code, location

Re: [SQL] need help

2013-02-21 Thread Carlos Chapi
Hello, Maybe this query can help you SELECT p.name, l.name FROM location l INNER JOIN product_move m ON m.source_location = location.id INNER JOIN product p ON m.product_id = p.id WHERE p.id = $product_id AND m.datetime < $given_date ORDER BY datetime DESC LIMIT 1 It will return the name of the

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread Johnny Winn
On Sat, Sep 29, 2012 at 2:28 PM, Victor Sterpu wrote: > This is a way to do it, but things will change if you have many > attributes/object > > SELECT o.*, COALESCE(a1.value, a2.value) > FROM objects AS o > LEFT JOIN attributes AS a1 ON (a1.object_id = o.id) > LEFT JOIN attributes AS a2 ON (a2.ob

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread Victor Sterpu
This is a way to do it, but things will change if you have many attributes/object SELECT o.*, COALESCE(a1.value, a2.value) FROM objects AS o LEFT JOIN attributes AS a1 ON (a1.object_id = o.id) LEFT JOIN attributes AS a2 ON (a2.object_id = 0); On 29.09.2012 19:02, Andreas wrote: Hi, asume I've

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread David Johnston
On Sep 29, 2012, at 12:02, Andreas wrote: > Hi, > > asume I've got 2 tables > > objects ( id int, name text ) > attributes ( object_id int, value int ) > > attributes has a default entry with object_id = 0 and some other where > another value should be used. > > e.g. > objects > ( 1, '

Re: [SQL] Need help with a special JOIN

2012-09-29 Thread Samuel Gendler
On Sat, Sep 29, 2012 at 9:02 AM, Andreas wrote: > Hi, > > asume I've got 2 tables > > objects ( id int, name text ) > attributes ( object_id int, value int ) > > attributes has a default entry with object_id = 0 and some other where > another value should be used. > > e.g. > objects > ( 1,

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> You seem to be describing a straight reconciliation between two tables. > My > current means of doing this are programmatically but for the simple case > pure SQL should be doable. The main thing is that you have to distinguish > between "duplicate" records first and then match them up: > > Tabl

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> You seem to be describing a straight reconciliation between two tables. > My > current means of doing this are programmatically but for the simple case > pure SQL should be doable. The main thing is that you have to distinguish > between "duplicate" records first and then match them up: > > Tabl

Re: [SQL] Need help building this query

2012-06-21 Thread rihad
> For matching triples (foo, bar, baz) the date in table B shouldnt always > be > after any date in table A, as table B contains complete operations? > Operations in Table B can usually be obtained a day after, when Table A gets the updates. Table B contains the physical date of operation. The date

Re: [SQL] Need help building this query

2012-06-21 Thread Oliver d'Azevedo Christina
operations shouldn't have already been completed and, thus, without any record on table A ...? Could you please kindly elucidate me? Thank you Best, Oliver - Original Message - From: "Oliver d'Azevedo Christina" To: "Rihad" ; Sent: Thursday, June 21, 2012 7

Re: [SQL] Need help building this query

2012-06-21 Thread Oliver d'Azevedo Christina
For matching triples (foo, bar, baz) the date in table B shouldnt always be after any date in table A, as table B contains complete operations? Best, Oliver - Original Message - From: "Rihad" To: Sent: Thursday, June 21, 2012 6:48 PM Subject: [SQL] Need help building this query

Re: [SQL] Need help building this query

2012-06-21 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Rihad > Sent: Thursday, June 21, 2012 1:49 PM > To: pgsql-sql@postgresql.org > Subject: [SQL] Need help building this query > > Hi, folks. I currently need to join two tables

Re: [SQL] Need help in grouping records

2012-05-20 Thread Andreas
Am 20.05.2012 05:04, schrieb Jasen Betts: On 2012-05-19, Andreas wrote: Hi, I'm trying to fight against double entries in tables. I got as far as I can find similar records with trigram string matching. If I do this with a table compared to itself I get something like this: id_a, id_b 3, 5

Re: [SQL] Need help in grouping records

2012-05-19 Thread Jasen Betts
On 2012-05-19, Andreas wrote: > Hi, > > I'm trying to fight against double entries in tables. > I got as far as I can find similar records with trigram string matching. > If I do this with a table compared to itself I get something like this: > > id_a, id_b > 3, 5 > 3, 7 > 5, 3 > 5, 7 > 7,

Re: [SQL] need help with import

2012-02-15 Thread Raj Mathur (राज माथुर)
On Thursday 16 Feb 2012, Andreas wrote: > Hi > I get CSV files to import. > Th structure is like this. > main part, sub part > Could be like this > > A, a1 > A, a2 > A, a3 > B, b1 > B, b2 > > The database has a table for main_part and one for sub_part. > The relation needs to be n:m so there is a

Re: [SQL] need help with import

2012-02-15 Thread David Johnston
On Feb 15, 2012, at 21:05, Andreas wrote: > Am 16.02.2012 02:13, schrieb David Johnston: >> -Original Message- >> From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] >> On Behalf Of Andreas >> Sent: Wednesday, February 15, 2012 8:03 PM >> To: pgsql-sql@postgresql

Re: [SQL] need help with import

2012-02-15 Thread Andreas
Am 16.02.2012 02:13, schrieb David Johnston: -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Andreas Sent: Wednesday, February 15, 2012 8:03 PM To: pgsql-sql@postgresql.org Subject: [SQL] need help with import Hi I get CSV fil

Re: [SQL] need help with import

2012-02-15 Thread David Johnston
-Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Andreas Sent: Wednesday, February 15, 2012 8:03 PM To: pgsql-sql@postgresql.org Subject: [SQL] need help with import Hi I get CSV files to import. Th structure is like this. main p

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Edgardo Portal
On 2011-06-09, Andreas wrote: > Am 09.06.2011 18:20, schrieb Richard Broersma: >> On Thu, Jun 9, 2011 at 6:43 AM, Andreas wrote: >> >>> I have a log-table that stores events of users and projects like this >>> ( user_id integer, project_id integer, ts timestamp, event_type integer ) >>> >>> I nee

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Kevin Crain
Try this: select user_id, project_id, date_trunc, sum(sum) FROM (select user_id, project_id, date_trunc('day', ts), SUM(duration) FROM (select user_id, project_id, a.ts, ((SELECT MIN(b.ts) FROM log b WHERE b.ts>a.ts AND (date_trunc('day',a.ts)=date_trunc('day',b.ts)))-a.ts) AS duration from log a

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Andreas
Am 09.06.2011 18:20, schrieb Richard Broersma: On Thu, Jun 9, 2011 at 6:43 AM, Andreas wrote: I have a log-table that stores events of users and projects like this ( user_id integer, project_id integer, ts timestamp, event_type integer ) I need an aggregated list of worktime per user, per pro

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Richard Broersma
On Thu, Jun 9, 2011 at 6:43 AM, Andreas wrote: > I have a log-table that stores events of users and projects like this > ( user_id integer, project_id integer, ts timestamp, event_type integer ) > > I need an aggregated list of worktime per user, per project, per day. > > The users can switch pro

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Andreas
The log holds events and the ts is just the timestamp when the event occured. The events are kind of "opened form xxx with id xxx", "clicked button xxx", "switched to record xxx", ... They were primarily meant for helping me to find possible bugs when the user complains that it doesn't work but

Re: [SQL] need help with some aggregation magic

2011-06-09 Thread Oliveiros d'Azevedo Cristina
The ts means the time the user started on a project ? Or the time he finished? Or can mean both? If so, how do you can tell one from the other? Different event_type s ? Is it correct to assume from your words that an user cannot be in more than one project at the time? If so, can't be overlappin

Re: [SQL] Need help with plpgsql function.

2010-11-14 Thread Pavel Stehule
2010/11/14 Adrian Klaver : > On Saturday 13 November 2010 11:15:51 pm Pavel Stehule wrote: > >> > } >> >> Hello >> >> you can use a RETURN QUERY statement - some like >> >> CREATE OR REPLACE FUNCTION foo(IN i int, OUT a int, OUT b int) >> RETURNS SETOF RECORD AS $$ >> BEGIN >>   IF i = 1 THEN >>  

Re: [SQL] Need help with plpgsql function.

2010-11-14 Thread Adrian Klaver
On Saturday 13 November 2010 11:15:51 pm Pavel Stehule wrote: > > } > > Hello > > you can use a RETURN QUERY statement - some like > > CREATE OR REPLACE FUNCTION foo(IN i int, OUT a int, OUT b int) > RETURNS SETOF RECORD AS $$ > BEGIN > IF i = 1 THEN > RETURN QUERY SELECT 10,20 UNION ALL SEL

Re: [SQL] Need help with plpgsql function.

2010-11-13 Thread Pavel Stehule
2010/11/14 berelith : > > Hi, > > I'm creating the function on a postgres 8.2 server. > I would like the function to accept half a dozen varied parameters (varchars > and timestamps). > The first parameter will determine which one of the 6 different select > queries that function is going to run. >

Re: [SQL] Need help on update.

2010-10-21 Thread Nicholas I
that was amazing, it worked thanks a lot. -Nicholas I On Thu, Oct 21, 2010 at 1:40 PM, Richard Huxton wrote: > On 21/10/10 08:43, Nicholas I wrote: > >> Hi, >> >> there are two tables, table1 and table2, each having same column name >> called sn_no,name. i want to update table1 names with table

Re: [SQL] Need help on update.

2010-10-21 Thread Richard Huxton
On 21/10/10 08:43, Nicholas I wrote: Hi, there are two tables, table1 and table2, each having same column name called sn_no,name. i want to update table1 names with table2 where sn_no are same. select * from table1; sn_no | name ---+--- 1 | ramnad 2 | bangalore 3

Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-31 Thread Yogi Dwianandono Rizkiadi
t(integer) OWNER TO postgres; -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Pavel Stehule Sent: 30 Agustus 2009 22:56 To: Tom Lane Cc: Yogi Rizkiadi; pgsql-sql@postgresql.org Subject: Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT

Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-30 Thread Pavel Stehule
2009/8/30 Tom Lane : > Pavel Stehule writes: >> COPY in plpgsql are not allowed. > > I think it will work if you use an EXECUTE. > >                        regards, tom lane > I didn't test it. regards Pavel Stehule -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes

Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-30 Thread Tom Lane
Pavel Stehule writes: > COPY in plpgsql are not allowed. I think it will work if you use an EXECUTE. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] NEED HELP COPY TO DYNAMIC OUTPUT FILE

2009-08-29 Thread Pavel Stehule
Hello COPY in plpgsql are not allowed. regards Pavel Stehule 2009/8/30 Yogi Rizkiadi : > Hi admin, i'm gie from indonesia > > i wanna ask you how to make a dynamic output file from command COPY TO ? > > i have tried this : > > BEGIN > i:=0; > j:=10; > WHILE i < j LOOP > COPY (SELECT * FROM count

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread Rob Sargent
if you want topics listed which don't yet have messages try select t.id, t.topic, m.id, m.message from topics t left join messages m on m.topic = t.id; On Fri, May 22, 2009 at 8:47 AM, James Kitambara wrote: > Dear Richard Ekblom, > > I think Mr. Adrian Klaver gave you the solution. Mine is the

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread Oliveiros Cristina
pgsql-sql@postgresql.org Sent: Friday, May 22, 2009 3:47 PM Subject: Re: [SQL] Need help combining 2 tables together Dear Richard Ekblom, I think Mr. Adrian Klaver gave you the solution. Mine is the similar solution SELECT message.id,topic.topic,message.me

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread James Kitambara
Dear Richard Ekblom, I think Mr. Adrian Klaver gave you the solution. Mine is the similar solution SELECT message.id,topic.topic,message.message FROM topics, messages WHERE message.topic=topic.id order by message.id;   After executing this query you will get the following: id |  top

Re: [SQL] Need help combining 2 tables together

2009-05-22 Thread Adrian Klaver
On Friday 22 May 2009 6:48:43 am Richard Ekblom wrote: > Hello > > I have frequently encountered the need of combining two tables into one. > First, please take a look at the following table setups... > > CREATE TABLE topics ( >id SERIAL PRIMARY KEY, >topic TEXT NOT NULL > ); > > CREATE TAB

Re: [SQL] need help in building a query

2008-11-08 Thread Devil™ Dhuvader
> > > Try: > > bdteste=# SELECT o1.user_id, o1.order_id, '>= 500' AS cond FROM Orders o1 > bdteste-# WHERE (SELECT sum(o2.amount_paid) FROM Orders o2 WHERE > o2.user_id = o1.user_id AND o2.order_id > o1.order_id) < 500 AND > bdteste-#(SELECT sum(o2.amount_paid) FROM Orders o2 WHERE > o2.us

Re: [SQL] need help in building a query

2008-11-08 Thread Devil™ Dhuvader
yes, I am picking up the specific transaction (order_id) so that I can pickup the create_timestamp and sort it descending. that will list me those users who did transaction more than 500 in the least time. then I can give discount for top 10 users expected output: user_id, create_timestamp(desc) wi

Re: [SQL] need help in building a query

2008-11-07 Thread Frank Bax
Devil™ Dhuvader wrote: its like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the entry that has sum > $500. If there is some user who didnt even make 500 till now in my shop return the first date of transaction/order . ex: Orders(order_id,

Re: [SQL] need help in building a query

2008-11-07 Thread Devil™ Dhuvader
its like sum up entries of each user in order table backwards (i.e from last entry to the first) and find the entry that has sum > $500. If there is some user who didnt even make 500 till now in my shop return the first date of transaction/order. ex: Orders(order_id, user_id, amount_paid, create_t

Re: [SQL] need help in building a query

2008-11-06 Thread Harold A. Giménez Ch.
I personally would help if I understood what you need. I'm sure others feel the same way. Provide DDL, sample data, and expected result of the query. Maybe you'll have better luck... On Thu, Nov 6, 2008 at 11:15 AM, Devil™ Dhuvader <[EMAIL PROTECTED]>wrote: > none can help me? > > On Tue, Nov 4,

Re: [SQL] need help in building a query

2008-11-06 Thread Devil™ Dhuvader
none can help me? On Tue, Nov 4, 2008 at 9:08 PM, Devil™ Dhuvader <[EMAIL PROTECTED]> wrote: > hi, > I need some help in creating a sql. > the problem is as below. > > assume that: > I am a store keeper > and I have the list of customer(user_id) transactions in my order table. > schema: Orders(or

Re: [SQL] need help

2007-12-26 Thread Richard Broersma Jr
--- On Wed, 12/26/07, A. Wiryawan <[EMAIL PROTECTED]> wrote: > niwey do you have any e-books abour postgresql to be > shared, if you don't mind please sent me Sure, There are lots of books on the Postgresql site: http://www.postgresql.org/docs/8.2/interactive/index.html http://www.postgresql.or

Re: [SQL] need help

2007-12-26 Thread Richard Broersma Jr
--- On Wed, 12/26/07, A. Wiryawan <[EMAIL PROTECTED]> wrote: > From: A. Wiryawan <[EMAIL PROTECTED]> > Subject: [SQL] need help > To: pgsql-sql@postgresql.org > Date: Wednesday, December 26, 2007, 11:19 AM > is there any one online in yahoo messenger right now..? I am not, but you can find alot o

Re: [SQL] Need help with CASE statement in Function

2007-10-03 Thread Richard Broersma Jr
--- Hengky Lie <[EMAIL PROTECTED]> wrote: > My Question is : How to make argument 4 optional ? When IS NULL the function > will show all transaction between date $1 and $2 and product ID=$3 Could you simply overload your function by having two functions? One with arguement 4 and one without? R

Re: [SQL] Need help with CASE statement in Function

2007-10-03 Thread Dawid Kuroczko
On 10/3/07, Hengky Lie <[EMAIL PROTECTED]> wrote: > Dear friends, > I am a new user to postgreSQL and really need help to solve my "stupid ?" > problem. > > I have created function with 4 arguments like this : > > CREATE OR REPLACE FUNCTION "public"."fHistoryCard" (begdate date, enddate > date, Pr

Re: [SQL] need help

2007-05-14 Thread Aaron Bono
On 5/14/07, Penchalaiah P. <[EMAIL PROTECTED]> wrote: Hi … Create table cdano_nya(cdano int4,nyano int4) … I created this table and then I inserted some values to this( 234576,86)… Now when I am updating this table .. its not updating ..query is continuously running…

Re: [SQL] need help

2007-05-14 Thread Ashish Karalkar
Anyone else is using this table simulteniously? With Regards Ashish... - Original Message - From: Penchalaiah P. To: pgsql-sql@postgresql.org Sent: Monday, May 14, 2007 12:20 PM Subject: [SQL] need help Hi . Create table cdano_nya(cdano int4,nyano int4) .

Re: [SQL] need help

2007-05-14 Thread Andrej Ricnik-Bay
On 5/14/07, Penchalaiah P. <[EMAIL PROTECTED]> wrote: Any one can help in this Operating system? Postgres version? How does psql behave? Anything in the logs? Cheers, Andrej ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner wi

Re: [SQL] Need help: Find dirty rows, Update, Delete SQL

2006-02-20 Thread Patrick JACQUOT
Janning Vygen wrote: Am Samstag, 18. Februar 2006 18:41 schrieb [EMAIL PROTECTED]: Hello, I need a bit of help with some SQL. I have two tables, call them Page and Bookmark. Each row in Page can have many Bookmarks pointing to it, and they are joined via a FK (Page.id = Bookmark.page_id).

Re: [SQL] Need help: Find dirty rows, Update, Delete SQL

2006-02-19 Thread Janning Vygen
Am Samstag, 18. Februar 2006 18:41 schrieb [EMAIL PROTECTED]: > Hello, > > I need a bit of help with some SQL. > I have two tables, call them Page and Bookmark. > Each row in Page can have many Bookmarks pointing to it, and > they are joined via a FK (Page.id = Bookmark.page_id). > > Page has a 'ur

Re: [SQL] Need help with 'unique parents' constraint

2005-09-14 Thread Daryl Richter
Leif B. Kristensen wrote: On Sunday 11 September 2005 16:04, Greg Sabino Mullane wrote: Not just old-fashioned, it's the biological law! (among homo sapiens anyway). I'd approach this with a trigger, as you can do complex checks and get back nice customized error messages. A sample script foll

Re: [SQL] Need help with `unique parents` constraint

2005-09-12 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Thank you for an excellent answer. I think I will have to study your > code for a while. But is it such a bad idea to have a separate column > for the primary key here? I see that there are two schools on this, > with diametrically opposed views.

Re: [SQL] Need help with 'unique parents' constraint

2005-09-12 Thread Leif B. Kristensen
On Sunday 11 September 2005 16:04, Greg Sabino Mullane wrote: > Not just old-fashioned, it's the biological law! (among homo sapiens > anyway). I'd approach this with a trigger, as you can do complex > checks and get back nice customized error messages. A sample script > follows. Hard to tell with

Re: [SQL] Need help with 'unique parents' constraint

2005-09-11 Thread John Hasler
Greg Sabino Mullane writes: > Not just old-fashioned, [having only one mother is] the biological law! I see you aren't up on current research. -- John Hasler [EMAIL PROTECTED] Elmwood, WI USA ---(end of broadcast)--- TIP 4: Have you searched our l

Re: [SQL] Need help with 'unique parents' constraint

2005-09-11 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Now, I want to ensure that each person_id can be assigned only one > father (gender=1) and one mother (gender=2). (Yes, this is old- > fashioned, but I'm working with 18th century people). How do I do it? Not just old-fashioned, it's the biologica

Re: [SQL] Need help with 'unique parents' constraint

2005-09-11 Thread Leif B. Kristensen
On Sunday 11 September 2005 14:24, Leif B. Kristensen wrote: > ALTER TABLE relations ADD CONSTRAINT non_unique_father > CHECK (NOT EXISTS > (SELECT persons.person_id, relations.parent_fk > FROM persons AS P, relations AS R > WHERE R.parent_fk = P.person_id >

Re: [SQL] Need Help : Query problem

2003-11-19 Thread Michael Glaesemann
On Wednesday, November 19, 2003, at 10:26 AM, Abdul Wahab Dahalan wrote: How do I write a query so that I can get a result as below [ select only a record/s with same kk and kj but different pngk. For example here I've 3 records with same kk=01,kj=01 but diff pngk=a,b,c and 2 records with same kk

Re: [SQL] Need Help

2003-11-13 Thread Bruno Wolff III
On Fri, Nov 14, 2003 at 09:04:47 +0800, Abdul Wahab Dahalan <[EMAIL PROTECTED]> wrote: > Hi! > > If I've a table like this > > kk kj pngk vote > 01 02 a 12 > 01 02 b 10 > 01 03 c 5 > > and I want to have a

Re: [SQL] Need help with complex query

2003-07-09 Thread Yasir Malik
. I hope to continue to learn from professionals like you. Thank you so much, Yasir On Wed, 9 Jul 2003, Christoph Haller wrote: > Date: Wed, 09 Jul 2003 16:46:43 +0200 > From: Christoph Haller <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Re: [SQL] Need help with compl

Re: [SQL] Need help creating a BEFORE DELETE trigger

2003-06-30 Thread Rod Taylor
> The problem I'm looking at is: could this cause a recursion problem, where the > cascading deletion will try to cause the whole thing to cascade again? How It will only be able to delete the row (and cascade) once per row. The second time it tries to find the row, the row won't exist anymore.

Re: [SQL] Need help paging through record sets

2002-12-21 Thread Peter Galbavy
I have an almost identical application, but I am using Apache::ASP instead of PHP. Apart from the language differences, I suspect the ideas are the same. What I have done is store the *entire* list of results in a session variable with a clock-time. When I get a new query (...?page=2), I check i

Re: [SQL] Need help paging through record sets

2002-12-20 Thread Steve Crawford
Sort of depends on the nature of your application. You can use offset to get specific chunks: select * from foo order by date limit 100 offset 100; You should be aware, however, that on a very large table this can be quite inefficient as you will have to do the select and sort on the large tabl

Re: [SQL] Need Help for select

2002-08-18 Thread Andre Schubert
On Thu, 15 Aug 2002 11:17:15 +0900 "Masaru Sugawara" <[EMAIL PROTECTED]> wrote: > On Wed, 14 Aug 2002 16:04:21 +0200 > Andre Schubert <[EMAIL PROTECTED]> wrote: > > > > I want to compare if a tuple in c exist in b for each c.d_id and b.a_id. > > In c exists 3 tuples: (1,2), (3,4), (5) > > and w

Re: [SQL] Need Help for select

2002-08-14 Thread Masaru Sugawara
On Wed, 14 Aug 2002 16:04:21 +0200 Andre Schubert <[EMAIL PROTECTED]> wrote: > I want to compare if a tuple in c exist in b for each c.d_id and b.a_id. > In c exists 3 tuples: (1,2), (3,4), (5) > and want to find these tuples in b. Probably I would think I have reached the correct query. Table

Re: [SQL] Need Help for select

2002-08-14 Thread Masaru Sugawara
On Wed, 14 Aug 2002 16:04:21 +0200 Andre Schubert <[EMAIL PROTECTED]> wrote: > > > > > > If this mention implies that the tuple of (1, 1) in the c is supposed ^^ b > > to t

Re: [SQL] Need Help for select

2002-08-14 Thread Andre Schubert
On Wed, 14 Aug 2002 21:57:02 +0900 "Masaru Sugawara" <[EMAIL PROTECTED]> wrote: > On Wed, 14 Aug 2002 09:10:53 +0200 > Andre Schubert <[EMAIL PROTECTED]> wrote: > > > The ride side as follows. > > Table d contains information about subitems. > > Table c holds information about subitems and items

Re: [SQL] Need Help for select

2002-08-14 Thread Masaru Sugawara
On Wed, 14 Aug 2002 09:10:53 +0200 Andre Schubert <[EMAIL PROTECTED]> wrote: > The ride side as follows. > Table d contains information about subitems. > Table c holds information about subitems and items of type bar. > Each subitem can have 0..n items bar selected. > > What i want is that a sub

Re: [SQL] Need Help for select

2002-08-13 Thread Andre Schubert
On Mon, 12 Aug 2002 08:11:48 -0700 (PDT) "Ludwig Lim" <[EMAIL PROTECTED]> wrote: Hi, thank you for your quick response, but the answer you gave me doesnt give the result i want. Let me try to explain what i want. Lets say that table a contains informations about some items of the type foo. Table

Re: [SQL] Need Help for select

2002-08-12 Thread Ludwig Lim
--- Andre Schubert <[EMAIL PROTECTED]> wrote: > Hi all, > > i need help to build a select query or > plpgsql-fucntion > for the following tables. >> Is it possible to build a select query that selects > d.name for each a.name where > a.id = b.a_id and d.id = c.d_id and each b.c_id must > exist i

Re: [SQL] Need help on a troublesome query plan

2002-07-17 Thread Alain Lavigne
] 297 St-Paul, West - Montreal, Quebec, Canada - H2Y 2A5 Phone: 514-282-7073 ext: 371 - Fax: 514-282-8011 -Original Message- From: Stephan Szabo [mailto:[EMAIL PROTECTED]] Sent: July 16, 2002 14:52 To: Alain Lavigne Cc: [EMAIL PROTECTED] Subject: Re: [SQL] Need help on a troublesome query

Re: [SQL] Need help on a troublesome query plan

2002-07-16 Thread Stephan Szabo
On Tue, 16 Jul 2002, Alain Lavigne wrote: > Thanks that worked, but why does that happen or maybe you could point > to the proper thread so I read up on it. It's an issue that the numeric constant gets cast to int4 somewhat prematurely. I don't have a pointer to a thread off hand, but if you se

Re: [SQL] Need help on a troublesome query plan

2002-07-16 Thread Stephan Szabo
On Tue, 16 Jul 2002, Alain Lavigne wrote: > Index "bld_x1_tb_bus_fact" > Column | Type > -+--- > party_id| bigint > bus_fact_typ_cd | character(10) > cont_id | bigint > btree > > With the following query on 5 records: > > expla

Re: [SQL] Need Help!!

2001-10-04 Thread Ross J. Reedstrom
On Mon, May 21, 2001 at 07:39:06PM +0530, Gurudutt wrote: > Hello pgsql-sql, > > I am the new member for the postgres mailing list. Actually I have > been working with mysql, php and perl for a very long time now, and > offlate shifted to pgsql. I have many technical difficulties > > 2.

Re: [SQL] Need help in composing PostgreSQL query

2001-09-04 Thread Oliver Elphick
"Vladimir V. Zolotych" wrote: >Hi > >Please help me compose the query in PostgreSQL. >Using PostgreSQL 7.1.2. > >Suppose relations A and B have columns: > {X1, X2, ..., Xm, Y1, Y2, ..., Yn} >and > {Y1, Y2, ..., Yn} >Attributes Y1, Y2, ..., Yn are common for both relations >

Re: [SQL] Need help with search-and-replace

2001-05-06 Thread Christopher Sawtell
On Sunday 06 May 2001 10:27, Josh Berkus wrote: > Folks, > > I need to strip certain columns out of my pgdump file. However, I > can't figure out how to use any Unix-based tool to search-and-replace a > specific value which includes a tab character (e.g. replace "{TAB}7 > 00:00:00" with ""

Re: [SQL] Need help with EXECUTE function

2001-04-08 Thread Cedar Cox
Attached is the (I think) corrected version.. If you do like I said and cut the number in half you see fairly quickly why it didn't work. I'm sending yours back so you can easily run a diff to see what I did. Let me know if this (attached "cedars") works. -Cedar On Sat, 7 Apr 2001, Josh Berk

Re: [SQL] Need Help With Dates.

2000-07-03 Thread Thomas Lockhart
> I just migrated a database from MySQL to postgreSQL and am having trouble > wit postgres' dates. > MySQL dealt with dates very well, but i don't see the same sort of > functionality in postgres. ?? > The database is an archive of imformation, and i would like to do a cron'd > select for an int