[SQL] Interval FAQ - please review

2001-08-16 Thread Josh Berkus
Folks, Please review this for inaccuracies before I post it to pgsql-newbie and the docs. -Josh FAQ: Working with Dates and Times in PostgreSQL This FAQ is intended to answer the following questions: Q: Where are the DATEADD() and DATEDIFF() functions in PostgreSQL? Q: How do I tell the

[SQL] Re: Interval FAQ - please review

2001-08-16 Thread Josh Berkus
DATEDIFF & DATEADD are more complicated than that. More importantly, I don't want to get into Function design in this article, which is aimed at newbies. If, however, anyone *does* have an online sample of one or both of these two functions, I'd love to

Re: [SQL] Re: Interval FAQ - please review

2001-08-16 Thread Josh Berkus
imestamp *without* time zone. Hmmm OK, I'll revise the A: but I *don't* want to go into Time Zone issues in this intro. Any docs I can link to? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete informa

Re: [SQL] Nested JOINs

2001-08-16 Thread Josh Berkus
n mind in this case that you cannot reference a. or b. in the SELECT list at the top, just c. because a. and b. exist only in the subselect. Now, go out and buy a copy of "SQL for Smarties". You'll be glad you did. -Josh Berkus __AGLIO DATABASE SOLUTIONS___

Re: [SQL] SQL Statement too long

2001-08-20 Thread Josh Berkus
st this question on the pgsql-jdbc list. It is unlikely that anyone on this list can help you, as this sounds like a JDBC problem. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL

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

2001-08-20 Thread Josh Berkus
eans that it is possible to get both your desired rowcounts out of a *single* query, using subselects. "SQL for Smarties" can help you learn to build this kind of query. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus

Re: [SQL] Simple SQL-syntax

2001-08-20 Thread Josh Berkus
to NrB... > > I've tried: > UPDATE tableA Set tableA.nrA = B.nrB From tableB B Where tableA.nrA = B.nrA; This should work. What error message are you getting? And what version of Postgres are you using? -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] user defined function question

2001-08-20 Thread Josh Berkus
s. Browse through and you should find them. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law fir

Re: [SQL] Simple SQL-syntax

2001-08-20 Thread Josh Berkus
e a bit. The syntax can be fussy, however. The following is perfectly valid in Postgres, although not 100% ANSI-92 kosher: UPDATE A SET 1 = B.2 FROM B WHERE A.2 = B.2 Fredrik's problem may be simply the table reference after SET; that's why I'd like to see his exact parse error

Re: [SQL] Simple SQL-syntax

2001-08-20 Thread Josh Berkus
total_of_items FROM (SELECT invoice_id, sum(item_amount) FROM invoice_items) iit WHERE iit.invoice_id = invoices.id; -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED]

Re: [SQL] Simple SQL-syntax

2001-08-20 Thread Josh Berkus
Folks, Ooops! Let me correct that example: UPDATE invoice SET invoice_total = total_of_items FROM (SELECT invoice_id, sum(item_amount) AS total_of_items FROM invoice_items) iit WHERE iit.invoice_id = invoices.id; Sorry to lead people astray. -Josh __AGLIO DATABASE

Re: [SQL] Getting 'n-1'th record.

2001-08-21 Thread Josh Berkus
t record, simply reverse the ORDER BY and take the second record. e.g.: If you want the next-to-last (n-1) record from: SELECT * FROM syslog ORDER BY entrytime; Then ask for: SELECT * FROM syslog ORDER BY entrytime DESC LIMIT 1 OFFSET 1; Easy, no? -Josh Berkus __AGLIO DATA

Re: [SQL] Primary vs Unique Index

2001-08-21 Thread Josh Berkus
__AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small businessesfax 621-2533 and non-profit organizations. San Francisc

[SQL] Should I worry?

2001-08-21 Thread Josh Berkus
Folks: Do I need to worry about this: pq_flush: send() failed: Broken pipe ... which appears in the log intermittently? __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED

