Re: [SQL] Return relation table data in a single value CSV

2004-02-18 Thread Richard Huxton
On Tuesday 17 February 2004 23:33, Tom Lane wrote: Richard Huxton [EMAIL PROTECTED] writes: 2. Write a custom aggregate function (like sum()) to do the concatenation. This is easy to do, but the order your ABC get processed in is undefined. Actually, as of 7.4 it is possible to control

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Richard Huxton
On Wednesday 18 February 2004 00:25, Tom Lane wrote: scott.marlowe [EMAIL PROTECTED] writes: But then this: select 'x'||' '||'x' should produce xx, but it produces x x. No, because the imputed type of those literals is text. You'd have to cast the middle guy to char(n) explicitly to

Re: [SQL] bytea or blobs?

2004-02-18 Thread Richard Huxton
On Wednesday 18 February 2004 06:44, Dana Hudes wrote: At least with base64 I have ample libraries and can convert my data before sending to sql or after receiving from sql. It becomes my application's issue. Mind, this bloats the data considerably. escape is less bloat but I have to recreate

Re: [SQL] bytea or blobs?

2004-02-18 Thread Dana Hudes
How can one measure the result of the compression -- can I see this in some table or with some pgsql command? At what threshold does it take place, I think its 8192? The nasty bit is not one picture of 100kb. Its 20 pictures of 5kb. On Wed, 18 Feb 2004, Richard Huxton wrote: On Wednesday 18

Re: [SQL] Indexes and statistics

2004-02-18 Thread Tom Lane
David Witham [EMAIL PROTECTED] writes: Does this make it a wide table? Nope. A rough estimate is that your rows will be about 160 bytes wide, which means you can fit about 50 per 8K page. So a query that needs to select 8% of the table will *on average* need to hit about 4 rows per page. In

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Tom Lane
Richard Huxton [EMAIL PROTECTED] writes: I've never really understood the rationale behind char(n) in SQL databases (other than as backward compatibility with some old mainframe DB). There are (or were) systems in which the benefit of using fixed-width columns is a lot higher than it is in

Re: [SQL] bytea or blobs?

2004-02-18 Thread Richard Huxton
On Wednesday 18 February 2004 15:17, Dana Hudes wrote: How can one measure the result of the compression -- can I see this in some table or with some pgsql command? Hmm - not so far as I know. At what threshold does it take place, I think its 8192? The nasty bit is not one picture of 100kb.

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Jeremy Smith
Also, to make char(n) even more annoying, I had the one character value K stored in a column that was char(2). When I pulled it from the database and tried to compare it to a variable with a value of K it came out inequal. Of course in mysql, that was not a problem. Jeremy -Original

[SQL] Inserting NULL into Integer column

