Re: [SQL] [Trigger] Help needed with NEW.* and TG_TABLE_NAME

2010-05-11 Thread Stuart
Torsten, Usually, the “insert ... (select ...)” has the select portion enclosed in parenthesis. Don't know if solution is that simple but did not see it in your examples. It may be worth a try. Stuart - Original message - > Hello, > > i have a problem with a trigger

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Stuart McGraw
Glenn Maynard wrote: (JMdict? yup. ;-) I was playing with importing that into a DB a while back, but the attributes in that XML are such a pain--and then my email died while I was trying to get those changed, and I never picked it up again.) On Mon, Apr 13, 2009 at 1:20 PM, Stuart McGraw

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Stuart McGraw
Scott Marlowe wrote: 2009/4/7 Stuart McGraw : Hello all, I have a table with a primary key column that contains sequential numbers. Sometimes I need to shift them all up or down by a fixed amount. For example, if I have four rows with primary keys, 2, 3, 4, 5, I might want to shift them down

Re: [SQL] changing multiple pk's in one update

2009-04-13 Thread Stuart McGraw
Jasen Betts wrote: On 2009-04-08, Stuart McGraw wrote: Hello all, I have a table with a primary key column that contains sequential numbers. Sometimes I need to shift them all up or down by a fixed amount. For example, if I have four rows with primary keys, 2, 3, 4, 5, I might want to

[SQL] changing multiple pk's in one update