Re: [SQL] Function returning an array

2001-08-23 Thread Josh Berkus
into 2 fields (e.g. 'element 1|element2') 2. Do the operation in your middleware, where you can use C, Java, Python or similar to pass arrays. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete inform

[SQL] Performance on large functions

2001-08-27 Thread Josh Berkus
n anyone point me in the right direction, or should I be posting this to a different list? -Josh Berkus P.S. Postgres 7.1.2 running on SuSE Linux 7.2 on a Celeron 500/128mb RAM/IDE HDD. __AGLIO DATABASE SOLUTIONS___ Josh Berkus C

[SQL] Date/Time FAQ posted

2001-08-27 Thread Josh Berkus
for users porting from MS SQL Server or SyBase. Grazie! -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565

Re: [SQL] WHERE on an alias

2001-08-27 Thread Josh Berkus
me to upgrade ;-) -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small businessesfax 621-2533 a

Re: [SQL] WHERE on an alias

2001-08-27 Thread Josh Berkus
t;) OUTSIDE the subselect ("ml.key = mll.key"). You can't reference columns from the main select inside a subselect except in an EXISTS clause. This does mean that you're going to need some approach other than the "limit 1" to limit the rows in your result set. Proba

Re: [SQL] WHERE on an alias

2001-08-27 Thread Josh Berkus
with a little nested subselect, but I'm having a lot of difficulty picturing what we're looking at. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data managemen

Re: [SQL] WHERE on an alias

2001-08-27 Thread Josh Berkus
ll.key1 and u.key2 = mll.key2 ORDER BY d.somefield LIMIT 25 OFFSET $pageno That should give you the utable and dtable records, plus the last serial value while executing the subselect only once per query call. Give it a spin. -Josh __AGLIO DATABASE SOLUTIONS_

Re: [SQL] Performance on large functions

2001-08-27 Thread Josh Berkus
conversation and basically determined that the problem is 90% likely to be disk access time. Bummer 'cause I didn't want to add any hardware to this machine, but, well, there ya go. -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] getting the oid for a new tuple in a BEFORE trigger

2001-08-29 Thread Josh Berkus
me from someone else. I could suggest a couple of workarounds, if you gave a fuller description of exactly what you're trying to accomplish. -Josh Berkus P.S. Please do not cross-post to more than 2 lists at a time. The Postgres lists have been kept to a managable volum

Re: [SQL] Problem with sequences

2001-08-30 Thread Josh Berkus
robably not going to find people on this list capable of diagnosing either problem. Try the pgsql-interfaces list instead. (http://postgresql.advancecreations.com/users-lounge/index.html) -Josh Berkus __AGLIO DATABASE SOLUTIONS___ J

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Josh Berkus
, twice, to a third table. I don't believe that this structure has a particular name. It's very common. -Josh Berkus *= Bruce, what I mean by "too short" is that you only have about 80 pages of introduction to SQL, which makes it a good first intro but does not bridge the ga

Re: [SQL] 2 tables, joins and same name...

2001-08-31 Thread Josh Berkus
e as airport2 FROM desitination dest JOIN airport depart_air ON dest.airport_dep_id=depart_air.airport_id JOIN airport arrive_air ON dest.airport_arr_id=arrive_air.airport_id Got it? -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] 2 tables, joins and same name...

2001-09-01 Thread Josh Berkus
hat'll make me friends at Stacy's Bookstore. "I'm not sure of the title, and I don't know the author or publisher, but it's about databases and it's pink." ;-P -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] INSERT Syntax

2001-09-03 Thread Josh Berkus
UES" syntax is only appropriate if you are inserting a set of constants with no SELECT statement involved. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and d

Re: [SQL] More on the TO DO wishlist

