[SQL] How to make a IN without a table... ?

2003-06-08 Thread David Pradier
e to maintain...) I really don't see how to do this :-/ Any help is heartfully welcome, David -- [EMAIL PROTECTED] 01.46.47.21.33 ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

[SQL] How to make a IN without a table... ?

2003-06-12 Thread David Pradier
s of code to maintain...) I really don't see how to do this :-/ Any help is heartfully welcome, David -- [EMAIL PROTECTED] 01.46.47.21.33 ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] How to make a IN without a table... ?

2003-06-12 Thread David Pradier
27;t even want to think about adding temporary tables, brrr ! > And COPY FROM STDIN offers a real fast way to populate. > BTW, why using SQL at all? Couldn't perl do the job much easier? I guess i wasn't clear enough. "my_function" here is a function which ca

Re: [SQL] How to make a IN without a table... ?

2003-06-12 Thread David Pradier
On Thu, Jun 12, 2003 at 07:09:29AM -0500, Bruno Wolff III wrote: > On Thu, Jun 12, 2003 at 13:50:27 +0200, > David Pradier <[EMAIL PROTECTED]> wrote: > > > > I guess i wasn't clear enough. > > "my_function" here is a function which calculate some r

Re: [SQL] How to make a IN without a table... ?

2003-06-12 Thread David Pradier
oph The arguments of the functions come from outside the database, but the function itself uses the datas in the database. Like "Tell me how much i spent between the 4th and the 7th og this month ?" uses 4 and 7 as arguments, but need to fetch the datas in the database. Clear enough ? :-) Wh

Re: [SQL] How to make a IN without a table... ?

2003-06-12 Thread David Pradier
On Thu, Jun 12, 2003 at 02:37:00PM +0200, Christoph Haller wrote: > > > > Like "Tell me how much i spent between the 4th and the 7th og this > month > > ?" uses 4 and 7 as arguments, but need to fetch the datas in the > > database. > > Clear enough ? :-) > Yes. > > > > What do you mean by table fun

Re: [SQL] How to make a IN without a table... ?

2003-06-16 Thread David Pradier
> > I avoid as hell to use temporary tables. This is part of a complex > > database, with more than 250 different tables. So i don't even want to > > think about adding temporary tables, brrr ! > > Just FYI, temporary tables in pgsql are invisible to other connections > even if they have the same

Re: [SQL] Inquiry From Form [pgsql]

2003-07-02 Thread David Witham
test_table Table "public.test_table" Column | Type | Modifiers +-+--- col1 | integer | HTH. David -Original Message- From: Chris Schneider [mailto:[EMAIL PROTECTED] Sent: Thursday, 3 July 2003 05:26 To: [EMAIL PROTECTED] Subject: [SQL] Inquiry From F

Re: [SQL] Datatype conversion help

2003-07-08 Thread David Olbersen
Yasir, If this is a date you're playing with, simply use: to_char( , 'MM-DD-' ) to get what you want. -- David Olbersen iGuard Engineer St. Bernard Software 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 > -Original M

[SQL] Functional Indexes

2003-07-15 Thread David Olbersen
functional indexes, but that seems a bit silly to me. Any thoughts? -- David Olbersen iGuard Engineer St. Bernard Software 11415 West Bernardo Court San Diego, CA 92127 1-858-676-2277 x2152 ---(end of broadcast)--- TIP 1:

[SQL] Using a compound primary key

2003-07-27 Thread David Witham
QL 7.3.2? I can add another index just on prefix and get a performance increase but it's still not as cost-efficient as using the primary index. Would it be more cost effective to do a bunch of individual queries for each length of prefix until I find one that matches? The average length of a prefix would probably be around 3 digits and I would need to start at 8 digits and work back to cover all possibilities. Thanks for any advice, David Witham ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] Optional join

2003-08-15 Thread David Fetter
could be > table1... table2.pk2 > table1... NULL > Doable? Yes. SELECT table1.*, table2.pk2 FROM table1 LEFT OUTER JOIN table2 ON (table1.pk1 = table2.pk2); HTH :) Cheers, D -- David Fetter [EMAIL PROTECTED] http://fetter.org/ phone: +1 510 893 6100cell: +1 415

Re: [SQL] Inheritance or no inheritance, there is a question