2009-04-07 Thread Stuart McGraw
Hello all, I have a table with a primary key column that contains sequential numbers. Sometimes I need to shift them all up or down by a fixed amount. For example, if I have four rows with primary keys, 2, 3, 4, 5, I might want to shift them down by 1 by doing: UPDATE mytable SET id=id-1 (

Re: [SQL] autovacuum not freeing up unused space on 8.3.0

2008-02-24 Thread Stuart Brooks
vacuums of a whole lot of tables by hand... Thanks Stuart PS. Running on NetBSD 3 ---(end of broadcast)--- TIP 6: explain analyze is your friend ---(end of broadcast)--- TIP 4: Have you searche

[SQL] autovacuum not freeing up unused space on 8.3.0

2008-02-24 Thread Stuart Brooks
32801 | 52750 Is there anything I have missed as far as setting this up is concerned, anything I could try? I would really rather use autovacuum than manage the vacuums of a whole lot of tables by hand... Thanks Stuart PS. Running on NetBSD 3 ---(end of bro

Re: [SQL] Am I wasting my time with partitions?

2008-02-19 Thread Stuart Brooks
es that help you? I tried to strip the example down to its bare essentials but in this case I would be partitioning by lineitem_key and would obviously index and add a CONSTRAINT on that as well. I don't think it would help though, the query needs to merge from all tables. Thanks f

[SQL] Am I wasting my time with partitions?

2008-02-19 Thread Stuart Brooks
t;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> If I partition the table by creating a top level table L, and inheri

[SQL] Slow GROUP BY query

2008-01-29 Thread Stuart Brooks
ghly the same time? Out of interest, since we are grouping by transaction_key which is unique, surely the other Transaction fields in the group by could be ignored by the planner? Thanks Stuart (running postgresql 8.2.5 on NetBSD 3) >> Slow query EXPLAIN SELECT t.transaction_key,t.cash

Re: [SQL] TIMESTAMP comparison problem

2008-01-22 Thread Stuart Brooks
least microsecond precision. Well, you can't get better than microsecond precision with timestamps in Postgres. And the only way you can rely on that level of precision is to compile with --enable-integer-datetimes. Michael Glaesemann I thought that might be the case, thanks for the hel

[SQL] TIMESTAMP comparison problem

2008-01-22 Thread Stuart Brooks
like to have at least microsecond precision. Thanks Stuart Table definition: db=> \d+ Transactions; Table "test.transactions" Column | Type | Modifiers

Re: [SQL] data dependent sequences?

2007-07-17 Thread Stuart
"Andrew Sullivan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tue, Jul 17, 2007 at 09:40:21AM -0600, Stuart wrote: > > is not really structually important -- it is a value that > > exists soley for the UI. > > Hmm. Maybe you sh

Re: [SQL] data dependent sequences?

2007-07-17 Thread Stuart
"Andrew Sullivan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tue, Jul 17, 2007 at 07:34:26AM -0600, Stuart wrote: > > I am not looking for gapless sequences. The reason I > > want to do this is the "typ" column is actually an indic

Re: [SQL] data dependent sequences?

2007-07-17 Thread Stuart
"chester c young" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > > > CREATE TABLE items ( > > id INT, > > typ INT... > > PRIMAY KEY (seq,typ)); > > > > >id typ > > +- > > 1 'a' > > 2 'a' > > 3 'a' > > 1 'b' > > 4 'a'

Re: [SQL] data dependent sequences?

2007-07-17 Thread Stuart
"Ragnar" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On sun, 2007-07-15 at 09:28 -0600, Stuart McGraw wrote: > > Advice requested :-) I have a table like: > > > > CREATE TABLE items ( > > id INT, > > typ INT... >

[SQL] data dependent sequences?

2007-07-15 Thread Stuart McGraw
Advice requested :-) I have a table like: CREATE TABLE items ( id INT, typ INT... PRIMAY KEY (seq,typ)); I would like 'id' to be like a SERIAL except that I want independent sequences for each value of 'typ'. So if 'items' is: id typ +- 1 'a' 2 'a'

Re: [SQL] slowness when subselect uses DISTINCT

2007-04-19 Thread Stuart McGraw
Phillip Smith wrote: > May I suggest you post an EXPLAIN ANALYZE to the group for the query you're > having problems with...? I will do that but it has happened to me enough that it seems to be a general pattern, not something specific to one of my queries, so I thought some communal knowledge ma

[SQL] slowness when subselect uses DISTINCT

2007-04-18 Thread Stuart McGraw
I have several times now run into what seems like similar performance problems with some of my postgresql queries. I have a view that runs reasonably quicky. I use this view in a subselect in another query and that query too runs reasonably quicky. The view returns some unwanted duplicate row

[SQL] equiv of ascii() function for unicode?

2007-04-18 Thread Stuart McGraw
Does postgresql have a function that will give me the numeric unicode code point for a character in a unicode (aka utf8) database text string? That is, something like ascii() but that works for unicode characters? ---(end of broadcast)--- TIP 2:

Re: [SQL] Constraint on multicolumn index

2006-11-14 Thread Stuart Brooks
each of the selects and then have to merge, sort and limit the results. This seemed to work although it gets clumsy if there are a whole lot of extra criteria. Thanks again for the help, Stuart ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

[SQL] Constraint on multicolumn index

2006-11-10 Thread Stuart Brooks
rt of issuing 3 queries and joining them that I can do this? I had hoped to be able to compare (a,b,c)>(10,100,1000) but of course that evaluates to (a>10) and (b>100) and (c>1000). It feels like there should be a simple solution to this... please help :) Thanks Stuart -

Re: [SQL] slow view

2006-10-11 Thread Stuart McGraw
On 2006/10/11 Stuart wrote: > [..] Apologies for following up my own post, but after struggling with that query for over a day, I figured out the answer within thirty minutes of posting. (Sigh) My slow query was: > SELECT p.id AS pid, a.id AS aid, sub.bid AS bid > FROM p >

[SQL] slow view