2001-09-03 Thread Josh Berkus
fund nor write it myself, so that'll remain a "wish list" item until maybe Red Hat sees money in it. Speaking of which, does anyone know if RH has a seperate "wish list" for what us developer-types would like to see our of RHDB? -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] More on the TO DO wishlist

2001-09-03 Thread Josh Berkus
it into the server. You heard it here first! > Does this mean I'll be forced to learn Emacs? -Josh (Who uses Kedit, Pico, and Joe) __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL P

Re: [SQL] 2 tables, joins and same name...

2001-09-03 Thread Josh Berkus
Ross, > I haven't seen _any_ of these books for over a year, and know a lot > more > SQL than I did then, so take any recommendations with a grain of > salt. Hmmm... both of these books get good reviews. Is there anywhere (say, techdocs) where we could add a book list? I&

Re: [SQL] optimizing queries and indexes...

2001-09-09 Thread Josh Berkus
mns in alphabetical order (!?!). They then had to call me, and re-ordering the index columns cut the delay in single-row queries (especially DELETE queries) by 80%. > so, i am hopeful that there is some sort of postgresql performance > faq > for queries. Somebody wanna re-organize

Re: [SQL] optimizing queries and indexes...

2001-09-09 Thread Josh Berkus
s to the database, especially for a marginal query performance gain. To phrase it another way: Optimization problems cost you seconds. DB Design and normalization problems cost you *days*. -Josh Berkus __AGLIO DATABASE SOLUTIONS___

Re: [SQL] group by weirdness

2001-09-10 Thread Josh Berkus
) as mcount FROM ml WHERE ml.state <> 11 GROUP BY jid) ma1, (SELECT jid, COUNT(oid) as mcount FROM ml WHERE ml.state in (2,5) GROUP BY jid) ma2 WHERE j.fkey = 1 AND mj.jid = j.id AND ma1.jid = j.id AND ma2.jid = j.id GROUP BY j.id, j.created, ma1.mcount, m

Re: [SQL] referencing oid impozsible ?

2001-09-11 Thread Josh Berkus
ues perfect for attaching foriegn keys. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small businesses

Re: [SQL] ERROR: Cannot insert a duplicate key into a unique index

2001-09-12 Thread Josh Berkus
Christoph, > This is no good programming style. > Does anybody have another, better idea or is > there at least a header file available, where > all the error messages can be found? Try posting this question to pgsql-hackers instead. I think you'll get more knowledgable h

Re: [SQL] SQL request change when upgrade from 7.0.2 to 7.1.3

2001-09-14 Thread Josh Berkus
BY statement as you appear to use it in that query is permitted and correct. I suspect that your problem is located somewhere else. For example, what interface tool are you using to send queries to the database? -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] SQL request change when upgrade from 7.0.2 to 7.1.3

2001-09-14 Thread Josh Berkus
Richard, I'm curious now. What happens if you remove the table qualifications, e.g.: ORDER BY type, nom; -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and

Re: [SQL] optimizing queries and indexes...