2004-02-18 Thread Jeremy Smith
Hi, in mysql I was able to make an insert such as: INSERT INTO TABLE (integervariable) VALUES ('') and have it either insert that variable, or insert the default if it had been assigned. In postgresql it gives and error every time that this is attempted. Since I have so many queries that do

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread scott.marlowe
On Wed, 18 Feb 2004, Jeremy Smith wrote: Hi, in mysql I was able to make an insert such as: INSERT INTO TABLE (integervariable) VALUES ('') and have it either insert that variable, or insert the default if it had been assigned. In postgresql it gives and error every time that this is

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread elein
So exactly what is the order of casts that produces different results with: 'x' || ' ' || 'x' and 'x' || ' '::char15 || 'x' Are operators being invoked both (text,text)? I'm trying to understand the precedence that causes the different results. elein On Tue, Feb 17, 2004 at 10:53:17PM

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread Jeremy Smith
Scott, I understand that MySQL's adherence to the standards must be lazy as I am running into frequent issues as I transfer my site. Unfortunately I have over 2500 queries, and many more of them needed to be rewritten than I ever would have imagined. I guess MySQL is the IE of open source DB,

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread scott.marlowe
On Wed, 18 Feb 2004, Jeremy Smith wrote: Scott, I understand that MySQL's adherence to the standards must be lazy as I am running into frequent issues as I transfer my site. Unfortunately I have over 2500 queries, and many more of them needed to be rewritten than I ever would have

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread Jeremy Smith
I've run into this kind of thing before. IT helps if you have an array of all your fields like: $fields = array(field1,field3,last_name); and then you can foreach across the input: foreach($fields as $f){ if (!$_POST[$f]){ $_POST[$f]='DEFAULT'; } else { $_POST[$f] =

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread scott.marlowe
On Wed, 18 Feb 2004, Jeremy Smith wrote: I've run into this kind of thing before. IT helps if you have an array of all your fields like: $fields = array(field1,field3,last_name); and then you can foreach across the input: foreach($fields as $f){ if (!$_POST[$f]){

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread Rod Taylor
and then you can foreach across the input: foreach($fields as $f){ if (!$_POST[$f]){ $_POST[$f]='DEFAULT'; } else { $_POST[$f] = '.$_POST[$f].'; } } Default in quotes isn't going to work, and please tell me you escape those things with pg_escape_string() at some point.

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread scott.marlowe
On Wed, 18 Feb 2004, Rod Taylor wrote: and then you can foreach across the input: foreach($fields as $f){ if (!$_POST[$f]){ $_POST[$f]='DEFAULT'; } else { $_POST[$f] = '.$_POST[$f].'; } } Default in quotes isn't going to work, and please tell me you escape

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread Rod Taylor
Note that the ' marks aren't part of the string, they are the delimiter of the string, and I always run every server with magic_quotes_gpc on. anything else? :-) Good point. I looked at the single quotes of the second line and somehow the DEFAULT got quoted as well ;)

Re: [SQL] Inserting NULL into Integer column

2004-02-18 Thread scott.marlowe
On Wed, 18 Feb 2004, Rod Taylor wrote: Note that the ' marks aren't part of the string, they are the delimiter of the string, and I always run every server with magic_quotes_gpc on. anything else? :-) Good point. I looked at the single quotes of the second line and somehow the

[SQL] Need some help with crafting a query to do major update

2004-02-18 Thread Sean Shanny
To all, This is part of a data warehouse. Made the mistake of using a natural key in one of the fact tables. :-( The f_test_pageviews is a simple testing table while I work this out. The real table has an identical schema. I have built a mapping table, d_user, to allow the replacement of

Re: [SQL] Need some help with crafting a query to do major update

2004-02-18 Thread Stephan Szabo
On Wed, 18 Feb 2004, Sean Shanny wrote: To all, This is part of a data warehouse. Made the mistake of using a natural key in one of the fact tables. :-( The f_test_pageviews is a simple testing table while I work this out. The real table has an identical schema. I have built a

Re: [SQL] Indexes and statistics

2004-02-18 Thread Iain
The computed cost of using the index was a factor of 10 higher which I presume is why the query planner wasn't using the index, but it ran in half the time Have you tried playing with the random_page_cost parameter? The default is 4. Try: set random_page_cost = 1; in psql to alter it for the

[SQL] Distributed Transactions

2004-02-18 Thread George A.J
Hi all, i am using PostgreSQL 7.3.2. How can i do distributed transactions in PostgreSQL. is there a transaction coordinator available for Postgres.. thanks in advance regards jinujose Do you Yahoo!? Yahoo! Mail SpamGuard - Read only the mail you want.

Re: [SQL] Distributed Transactions

2004-02-18 Thread Josh Berkus
Jinujose, i am using PostgreSQL 7.3.2. How can i do distributed transactions in PostgreSQL. is there a transaction coordinator available for Postgres.. Distributed transactions? Transaction coodinator? I'm not quite sure what these are. If you mean Two Phase Commit, for committing a

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread Tom Lane
elein [EMAIL PROTECTED] writes: So exactly what is the order of casts that produces different results with: 'x' || ' ' || 'x' and 'x' || ' '::char15 || 'x' Are operators being invoked both (text,text)? The only relevant operator is text || text (there are also some || operators for