2003-08-20 Thread David Fetter
_order ( issuer VARCHAR(255) NOT NULL , mo_num VARCHAR(64) NOT NULL ) INHERITS (payment); CREATE TABLE payment_wire ( payment_wire_desc VARCHAR(255) NOT NULL ) INHERITS (payment); Cheers, D -- David Fetter [EMAIL PROTECTED] http://fetter.

Re: [SQL] Migrating Stored Procedures from MS SQL Server

2003-08-29 Thread David Witham
reSQL doesn't support. You'll need to write some new code or at worst redesign your logic to work around the differences. I don't expect there would be automated tools that could do that for you.   Regards, David -Original Message-From: Kumar [mailto:[EMAIL PROTECTED]Sen

Re: [SQL] how to get decimal to date form

2003-09-20 Thread David Brown
seems to work but noticeably slows down the query. -David  Tomasz Myrta <[EMAIL PROTECTED]> wrote: > In our postgre database is a decimal field with format YYMMDDhhmmss.99> where the 9s are random digits. I'm trying to strip off just the> YYMMDD and put it in date form.&

[SQL] How to figure out when was a table created

2003-09-29 Thread David B
Folks, I have a list of tables for which I want to get the date they were created...and if possible the date last updateded. I suspect there is a pg_??? table that can answer this question but I don't know what it is and I cannot find it mentioned in any docs. Any suggestions...tia -D p.s. Love

[SQL] How to figure out when was a table created

2003-10-02 Thread David B
Hi folks, I posted this question a few days ago and got no response so I guess it cannot be done (surprising!) So that leaves me with my business problem. We create a table for each days activity. After N days (typically 7 days) we can drop the table. The table name is not known so cannot force b

[SQL] Referring to derived column name in a RECORD

2003-10-24 Thread David B
Hi folks, I know I'm doing something wrong here but cannot make it work no matter how many/few quotes I use I'm trying to reference a column in a RECORD which is not a column name but a derived column. Any suggestions??? Example code below to highlight the problem: DECLARE r_app RECO

[SQL] Fetch a single record

2003-12-09 Thread David Shadovitz
M myTable WHERE oid = anOID The 1st technique is slow. (I think PostgreSQL fetches all records and then returns just one.) The 2nd is faster, but not fast enough. Any other ideas? Please reply to me personally ([EMAIL PROTECTED]) as well as to the list. Thanks. -David ---

[SQL] Faster performance when using where cust_id = '123' vs cust_id = 123. Does 7.4 fix this??

2003-12-09 Thread David B
We have got used to the problem that queries of the format: select * from customer where cust_id = '123' are much much faster than select * from customer where cust_id = 123 (where cust_id is defined as bigint). a. Why is this. b. Will moving to v7.4 change this so we can avoid the whole '123'

[SQL] Left outer join on multiple tables

2004-01-11 Thread David Witham
Hi all, Is there a way to do left outer joins on more than 2 tables at once (3 in my case)? Or do I have to do the first join into a temp table and then another join from the temp table to the third table? I can't seem to work out the syntax from the User Guide. Thanks, David Witham Tele

[SQL] Transpose rows to columns