2001-09-16 Thread Josh Berkus
Tom, > [ Sorry for slow response, I've been out of town ] Taking a much-deserved vacation, hey? Any new job plans? > Postgres absolutely does not care: the optimizer will always consider > both A-join-B and B-join-A orders for every join it has to do. As > Stephan and Jo

Re: [SQL] Out of free buffers... HELP!

2001-09-19 Thread Josh Berkus
is limited (but I'm not as good as Bruce or Chris) -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law fir

Re: [SQL] How to enter lists into database.

2001-09-24 Thread Josh Berkus
gt; Thanks for any help, Can you be more explicit about what you are attempting? Perhpas yyou could give specific examples from you actual data. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [

Re: [SQL] Request for book reviews/comments

2001-09-24 Thread Josh Berkus
Folks, Also, any reviews on foriegn-language SQL or database books (in the appropriate language) would be appreciated. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED

Re: [SQL] Bug?: Update on ancestor for a row of a child

2001-09-24 Thread Josh Berkus
At least here, you can get a message to the actual database developers. Still, I understand your frustration. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and dat

Re: [SQL] How to enter lists into database:Example.

2001-09-24 Thread Josh Berkus
* search_attributes.attribute_value ) (the ~* allows searches on partial value matches) This will give you these results: 20 Mary Stuart 1600 Pensylvannia Ave. HairBrown 20 Mary Stuart 1600 Pensylvannia Ave. EyesHazel 20 Mary Stuart 1600 Pen

Re: [SQL] CHECK problem really OK now...

2001-09-24 Thread Josh Berkus
course, what they really want is for you to make a commitment to donate twice a year, every year. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management sol

Re: Query does not work: parse ERROR, Re: [SQL] How to enter lists into database: Problems with solution.

2001-09-26 Thread Josh Berkus
I've looked it over again and there's nothing missing. Is it possible, Frederick, that the comma after "matches" or "people_attributes" got cut off? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berku

Re: [SQL] 7.0.3 and 7.1.3 different results?

2001-10-03 Thread Josh Berkus
em to be more or less consistent across most vendor implementations. Plus in many languages the tests for NULL and empty recordset overlap or are easily combined. And this is pretty clearly defined in SQL 92, as you point out. -Josh P.S. Can you answer my question about indexing, please please?

Re: [SQL] Doing a regexp-based search/replace?

2001-10-18 Thread Josh Berkus
RCHAR ) RETURNS VARCHAR AS' SELECT SUBSTR($1, 1, ((STRPOS($1, ''-'') - 1)); END;' LANGUAGE 'SQL'; Then run: UPDATE main_table SET property_id = remove_propid_tail(property_id) WHERE property_id ~ '-'; -Josh __AGLIO DATABASE SOLUTIONS__

Re: [SQL] system maintained keys

2001-10-19 Thread Josh Berkus
L-SQL is for more advanced SQL issues. Yes, you can do this easily, Please see: http://www.postgresql.org/idocs/index.php?datatype.html#DATATYPE-NUMERIC Look at secion 3.1.1 on the page. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berku

Re: [SQL] oid's in views.

2001-10-19 Thread Josh Berkus
g OIDs as an index, and you've just found one more! -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law f

Re: [SQL] oid's in views.

2001-10-19 Thread Josh Berkus
eys and using those. Some Trigger types require referencing the OID, but that's about it. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions

Re: [SQL] Replication

2001-10-18 Thread Josh Berkus
on Postgres, but there are no definite plans. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law f

Re: [SQL] oid's in views.

2001-10-22 Thread Josh Berkus
le, but does have a unique index. The usq is populated by a single sequence "universal_sq" which is shared between tables, thus allowing all tables usq uniqueness between them. This strategy has allowed me to write a number of functions which are table-agnostic, needing only

Re: [SQL] Auto Increment

2001-10-23 Thread Josh Berkus
tml section 3.1.1 I can't imagine how it would be more clear. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293

Re: [SQL] can't update 'c:\windows'

2001-10-23 Thread Josh Berkus
illy", for example, I could: UPDATE table SET name = 'O\'Reilly'; Since you want to save an actual backslash, do this: UPDATE table SET field = 'C:\\windows'; In your interface code, you may which to add a function that doubles your backsl

Re: [SQL] oid's in views.

2001-10-24 Thread Josh Berkus
Hey, Dado, > Hi Josh! > Once you have your usq, how do you get more info about that row? > How do you know which table it came from? Well, if you have to go at it from that angle (hey, I have this USQ, where did it come from) then you're in trouble. However, I never use it tha

Re: [SQL] GUID in postgres

2001-10-24 Thread Josh Berkus
erpart of > this in postgres. It is urgent. No. Frankly, I don't know what a sys_GUID is. However, PostgreSQL allows you to create your own functions, operators, and data types, so I'm sure you could make your own GUID, whatever one is. -Josh __AGLIO DATABASE SOLUTIONS_

Re: [SQL] Connecting to different DataBase In PlPgsql Function

2001-10-26 Thread Josh Berkus
Bhuvan, > How can we connect to different database using plpgsql function? Can > we? No, you can't. -Josh ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Diferent databases on same query...

2001-10-26 Thread Josh Berkus
leware layer, such as J2EE. Your sort of situation is why middleware exists. If GreatBridge was still around, I'd reccommend you contact them, as I knwo they implemented a solution for your sort of situation. However, I don't know who'd do it now. -Josh __AGLIO DATABASE SOL

Re: [SQL] GUID in postgres

2001-10-25 Thread Josh Berkus
ead up on them in the postgreSQL docs. Also see my posts on pgsql-sql for the last week regarding primary keys. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED]