2006-10-11 Thread Stuart
I am having a problem with the performance of a view that will be a critical part of a database system I am working on, and would appreciate some advice. Apologies for the length of this posting! I have a parent table P and to child tables A and B,: CREATE TABLE p ( id INT NOT NULL PRIMARY

Re: [SQL] above the date functionssssssss

2006-07-11 Thread Stuart
2') | "-" | date_trunc('year', DATE '2005-02-12'); Stuart -Original Message- >From: "Penchalaiah P." <[EMAIL PROTECTED]> >Sent: Jul 11, 2006 7:34 AM >To: pgsql-sql@postgresql.org >Subject: [SQL] above the date function

Re: [SQL] REPOST[GENERAL] Quoting for a Select Into - Please Help

2004-01-14 Thread Stuart Barbee
Alex, Postgres's "select into" does not work like oracle. The "select into" for postgresql creates another table. Try this; select aliasvalue || trim(arrayval[i]) into newtablename from currenttablename where trim(searchfield) like '%' || trim(sea

Re: [SQL] SQL query problem

2003-10-09 Thread Stuart Barbee
Marek, Not sure but, try switching the lines db_data.mda_mod_con _CON, db_data.set_mda_fue _FUE with db_data.set_mda_fue _FUE, db_data.mda_mod_con _CON so there query is: SELECT _CON.con_id, _MOD.mod_ty, _VER.version, _YEA.year, _CON.dri_id, _CON.man_cod, _ENG.eng_p

[SQL] Auto-update a field when record is changed

2003-08-22 Thread Stuart
be able to update such a field automatically anytime a record was updated. Any help would be appreciated. Thanks, Stuart ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Count dates distinct within an interval

2003-07-15 Thread Stuart
up using immutable funtions to aid the query, or just a function to do it. However I think this does what you asked in a query. I've put a script at the end. hth, - Stuart -- s is the stuff to group by -- dt is the datetime thing create table Q ( s int4, dt timestamptz); truncate Q; IN

Re: [SQL] Cannot insert dup id in pk

2003-07-15 Thread Henshall, Stuart - TNP Southwest
he current maximum+1 hth, - Stuart P.S. Sorry about the format change the disclaimer adder forces > -Original Message- > From: Scott Cain [mailto:[EMAIL PROTECTED]] > Sent: 15 July 2003 14:00 > To: [EMAIL PROTECTED] > Subject: [SQL] Cannot insert dup id in pk > > > THI

Re: [SQL] sort for ranking

2003-07-09 Thread Henshall, Stuart - TNP Southwest
Title: RE: [SQL] sort for ranking Could you do something like the following: SELECT sum_user,(SELECT count(sum_user)+1 FROM tbl_sums AS t WHERE t.sum_user>tbl_sums.sum_user) AS ranking FROM tbl_sums ORDER BY ranking hth, - Stuart P.S. Sorry about format change, the disclaimer adder forces

[SQL] Inheritance and Referencial Integrity

2003-05-28 Thread Stuart
I'm using 7.3.2 which extends the inheritance of some checks and triggers to inherited tables, but still falls short of foreign key referencees looking into child tables. Are there plans to address these defficencies and when might we see this take place. Thanks S

Re: [SQL] Problem with timestamp

2002-12-11 Thread Henshall, Stuart - Design & Print
into t2 now(); > t3 := t2 - t1; > RAISE NOTICE '' from % to % = %'',t2,t1,t3; >     return t3; > > end; > ' language 'plpgsql'; > use timeofday(); as the others have the same value throughout the transaction - Stuart

Re: [SQL] How does postgres handle non literal string values

2002-11-26 Thread Henshall, Stuart - Design & Print
;"+username+"', '"+password+"')"; %> to actually concatonate a string including the username & password variables, however I've not really used Java much so you might want to ask on the [EMAIL PROTECTED] list. hth, - Stuart [EMAIL PROTECTED] w

[SQL] Two TIMESTAMPs in one pl/sql function

2002-11-26 Thread Rison, Stuart
bove, the timer1 and timer2 TIMESTAMPs are always identical. Any help/pointers/suggestions appreciate... well of course a working solution would be the best ;) Cheers, Stuart. ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

[SQL] [SQL/BUGS] (possible) inconsistent behaviour of timestamp?

2002-11-26 Thread Rison, Stuart
-- 2002-11-26 13:47:34.88358+00 (1 row) testdb2=# select timestamp 'now'; timestamptz --- 2002-11-26 13:47:47.701731+00 (1 row) The first SELECT returns a 'timestamp', but the next two return a 'timestamptz'

Re: [SQL] help optimise this ?

2002-11-21 Thread Henshall, Stuart - Design & Print
use pgsqlism how about: select file_md5 from image_instance WHERE     md5 = '546b94e94851a56ee721f3b755f58462' AND     image_width between 0 and 160 AND     image_length between 0 and 160 AND     ORDER BY image_width::int8*image_length::int8 LIMIT 1 This should get the smallest overall image size within your bounds. It might be faster to do ORDER BY image_width,image_length LIMIT 1 but this wouldn't necessarily give the smallest if the aspect ratio changed hth, - Stuart    