2004-01-12 Thread David Witham
so it displays like this: 991234,ABC,2003-07-01,10,15,5,2003-08-01,11,17,6,2003-09-01,12,19,7 991235,XYZ,2003-07-01,13,21,8,2003-08-01,12,19,7,2003-09-01,11,17,6 (I've used commas to shorten the layout for the example) Does anyone have some ideas on how to do this? Thanks, David W

[SQL] An order by question

2004-01-31 Thread David Arnold
All, I need a little help on a sorting problem. Imagine a table, call it records, that has fields: lastName firstName term I want to sort the records by last name, then first name, and finally by term. This almost does what I want: select * from records order by lastName, firstName, term; Howe

[SQL] determining how many products are in how many categories

2004-02-08 Thread David Garamond
# product table (simplified): create table p ( id char(22) not null primary key, name text, desc text ); # product category table (simpl.): create table pc ( id char(22) not null primary key, name text, desc text ); # table that maps products into categories: create table p_pc ( id ch

[SQL] Elegant way to monitor for changes in a trigger and migrate record to history table

2004-02-10 Thread David B
Folks, Perhaps you can helphell I'm sure you can! I want to monitor for changes in a table and migrate the OLD. record to audit table. Is there an elegant or generic way to do this so I can use across multiple tables with little change. E.g. IF TG_OP = 'UPDATE' THEN INSERT INTO cust_hist

[SQL] Index question

2004-02-12 Thread David Witham
ndex Cond: (("day" >= '2004-01-27'::date) AND ("day" <= ('now'::text)::date)) (3 rows) I understand that selecting count(*) will involve a scan at some stage, but I was surprised that the index wasn't used in the >= case, but was used in the b

Re: [SQL] Index question

2004-02-12 Thread David Witham
magnitude too low. However, it used the index I wanted and the >= case didn't. Regards, David -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Friday, 13 February 2004 16:38 To: David Witham Cc: [EMAIL PROTECTED] Subject: Re: [SQL] Index question "David

[SQL] Indexes and statistics

2004-02-17 Thread David Witham
some parameters to alter that? Any suggestions appreciated. Thanks, David David Witham Telephony Platforms Architect Unidial, Australia ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "u

Re: [SQL] Indexes and statistics

2004-02-17 Thread David Witham
e. I hope this makes sense. Does it help any? Thanks, David -Original Message- From: Tom Lane [mailto:[EMAIL PROTECTED] Sent: Wednesday, 18 February 2004 16:10 To: David Witham Cc: [EMAIL PROTECTED] Subject: Re: [SQL] Indexes and statistics "David Witham" <[EMAIL PROTECTED]&g

[SQL] ANALYZE error

2004-03-08 Thread David Witham
m I run at 1am but I don't think it would take an hour to run. Occasionally I get this error message from the analyze job: ERROR: simple_heap_update: tuple concurrently updated What does this mean and should I do anything about it? Thanks, David Witham Telephony Platforms Architect Un

Re: [SQL] Line length in pl/pgsql function

2004-03-17 Thread David Olbersen
yslog output was different. I can attach both if that's helpful. Any more info needed? -- David Olbersen iGuard Engineer St. Bernard Software 15015 Avenue of Sciences San Diego, CA 92127 x2152 psql:test_ratedby_category_lang.plsql:1: ERROR: Relation 'ratedby_return_set' already

Re: [SQL] Line length in pl/pgsql function

2004-03-17 Thread David Olbersen
; > at character 3419 psql:test_ratedby_category_lang.plsql:95: LINE 81: > -- none,everything = don't show the language... > psql:test_ratedby_category_lang.plsql:95: > ^ That would have been handy! -- David Olbersen iGuard Engineer St. Bernard Software 15015 Av

Re: [SQL] Line length in pl/pgsql function

2004-03-17 Thread David Olbersen
David Olbersen wrote: > *sigh* I'd rather have pilot error than having to wait for a patch :) Hmmm, that doesn't look right in retrospect. What I meant to say was THANK YOU TOM! -- David Olbersen iGuard Engineer St. Bernard Software 15015 Avenue of Sciences San Diego, C

[SQL] Sorting an aggregated column

2004-03-22 Thread David Witham
| y, n, y, 123, 21, 1 2 | y, y, y, 3, 2, 1 This output is correct in this case but there is no guarantee that the answers will come out in "question" order. I can't see how to incorporate sorting by the "question" column using this approach. Can anyone suggest e

Re: [SQL] Sorting an aggregated column

2004-03-22 Thread David Witham
y had already sorted by survey (along with question), would the sort by survey bother to reorder any of the rows? E.g. if the subselect returned (assuming 1 answer from the 3 answer columns): 1,t 1,f 1,t 1,123 1,21 1,1 2,t 2,t 2,t 2,3 2,2 2,1 would the sort by survey potentially reorder th

[SQL] Syntax for cmd to EXEC...how many quotes?

2004-04-20 Thread David B
Folks, This is driving me crazy...I'm sure it's possible but that I am getting the #quotes wrong in some way... I keep getting unterminated string errors...now matter how many quotes I use. I have a FN that I want to loop through all views and populate a table with a count(*) from each views. To

[SQL] Row counts/data changes. Any catalog table that has this info?

2004-06-05 Thread David B
Folks, Is there a catalog table or location where I can go to find data counts for tables? It would be nice if I could do a query which returned something like: table_name#Rows cust 1000 order 5000 order_detail 9500 without having to have the overhead of querying each tabl

[SQL] In 7.4 ensure you have DEFAULT now () with no spaces

2004-06-18 Thread David B
Just a heads up folks... In converting from 7.3 to 7.4 one got-ya we had was... We had been testing 7.4 for a few days and just noticed that some tables had created_timestamp rows with a date/time of the date the DB was created...not the date/time the insert was done. Looking at those tables the

[SQL] Help with sql statement grouping and distinct

2004-07-09 Thread David Inglis
rrect number of columns in the in statement but how do I achieve the above Any help appreciated Thanks Regards David Inglis This message was sent using IMP, the Internet Messaging Program. ---(e

Re: [SQL] surrogate key or not?

2004-07-24 Thread David Garamond
Josh Berkus wrote: > Given: Surrogate keys, by definition, represent no real data; > Given: Only items which represent real data have any place in > a data model > Conclusion: Surrogate keys have no place in the data model But, once a surrogate key is assigned to a row, doesn't it become

[SQL] New PHP + PostgreSQL group on Google Groups2

2004-08-06 Thread N. David
Hello. I have created a new group in the Google Groups beta site for PHP + PostgreSQL development. This group is for questions on advanced web development with PHP and PostgreSQL using Linux. Topics include functions, regular expressions, classes (OOP), speed, security, editor customization, SQL,

[SQL] UPDATE FROM problem, multiple updates of same row don't seem to work

2004-08-09 Thread David Stanaway
tablea; id | flag +-- 1 |1 2 |1 -- Desired output is id | flag +-- 1 |7 2 |5 Is there a way around this so that I can get the desired output? -- David Stanaway <[EMAIL PROTECTED]> ---(end of broadcast)-

[SQL] Displaying two tables side by side

2004-08-11 Thread David Garamond
How can you display two tables side by side? Example: > select * from t1; a | b ---+--- 2 | 2 3 | 5 4 | 7 9 | 0 > select * from t2; c | d ---+--- 4 | 5 7 | 3 3 | 2 1 | 1 2 | 0 Intended output: a | b | c | d ---+---+---+--- 2 | 2 | 4 | 5 3 | 5 | 7 | 3 4 | 7 | 3 | 2 9 | 0 | 1 | 1 |

Re: [SQL] Displaying two tables side by side

2004-08-11 Thread David Garamond
Andreas Haumer wrote: You could try to use PosgreSQL's ctid system column to join on like this: test=# select *,ctid from t1; a | b | ctid - ---+---+--- 2 | 2 | (0,1) 3 | 5 | (0,2) 4 | 7 | (0,3) 9 | 0 | (0,4) test=# select *,ctid from t2; c | d | ctid - ---+---+--- 4 | 5 | (0,1) 7 |

[SQL] olympics ranking query

2004-08-20 Thread David Garamond
See http://www.athens2004.com/en/OlympicMedals/medals?noc=MGL . create table countrymedal ( countryid CHAR(3) PRIMARY KEY, gold INT NOT NULL, silver INT NOT NULL, bronze INT NOT NULL); COPY countrymedal (countryid, gold, silver, bronze) FROM stdin; ITA 5 6 3 FRA 5

Re: [SQL] olympics ranking query

2004-08-20 Thread David Garamond
Tom Lane wrote: Challenge question: is there a simpler way to do query #1 (without any PL, and if possible without sequences too? Can't without sequences AFAIK, but you certainly can do it simpler: select setval('seq1', 0); select nextval('seq1'), * from (select count(*) as numranker, gold, silve

Re: [SQL] olympics ranking query

2004-08-20 Thread David Garamond
Bruno Wolff III wrote: On Fri, Aug 20, 2004 at 23:40:08 +0700, David Garamond <[EMAIL PROTECTED]> wrote: Challenge question: is there a simpler way to do query #1 (without any PL, and if possible without sequences too? You could use a subselect to count how many countries had a lower

[SQL] Optimizer Selecting Incorrect Index

2004-08-25 Thread David Price
I have 2 servers both with the exact same data, the same O.S., the same version of Postgres (7.4.5) and the exact same db schema's (one production server, one development server). One server is using the correct index for SQL queries resulting in extremely slow performance, the other server is pro

[SQL] Interpolation and extrapolation in SQL

2004-09-13 Thread David Garamond
On my first try, interpolation and extrapolation turns out to be pretty easy to do. In psql: -- the "lookup" table CREATE TABLE p ( x DOUBLE PRECISION NOT NULL UNIQUE, y DOUBLE PRECISION NOT NULL ); INSERT INTO p VALUES (1,1); INSERT INTO p VALUES (2,5); INSERT INTO p VALUES (5,14); INSERT I

[SQL] Aggregate Function with Argument

2004-10-18 Thread David Siegal
1 David 1 Sanjay 1 Marie 2 Josh 2 Rani ... ...a query like: SELECT team_number, aggregated_concat(member_name, ', ' ) AS members FROM team GROUP BY team_number; ...would return: team_numbermembers -

Re: [SQL] Aggregate Function with Argument

2004-10-25 Thread David Siegal
Mark, Works beautifully. Thanks for the clear explanation and code! -David On Tue, 19 Oct 2004, Mark Gibson wrote: > David Siegal wrote: > > I would like to create an aggregate function that returns a concatenation > > of grouped values. It would be particularly useful if

[SQL] Unicode problem inserting records - Invalid UNICODE character sequence found (0xfc7269)

2004-11-10 Thread David B
My first time using unicode. Based on reading other messages I think I've got it all setup correctly but still have prob. Running: psql 7.3.6-RH $ psql -l List of databases Name| Owner | Encoding ---+--+--- devdb | devuser | UNICODE template0 | pos

Re: [SQL] Unicode problem inserting records - Invalid UNICODE character

2004-11-11 Thread David B
show client_encoding gives: UNICODE databases reads: DATABASE OWNER ENCODING mydb david UNICODE testdb david SQL_ASCII table columns are character varying(255) Tx, David -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Richard Huxton Sent

Re: [SQL] [Dbdpg-general] [ANNOUNCE] pgtop, display PostgreSQL processes in `top' style

2005-05-06 Thread David Wheeler
/ ... ? I think so, but you have to enable some postgresql.conf settings to get that information logged. http://www.postgresql.org/docs/8.0/static/runtime-config.html Regards, David ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] ORDER BY handling mixed integer and varchar values

2005-05-16 Thread David B
Hi All, I have a tabe Product_desc varchar(100) Product_price integer Product_catvarchar(100) The problem… We have categories such as: Electronics White Goods 1 2 5 15 25 etc I have a query Select product_desc, product_price, product_cat Order by product_cat, product_price And of cours

[SQL] View unique rowid

2005-06-01 Thread David Klugmann
, position as planetposition, position+angle as transitposition from personplanet, aspect union select personid, planet, name as aspectname, position as planetposition, position-angle as transitposition from personplanet, aspect where name != 'OPPOSITION'; Many thanks David ---

Re: [SQL] View unique rowid

2005-06-01 Thread David Klugmann
Many thanks I think the problem with using the oid from the primary table is that may rows in the view definition will get the same oid because of the union. Thanks very much anyway. I will look at the temporary sequence although I am not sure if sequences work with views. Regards David

[SQL] Rule

2005-06-08 Thread David Hofmann
of rule so that whenever a s_data field is updated, that the time_stamp gets update to the current time/date. The program regretab I'm not really familar with rules, I've only used them in a certain places and very limitedly. Any help would be greatly appercated. Dav

Re: [SQL] Rule

2005-06-08 Thread David Hofmann
Ok, I have no knowledge of Tiggers except what I just read in the docs section. Look like I need to make a procudure then call it with a trigger. Is there a better location for Tigger/Procudure Examples. The trigger seems fairly, however I got lost in the procudure part. David Normally

Re: [SQL] Putting an INDEX on a boolean field?

2005-06-16 Thread David Dick
how about an very large table with a "processed" type flag? uru -Dave Marc G. Fournier wrote: Does that make sense? Would it ever get used? I can't see it, but figured I'd ask ... Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) Email: [EMAIL PROTECTED]

Re: [SQL] UPDATEABLE VIEWS ... Examples?

2005-06-20 Thread David Pradier
> Reading through the docs, both the CREATE VIEW and CREATE RULE pages refer > to how you can use a RULE to 'simulate' an updateable VIEW ... but I can't > seem to find any examples of this ... This is maybe a newbie question, but what is the difference with a ma

Re: [SQL] UPDATEABLE VIEWS ... Examples?

2005-06-20 Thread David Pradier
st execution of the view Thanks Jaime, it's perfectly clear now. David -- [EMAIL PROTECTED] - tel: 01.46.47.21.33 - fax: 01.46.47.21.37 ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your join

Re: [SQL] UPDATEABLE VIEWS ... Examples?

2005-06-20 Thread David Pradier
perspectives in programmation, methinks :-) Thanks all the same, David -- [EMAIL PROTECTED] - tel: 01.46.47.21.33 - fax: 01.46.47.21.37 ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Dynamic Offset Determination

2005-07-13 Thread David Blankley
I came up with a clever solution to this myself... I know the determined value for my CriteriaCol, so I can simply get the count of all the rows with criteria <= my value... SELECT count(*) FROM foo WHERE CriteriaCol<=constraint ORDER BY OrderCol; Thanks, Dave --

[SQL] Dynamic Offset Determination

2005-07-13 Thread David Blankley
Problem Statement: I want to return n rows from a table. These n rows are relative to an offset. The part I can't figure out: The offset needs to be determined from values in the rows. Example: Given a table foo: CriteriaCol integer OrderedCol integer I can figure out the number of rows

[SQL] Tigger

2005-07-22 Thread David Hofmann
ny help or suggestions of websites I should read would be appercated. David _ Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Re: [SQL] Tigger

2005-07-22 Thread David Hofmann
I'm using 7.3. From: Bricklen Anderson <[EMAIL PROTECTED]> To: David Hofmann <[EMAIL PROTECTED]> CC: pgsql-sql@postgresql.org Subject: Re: [SQL] Tigger Date: Fri, 22 Jul 2005 12:17:41 -0700 David Hofmann wrote: > I've look throught the docs and from what I can see the

Re: [SQL] Tigger

2005-07-22 Thread David Hofmann
T OR UPDATE ON sessions FOR EACH ROW EXECUTE PROCEDURE session_update(); I appercated the help Bricklen. David From: Bricklen Anderson <[EMAIL PROTECTED]> To: David Hofmann <[EMAIL PROTECTED]> CC: pgsql-sql@postgresql.org Subject: Re: [SQL] Tigger Date: Fri, 22 Jul 2005 12:28:

[SQL] Tidying values on variable instantiation

2005-08-25 Thread Bath, David
Has anybody got a code sample that might do something similar. Apologies if I have missed something obvious in the manual, or if it is a well-known item in the wish-lists, but I am very new to serious Pg work, and have a tight schedule to do deliver a schema. *sigh* Thanks in advance -- David T. Bat

[SQL] Equivalent of Oracle SQL%NOTFOUND in plpgsql

2005-09-05 Thread Bath, David
lind, not looking in the right spot, is it undocumented, or unimplemented? Thanks in advance -- David T. Bath [EMAIL PROTECTED] ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

[SQL] RULES on SELECT with JDBC/perlDBI from other RDBMS products?

2005-10-06 Thread Bath, David
/admin effort when porting to other platforms, as there would be few dependencies on things like external perl modules. If any pg developer gurus are reading this, perhaps such templates might be worthwhile including in the contrib bundle? -- David T. Bath [EMAIL PROTECTED] -

[SQL] Design problemi : using the same primary keys for inherited objects.

2005-10-14 Thread David Pradier
e D instance the same id 12343. It's possible as two instances of an object never inherit from a same instance of another object. The id seems to me absolutely bad, but I wouldn't know how to phrase why. Any suggestion ? Thanks in advance, David. -- David Pradier -- Directeur Techn

Re: [SQL] Design problem : using the same primary keys for inherited objects.

2005-10-14 Thread David Pradier
EY, arg1 type1, arg2 type2 ) CREATE TABLE person ( id_person INTEGER PRIMARY KEY REFERENCES actor, arg3 type3, arg4 type4 ) Don't you think it is a BAD design ? If it isn't, well, it will expand my database practices. David -- David Pradier -- Directeur Technique de Clarisys Inf

Re: [SQL] Design problem : using the same primary keys for inherited objects.

2005-10-17 Thread David Pradier
#x27;person' : user, physician, customer, etc... Do you continue to think that inheritance is the wrong relationship type here ? > It *is* a bad design. You should not do this. After all, how is that > any different than this? Well, not every line of actor are in laborato

Re: [SQL] Design problem : using the same primary keys for inherited objects.

2005-10-17 Thread David Pradier
pecified that not two laboratories could be the same actor, for example. That's why i think having a primary key referencing another primary key could technically work, but well, it seems to me BAD to mix two primary keys together. I'm still wondering... -- David Pradier -- Directeur Techniqu

Re: [SQL] Design problemi : using the same primary keys for inherited objects.

2005-10-17 Thread David Pradier
D]', 'arnie', 'arnie'); > INSERT INTO sys_user(sys_client_id, lu_user_type, f_name, m_name, l_name, > email_addr, uname, upwd) VALUES (1, 2, 'Roberto', 'Guiterrez', 'Amendola', > '[EMAIL PROTECTED]', 'arnie'

Re: [SQL] generating a sequence table against which to do a LEFT OUTER JOIN

2005-10-18 Thread David Fetter
FROM generate_series(0,'2005-02-01'::date - '2005-01-01'::date - 1) AS s(i); LEFT JOIN your_table t ON ('2005-01-01'::date + s.i = t.your_date_col); You can also use generate_series() with a correllated subquery so as not to have to hard-code dates. HT

Re: [SQL] NULL in IN clause

2005-10-19 Thread David Dick
As i understand it, the use of NULL in SQL means the value of the column is unknown. Therefore that result would seem fair. Havasvölgyi Ottó wrote: Hi, I have just run this command on 8.0.4 : SELECT 'foo' WHERE 0 NOT IN (NULL, 1); And it resulted is zero rows. Without NULL it is OK. Is this

[SQL] ?Equiv to oracle (ENABLE|DISABLE) (CONSTRAINT|TRIGGER) statements?

2005-10-25 Thread Bath, David
en issued by someone with DBA privs (and maybe the target object owner, although I imagine reasons that /might/ be a bad idea for paranoid info management governance). Thanks in advance -- David T. Bath [EMAIL PROTECTED] ---(end of broadcast)--

Re: [SQL] why vacuum

2005-10-25 Thread Bath, David
ath (Oracle DBA for health/telcos way back in 1986: honeywrong GCOS and Pr1mos) -- David T. Bath [EMAIL PROTECTED] ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Yes, pg does triggers first before asserting check constraints! Was Re: [SQL] why vacuum

2005-10-26 Thread Bath, David
Tom, After I wrote > > Sybase/MS-SQL's check constraint model asserts the constraint > > BEFORE the trigger, which discourages you from attempting to> > > check and handle meaning of data! you wrote (2005-10-26 17:00) > Er, doesn't PG do it that way too? Well, it works for me! In this case (wit

[SQL] Index lookup on > and < criteria

2005-11-01 Thread David Durham
Apologies if this questions is asked often. I'm doing some select statements based on a timestamp field. I have an index on the field, and when I use the '=' operator the index is used. However, if I use the '>' or '<' operators, then it does a full table scan. I've got around 6 million row

Re: [SQL] Index lookup on > and < criteria

2005-11-01 Thread David Durham
Michael Fuhr wrote: No need to guess: run the queries with enable_seqscan disabled and see if an index scan is indeed faster. select max(myTimeStamp) from myTable; In current releases min() and max() can't use indexes; search the archives for numerous discussions of the reasons. The work

Re: [SQL] Index lookup on > and < criteria

2005-11-02 Thread David Durham
Yeah, analyze did make a difference. See below. -- Index Scan using october_begin_time on october_cdr_call (cost=0.00..98383.82 r ows=24594 width=568) (actual time=0.280..79274.579 rows=538592 loops=1) Index Cond: ((beg

[SQL] selective dump pg_dump: only specific non-tables? with schema name?

2005-11-13 Thread Bath, David
objects that include the schema prefix "inline" e.g. CREATE FUNCTION "fred"."func1" 3. Can I pg_dump "CREATE OR REPLACE" rather than straight "CREATE", especially for functions? -- David T. Bath [EMAIL PROTECTED] --

Re: [SQL] idea for a geographically distributed database: how best to implement?

2005-11-21 Thread Bath, David
nclosing the entire region by x%. Yep, "squaring the circle" and "circling the square" are useful in the real world. 4) There are a lot of useful bits and pieces at opengis.org and postgis.org 5) There are many useful GIS functions in postgres to decide if a point is ins

[SQL] Updatable views: any decent front-ends?

2005-11-24 Thread Bath, David
s suitable for default screen prompts and report headings. I am being wrong-headed here? -- David T. Bath [EMAIL PROTECTED] ---(end of broadcast)--- TIP 6: explain analyze is your friend

[SQL] Order of precedence between AND and OR.

2005-11-25 Thread David Pradier
etween AND and OR, that is if the AND expression is calculated before the OR one, or anyelse way. Could somebody tell me or point me to the right doc ? Thanks in advance, David -- David Pradier -- Directeur Technique de Clarisys Informatique -- Chef de projet logiciels libres / o

[SQL] order and order line item

2005-12-27 Thread David Garamond
Suppose we have the usual order & order line item entities: CREATE TABLE "order" ( id INT PRIMARY KEY, date DATE NOT NULL ); CREATE TABLE orderlineitem ( id INT PRIMARY KEY, orderid INT REFERENCES "order"(id), seq INT NOT NULL, CONSTRAINT con1 UNIQUE (orderid, seq), produc

[SQL] constraint and ordered value

2005-12-27 Thread David Garamond
Is it possible to use only CHECK constraint (and not triggers) to completely enforce ordered value of a column (colx) in a table? By that I mean: 1. Rows must be inserted in the order of colx=1, then colx=2, 3, and so on; 2. When deleting (or updating), "holes" must not be formed, e.g. if there a

Re: [SQL] constraint and ordered value

2005-12-29 Thread David Garamond
Daryl Richter wrote: >> No. A constraint only applies to one row at a time. If you try to >> work around >> this by calling a function that does queries it isn't guarenteed to >> work. >> And if you are thinking of calling a function that does a query, you >> aren't >> looking at saving time ove

[SQL] system view corrupted, i get "unexpected right parenthesis" for many system tables.

2006-01-09 Thread David Ford
sno 8 :restype 1009 :restypmod -1 :resname useconfig :ressortgroupref 0 :resorigtbl 1260 :resorigcol 8 :resjunk false} :expr {VAR :varno 3 :varattno 8 :vartype 1009 :vartypmod -1 :varlevelsup 0 :varnoold 3 :varoattno 8}}) :groupClause <> :havingQual <> :distinctClause <> :sortClause <> :limitOffset <> :limitCount <> :setOperations <> :resultRelations <>}) (1 row)can anyone help me restore this correct function of this view rule in the backend for pg_rewrite?thank you,david-- It's the ideals of Linux and Open Source that are amazing, it embodies what WE want, not what is marketed Once you lose the greatest of all things, it's the memories you cherish for all time.  He was the best, I could have been better.

Re: [SQL] system view corrupted, i get "unexpected right parenthesis" for many system tables.

2006-01-09 Thread David Ford
options left to try but i might be reduced to stitching together COPYs and system tables from an older backup. On 1/9/06, Tom Lane <[EMAIL PROTECTED]> wrote: David Ford <[EMAIL PROTECTED]> writes:> i encountered this when trying to do a pg_dumpall in preparation for moving> from 8.0

Re: [SQL] system view corrupted, i get "unexpected right parenthesis" for many system tables.

2006-01-09 Thread David Ford
that's ok, i found a working solution with 8.0.5 +pg-hier (8.0.1 wouldn't work + or -pg-hier), so i got things dumped, upgraded, and running.  thank you to you and the guys on #postgresql very much for your assistance :) davidOn 1/9/06, Tom Lane <[EMAIL PROTECTED]> wrote: Da

Re: [SQL] How to implement Microsoft Access boolean (YESNO)

2006-01-29 Thread Bath, David
e me 0=no or all_bits_on=yes (which because MS lacks "unsigned", is -1). -- David T. Bath System Analyst, Challenge Logistics 75-85 Nantilla Road, Clayton North Vic 3168 Voice: 131323 Fax: +613 8562 0002 [EMAIL PROTECTED] IMPORTAN

Re: [SQL] create table and data types

2006-02-14 Thread Bath, David
urse, more than a single table can be referenced in the FROM clause. -- David T. Bath [EMAIL PROTECTED] ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

[SQL] Disabling triggers/constraints pg<8.1

2006-02-26 Thread Bath, David
ables constraints (even if this does not include those involving indices such as primary or unique constraints)? 3. How "evil" are such queries? Should they be avoided wherever possible? What other "gotchas" should I watch out for? Thanks in advance -- David T. Bath

[SQL] Dump/restore comments only?

2006-02-26 Thread Bath, David
ions that might help me? (If there are no such options for dump/restore, might these be useful inclusions in the future?) Thanks in advance. -- David T. Bath [EMAIL PROTECTED] ---(end of broadcast)--- TIP 4: Have you searched ou

[SQL] Lead and tail quotes with \pset fieldsep

2006-03-19 Thread Bath, David
t;,"bar Is there a way to use psql to give rows like 1234","blahblah","sdfgsg","foo","bar or is there another tool I should use. COPY doesn't deal with views and restrictions well so it is not an option. Thanks in advance -- David T. Bath [EMAIL PR

[SQL] Table design question

2006-06-01 Thread David Clarke
I'm reading Joe Celko's book SQL Programming Style for the second time and although I've been an OO developer for quite a few years I'm fairly green wrt SQL. Joe is obviously something of a curmudgeon and I would fall squarely into his newbie OO developer ordinal scale and I'm trying to avoid the

<    1   2   3   4   5   >