Re: [SQL] SQL FUNCTION return type on INSERT

2001-11-03 Thread Josh Berkus
Eddy, > What value should I RETURN for a SQL FUNCTION that contains an INSERT > statement? OPAQUE. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] an

[SQL] Book reviews are up

2001-11-03 Thread Josh Berkus
. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small businessesfax 621-2533 and non

Re: [SQL] Strange Problem As Type Casting

2001-11-03 Thread Josh Berkus
ast Stop quoting your integers. It should be WHERE user_id = 1346 No quotes for numbers. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions

Re: [SQL] GUID in postgres

2001-10-26 Thread Josh Berkus
what happens if you swap out the network card? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small bus

Re: [SQL] transposing data for a view

2001-10-31 Thread Josh Berkus
d LEFT OUTER JOIN (SELECT scanid, volume as C_volume FROM volumes WHERE region = 'C') cv ON scan.scanid = cv.scanid ORDER BY scanid; This approach can be adapted to include aggregates and the like. -Josh Berkus __AGLIO DATABASE SOLUTIONS___

Re: [SQL] Index of a table is not used (in any case)

2001-10-22 Thread Josh Berkus
ex creation relevant? I.e., should I create the > indices before inserting > entries or the other way around? Ummm ... not to be obvious, or anything, but did you VACCUUM ANALYZE after populating your table? There's also some special steps to take if you are regularly deleting large numb

Re: [SQL] GUID in postgres

2001-10-26 Thread Josh Berkus
unction accomplishes this task. All > that is accomplished by incorporating the MAC into the GUID is > uniqueness between machines. Makes sense if you have an open-ended network of machines so that a simple numbering sequence won't work. With 3 servers, "1", "2", "

Re: [SQL] transposing data for a view

2001-11-01 Thread Josh Berkus
;t believe the self-join approach proposed > earlier will work, because joining on "scanid" will > create a cartesian type join where the region values > will be duplicated (multiplicated!). Not if you're talking about my query, they won't. I use that query form in many p

Re: [SQL] transposing data for a view

2001-11-01 Thread Josh Berkus
y to > restructure this solution to get around this limitation? No, you need to upgrade. What's the obstacle to using 7.1.3, anyway? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology

Re: [SQL] transposing data for a view

2001-11-01 Thread Josh Berkus
Yes, you're right. Sorry! Disregard my commentary about the second view. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions

Re: [SQL] A simple join question that may stump you

2001-09-27 Thread Josh Berkus
ag in table B > but no extra flags. So, I'd end up with: > >ID > - > 2 Try looking at the INTERSECT and EXCEPT join types. Thus, in pseudo-sql you'd need: SELECT A.ID WHERE Count A JOIN B = Count B AND Count A EXCEPT B = 0 Assuming that all rows in

Re: [SQL] LEFT OUTER JOIN problem