Re: [SQL] trying to learn plpqsql... so please forgive..

2002-11-20 Thread Henshall, Stuart - Design & Print
or things I may do wrong? > > TIA, > Michiel > > Trigger functions can only return type OPAQUE which isn't seen by the client program. To get the value of the serial field for the last insert do: SELECT currval('TableName_SerialFieldName_seq'); This will get the last value from the sequence used by this connection (although it will error if no values have been requested). hth, - Stuart

Re: [SQL] Copying a rowtype variable.

2002-11-07 Thread Rison, Stuart
Josh has submitted an appropriate report to pgsql-bugs... so perhaps it will happen! Stuart. > -Original Message- > From: Jean-Luc Lachance [mailto:jllachan@;nsd.ca] > Sent: 07 November 2002 16:29 > To: Rison, Stuart > Cc: ''[EMAIL PROTECTED]' ';

Re: [SQL] Copying a rowtype variable.

2002-11-06 Thread Rison, Stuart
dn't work either! > I'll tinker later today; there has to be a way to do it. I'd definitely appreciate further suggestions, but thanks all the same for you help. I have a feeling that you might have to write a PL function to perform the operation... but I haven't really thought about it! Stuart. ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] Copying a rowtype variable.

2002-11-05 Thread Rison, Stuart
accomodate rowtypes for which the fields are not known "a priori". Any clever workarounds? Cheers, Stuart. PS. I started using PGSQL five years ago... then I had to leave it alone for a while... I can't believe how much it's grown and developed. AMAZING, congra

Re: [SQL] ORDER the result of a query by date

2002-10-24 Thread Henshall, Stuart - Design & Print
t regards > -- > Javier >  ORDER BY year,month,day should do it. hth, - Stuart

Re: [SQL] Deleting obsolete values

2001-10-18 Thread Henshall, Stuart - WCP
DELETE FROM partitur WHERE EXISTS (SELECT * FROM partitur AS ss_partitur WHERE ss_partitur.userid=partitur.userid AND ss_partitur.ts>partitur.ts); Seems like it should seems like it should delete all old values (however I have not tested it) - Stuart > -Original Message- > Fro

Re: [SQL] Text/Image, JSP tomcat. How can I operate the text and image

2001-10-18 Thread Henshall, Stuart - WCP
Have a look at lo_import and lo_export. Can handle chunks at a time Also bytea type. You have to handle complete items with this. Although it'd need some formating. I believe zeros go to \000, ' to \' and \ to \\ as a bare minimum, but am not at all sure on that. - Stuart > ---

Re: [SQL] referencial conlumn contraints and inheritance

2001-10-17 Thread Stuart
be able to manage the data with tools on other platforms. I guess I will have to give potential alternatives more consideration. Thanks again, Stuart ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an

Re: [SQL] Why would this slow the query down so much?

2001-10-16 Thread Stuart Grimshaw
On Monday 15 October 2001 16:12 pm, Tom Lane wrote: > Stuart Grimshaw <[EMAIL PROTECTED]> writes: > > SELECT a.category, b.headline, b.added, c.friendlyname > > FROM caturljoin as a > > INNER JOIN stories as b ON (a.url = b.source) > > INNER JO

[SQL] Why would this slow the query down so much?

2001-10-15 Thread Stuart Grimshaw
I have 3 tables that I am trying to join together: -- Table "caturljoin" Attribute | Type | ---+-+ category | integer | url | integer | Index: caturljoin_url caturljoin_cat Table "stories" Attribute |

[SQL] referencial conlumn contraints and inheritance

2001-10-14 Thread Stuart
subselects in check constraints.  It would be nice to allow reference checking through the inherited tables so destination.area_id would be valid for any country, state, or city area_id entered. create table destination ( . area_id char(10) references areas ..., . .); Thanks, Stuart

Re: [SQL] GRANT ALL ON TO GROUP failure