2001-09-27 Thread Josh Berkus
,1,1,'hello',NULL,NULL,NULL > > But I think it may return two rows: > 1,'blabla',1,1,'hello',NULL,NULL,NULL > 2,'arrrgh',NULL,NULL,NULL,NULL,NULL,NULL Yes, it will. The query you want is: SELECT * FROM table1 JOIN table2 ON (table1.id = tabl

Re: [SQL] simple question!

2001-09-28 Thread Josh Berkus
Esteban, > is there a command intersect? I mean exist a union command, but > I > don't know if exist a intersect command. > thanks Yes. There is also EXCEPT as well as INTERSECT and UNION. See the online docs, in SQL COMMANDS --> SELECT -Josh

[SQL] Holiday Calculations?

2001-09-18 Thread Josh Berkus
L would be terrific). Thanks! -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small businessesfa

Re: [SQL] Checking for table existence

2001-09-17 Thread Josh Berkus
RETURN FALSE; ELSE RETURN TRUE; END IF; END;' LANGUAGE 'plpgsql'; ... then you build your function around this: CREATE FUNCTION my_function ( ... ... IF NOT table_exists(''my_table'') THEN CREATE TAB

Re: [SQL] Out of free buffers... HELP!

2001-09-20 Thread Josh Berkus
it sounds like the problem is. However, that sort of help will take some paid consultant time and possibly hardware. I think that if you can run a query on 150gb of data, you can probably run it on 355gb ... you just need some help performance tuning. But I don't think general advice on a

Re: [SQL] select is fast, update based on same where clause is slow

2001-09-21 Thread Josh Berkus
le in the FROM clause, while in Postgres such repetition is prohibited. This is mainly due to the fact that UPDATE ... FROM is not well-defined in the SQL 92 standard. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete inf

Re: Q on "Re: [SQL] select is fast, update based on same where clause is slow "

2001-09-21 Thread Josh Berkus
sult set of the number of rows in sessions2 * the number of rows in s. 74,000^2 Get it? Example: TableA: 1 A 2 B Table B 7 H 8 G SELECT * FROM TableA, TableB 1 A 7 H 1 A 8 G 2 B 7 H 2 B 8 G -

[SQL] Request for book reviews/comments

2001-09-23 Thread Josh Berkus
he SQL standard. All is explained in a completely implementation-agnostic way, with many diagrams and examples. A must for anyone required to create any complex database application from scratch. REVIEW WANTED: Database Design for Mere Mortals, by Michael Hernandez. -Josh __AGLIO DATABA

Re: [SQL] Stored prosedure last run

2001-09-19 Thread Josh Berkus
SERIAL NOT NULL PRIMARY KEY, function_name VARCHAR(100) NOT NULL, run_date TIMESTAMP NOT NULL DEFAULT current_timestamp); CREATE FUNCTION my_function ( ... ... BEGIN INSERT INTO function_log ( function_name ) VALUES ( 'my_function' ); ... Got it? -J

Re: [SQL] SQL-Programmer tool and field%type support

2001-10-08 Thread Josh Berkus
upported in PL/pgSQL, but not in Postgres SQL. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law firms, small b

Re: [SQL] [NOVICE] Loading current_user and current_timestamp using COPY

2001-10-10 Thread Josh Berkus
aven't seen any answers on the SQL list. I can think of several workarounds, depending on what kind of a user interface you're using, such as having a linked batches table. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berk

Re: [SQL] referencial conlumn contraints and inheritance

2001-10-14 Thread Josh Berkus
of the application. However, keep in mind that a lot of people (the Postgres core team included) do not agree with me about inheritance and its limitations. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information te

Re: [SQL] 7.0.3 and 7.1.3 different results?

2001-10-03 Thread Josh Berkus
27;t COUNT return no rows, too? Goes to show you that the SQL standard isn't even the model of perfect consistency BTW, returning no rows is somewhat different than returning NULL. WHat you should be seeing is: SELECT sum(id) FROM tableA WHERE field2 = 'not

Re: [SQL] Quotes and spaces

2001-10-05 Thread Josh Berkus
x27;; > EXECUTE query; > ... > END; > ... I'm pretty sure your quotes are correct. However, I believe "query" is a reserved word. Try using a different variable name. -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] SQL CONSTRAINTS - Constraining time values from two attributes on a table.

2001-10-05 Thread Josh Berkus
lue that ensures it is allways after another attribute value called > departure_time (declared as TIME). > Any know how this constraint would be written?? Easy: CONSTRAINT arr_dep_time CHECK ( arrival_time > departure_time ) __AGLIO DATABASE SOLUTIONS___

Re: [SQL] MEDIAN as custom aggregate?

2001-10-16 Thread Josh Berkus
ge... Me neither. You're right; the query didn't work. Here's a link to the median-finding function I posted to the CookBook: http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=1654 Anyone who can improve it is welcome! -Josh __AGLIO DATA

Re: [SQL] PgAdmin

2001-09-25 Thread Josh Berkus
This is in the pgadmin installation instructions. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions (415) 565-7293 for law f

Re: [SQL] How to enter lists into database: Problems with solution.

2001-09-26 Thread Josh Berkus
re-arrange the query slightly, you can turn it into a view. The trick is to have the search_id as an output column rather than a WHERE clause item in the sub-selects. Have fun! -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Comp

[SQL] Indexing behavior

2001-10-02 Thread Josh Berkus
ely by the PostgreSQL engine. Otherwise, such indexes are useless and may even slow down queries. Feedback? Answers? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED]