2001-09-04 Thread Henshall, Stuart - WCP
d the same for group reader and included any caps reader will need to be quoted and in the same case. - Stuart > -Original Message- > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]] > Sent: Monday, September 03, 2001 5:35 PM > To: [EMAIL PROTECTED] > Subject: GRAN

Re: [SQL] Help On Postgresql

2001-08-31 Thread Henshall, Stuart - WCP
n int4 with a default value of nextval(''). - Stuart > -Original Message- > From: Jaydip [SMTP:[EMAIL PROTECTED]] > Sent: Thursday, August 23, 2001 8:51 AM > To: [EMAIL PROTECTED] > Subject: Help On Postgresql > > Dear Friends > > I am Jaydip Dewanj

[SQL] RE: Sequential select queries...??

2001-08-21 Thread Henshall, Stuart - WCP
T ((name=description) IS NULL) AND (name=description) AS both FROM t WHERE name='bleh' OR description='bleh' GROUP BY NOT ((name=description) IS NULL AND (name=description); I think this should be more efficient than UNIONs, but am not an expert on the query planner or exe

[SQL] Re: how can we get total records in pg server?

2001-07-25 Thread Henshall, Stuart - WCP
'plpgsql'; You'll also need to have the plpgsql language created for your database (eg: createlang plpgsql testdb) then just execute the above script then select cnt_rows(); in psql. -Stuart ORIGINAL MESSAGE: hi all, consider the pg server with databases bhuvan uday guru the need i

RE: [SQL] How to represent a tree-structure in a relational database

2000-12-13 Thread Stuart Statman
s this table structure (I don't know if he's giving it > out, but he said it wasn't very difficult). We've done a similar thing for Java. It was ridiculously easy to create a TreeModel wrapped around this data. Almost too easy; it made me feel dirty. Stuart Statman Directo

RE: [SQL] How to represent a tree-structure in a relational database

2000-12-13 Thread Stuart Statman
y b is a subcategory of subcategory c, where I'm not sure your model will preserve or guarantee that. (Does that sentence deserve a prize?) In general, if you know that you will need to periodically alter a table to add columns, you should come up with a different model that doesn't r

RE: [SQL] How to represent a tree-structure in a relational database

2000-12-13 Thread Stuart Statman
ion, I guess. The problem with this method is if you need to insert a category, or move a category. You'll need to re-id a bunch of categories, and bubble those changes out to every table that refers to this table. Stuart Statman Director of Software Development Slam Media, Inc. BEGIN:VCARD

RE: [SQL] sum of agreggates in one SELECT?

2000-09-19 Thread Stuart Foster
Could it be that the first query is using max which will only return the max for b.lot and b.price.. so maybe. select sum(max(b.lot))as quantity, max(b.price) as price from bid b, person p where b.auction_id = 84 and p.id = b.person_id ; Just a thought. -Original Message- From: [EMAIL

[SQL] Where to get benchmark testing

2000-09-15 Thread Stuart Foster
I'm not sure this is the right list for this but maybe someone could point me in the right direction. We are getting some DB servers to test performance. I was wondering if anyone knows where we can get a test script of sorts that would allow us to check performance on each of the servers. TIA

RE: [SQL] How can I select all of the tables with field name 'area'?

2000-09-11 Thread Stuart Foster
You should be able to query the system table that holds that column names. Not sure which it is tho. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of G. Anthony Reina Sent: Monday, September 11, 2000 4:38 PM To: [EMAIL PROTECTED] Subject: [SQL] How can I s

Fw: [SQL] Viewing a function

2000-08-29 Thread stuart
-Original Message- From: Stuart Foster <[EMAIL PROTECTED]> To: PG-SQL <[EMAIL PROTECTED]> Date: Wednesday, 30 August 2000 2:25 Subject: [SQL] Viewing a function Helllo Stuart, Good question. I have been fiddly with a function editor using zeos controls and I have lo

[SQL] Viewing a function

2000-08-29 Thread Stuart Foster
How can a view a function after it's created ? I've created a SQL function that I need to review and possibly change. What is the best way to go about this. TIA

[SQL] Test

2000-08-28 Thread Stuart Foster
Please ignore. Thanks