Re: [SQL] Loading current_user and current_timestamp using COPY

2001-10-09 Thread Josh Berkus
ateTimestamp columns are last. 2.2. Set the defaults on those columns to current_user and current-timestamp. 2.3. COPY all columns except those two. They should populate according to the defaults (I hope). -Josh __AGLIO DATABASE SOLUTIONS___

Re: [SQL] to_date/to timestamp going to BC

2001-10-04 Thread Josh Berkus
Karel, > .. well, I add it to my TODO for 7.3 (I plan rewrite several things > in to_* functions). How about a to_char function for INTERVAL? Please, oh please? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Co

Re: [SQL]maximum parameters limit to function & manipulating array in plpgsql

2001-10-04 Thread Josh Berkus
ally, you can declare an array as a parameter of a function, but that's it. You cannnot have array variables or retuurn types. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology

Re: [SQL] SQL Syntax / Logic question

2001-10-04 Thread Josh Berkus
possible that any particular person went to more than one school, add: GROUP BY frienda, friendb Simple, neh? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data man

[SQL] Beginner's List

2001-10-04 Thread Josh Berkus
1 beginner question per day. But I can't figure out how to do this without subscribing to pgsql-beginner and suffering a deluge of 100's of e-mails. Can anyone suggest something? -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Jo

[SQL] MEDIAN as custom aggregate?

2001-10-12 Thread Josh Berkus
he Mean and the Median you can do all kinds of interesting statistical analysis. -Josh Berkus __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED] and data management solutions

Re: [SQL] MEDIAN as custom aggregate?

2001-10-12 Thread Josh Berkus
1 OFFSET middlerec('pageviews')) med GROUP BY site, median_views; Where middlerec is a custom function that counts the records and returns the middle one. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete informat

Re: [SQL] Alias Join Table

2001-10-04 Thread Josh Berkus
Keith, There are a number of posts and papers on tree structures , both in the SQL list archives, and on Roberto Mello's resources at techdocs.postgresql.org. -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Com

Re: [SQL] SQL reference card

2001-10-15 Thread Josh Berkus
Failing that, you can write your own and post it to Techdocs.postgresql.org. That's what open source is all about! -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTED]

Re: [SQL] problem w/plpgsql proc

2001-10-15 Thread Josh Berkus
omments. They will be treated as the end of the function definition string. If you write the T-SQL Procedure ---> PostgreSQL function porting guide, I volunteer to edit (certifiable MS SQL DBA). You might wanna wait for 7.2, where Jan says that cursor support in PL/pgSQL functions will be added

<    1   2   3   4   5   6   7   8   9   >