[SQL] Disabling constraints

2004-02-17 Thread Kumar
Dear friends,   I am working opn Postgres 7.3.4 on RH Linux 7.2.   I wanted to disable constraints.   Alter table 'table name' disable constraint 'constraint name'; doesn't work.   I got some information from google, which says about indirect way of disabling and enabling a constraint, as foll

Re: [SQL] bytea or blobs?

2004-02-17 Thread Achilleus Mantzios
Generally this is the task of various drivers. The postgresql jdbc for instance makes this task easy with the ResultSet.getBytes() method. The servlet code to display the contents of any mimetype bytea column looks like: PreparedStatement st = con.prepareStatement("select mimetype,image from im

Re: [SQL] Indexes and statistics

2004-02-17 Thread David Witham
Tom, I'm running PostgreSQL 7.3.2 on Red Hat Linux 7.3 with 512Mb RAM. The table definition is: Table "public.cdr" Column | Type | Modifiers ---+---+--- carrier_id| integer

Re: [SQL] bytea or blobs?

2004-02-17 Thread sad
On Tuesday 17 February 2004 18:08, you wrote: > I'd recommend to let the application convert the binary > data to and from base64, Don't, please don't ! Since you have the good bytea rule to convert so called "binary" data into so called "text". You have no need another encoding at all. Genera

Re: [SQL] Indexes and statistics

2004-02-17 Thread Tom Lane
"David Witham" <[EMAIL PROTECTED]> writes: > One of the customers is quite large (8.3% of the records): Hmm. Unless your rows are quite wide, a random sampling of 8.3% of the table would be expected to visit every page of the table, probably several times. So the planner's cost estimates do not

[SQL] Indexes and statistics

2004-02-17 Thread David Witham
Hi all, This is a further post from last week. I've got a table of phone call detail records. buns=# select count(*) from cdr; count - 2800653 (1 row) One of the customers is quite large (8.3% of the records): buns=# select count(*) from cdr where cust_id =

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

2004-02-17 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > Apparently the ::char is cast to varchar and then text? No, directly to text, because the || operator is defined as taking text inputs. But there's no practical difference between text and varchar on this point. regards, tom lane -

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

2004-02-17 Thread terry
> select 'x'||' '||'x' > > should produce xx, but it produces x x. > INCORRECT This select 'x'||' '::char ||'x' Should produce xx This select 'x'||' '||'x' is restateable as select 'x'|| ' '::text ||'x' And the || operand for text is not dropping the extra spaces hence correctly x x Terry Fie

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

2004-02-17 Thread Tom Lane
"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 make its trailing spaces go away when it's reconverted t

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

2004-02-17 Thread scott.marlowe
On Tue, 17 Feb 2004, Tom Lane wrote: > elein <[EMAIL PROTECTED]> writes: > > This is an example of the problem. It used to expand > > the middle thing to 15. > > > elein=# select 'x' || ' '::char(15) || 'x'; > > ?column? > > -- > > xx > > (1 row) > > Still does, but then the spaces g

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

2004-02-17 Thread elein
So the problem is there. But blaming it on char was wrong. It should be blamed on the varchar change. Hey, I thought the truncation was for varchar and not text? It was for both? It would be semantically tricky to change the operator. The precendence is to convert to text. Now with the implicit

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

2004-02-17 Thread Tom Lane
elein <[EMAIL PROTECTED]> writes: > This is an example of the problem. It used to expand > the middle thing to 15. > elein=# select 'x' || ' '::char(15) || 'x'; > ?column? > -- > xx > (1 row) Still does, but then the spaces go away again when the value goes into the concatenation, bec

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

2004-02-17 Thread Tom Lane
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 the order of inputs to a custom aggregate. You do some

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

2004-02-17 Thread elein
This is an example of the problem. It used to expand the middle thing to 15. elein=# select 'x' || ' '::char(15) || 'x'; ?column? -- xx (1 row) On Tue, Feb 17, 2004 at 06:10:56PM -0500, Tom Lane wrote: > "news.postgresql.org" <[EMAIL PROTECTED]> writes: > > I just discovered the foll

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

2004-02-17 Thread Tom Lane
"news.postgresql.org" <[EMAIL PROTECTED]> writes: > I just discovered the following change to CHAR(n) (taken from varlena.com, > general bits, issue 62). The description you quote doesn't appear to have much of anything to do with the actual behavior of 7.4. 7.4 will trim trailing spaces when con

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

2004-02-17 Thread Richard Huxton
On Tuesday 17 February 2004 20:05, [EMAIL PROTECTED] wrote: > I should probably be punished for even asking this question, but a > simplified version of what I want is this... > > I have 2 tables: > floorplans > floorplan_id | description > -- > 2240 | test floorplan

Re: FW: [SQL] Function

2004-02-17 Thread Richard Huxton
On Tuesday 17 February 2004 14:41, Sumita Biswas (sbiswas) wrote: > Is there nothing like SET NOCOUNT ON; in plpgsql What is this supposed to do for you? > Is there any option like SET ANSI_NULLS ON in plpgsql. What is this supposed to do for you too? > Do we append # before the temp table name

Re: [SQL] SQL query seach + rearranging results

2004-02-17 Thread Richard Huxton
On Monday 16 February 2004 16:07, lowdog wrote: > hey guys! > > I need your help in writing a php name-day searcher script. Actually, you probably want a mysql list - this is a PostgreSQL list. However, from what I can understand of your problem I think the easiest solution for you might be to o

Re: [SQL] bytea or blobs?

2004-02-17 Thread Jan Wieck
Jeremy Smith wrote: On this subject, isn't it actually better to just store image names in the database and pull the image itself from a directory? That's what I do on my site because I didn't want to bloat up my database unnecessarily. Are there additional benefits to storing the image informat

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

2004-02-17 Thread terry
I should probably be punished for even asking this question, but a simplified version of what I want is this... I have 2 tables: floorplans floorplan_id | description -- 2240 | test floorplan and a table elevations floorplan_id | elevation

Re: [SQL] Unique Constraint with foreign Key

2004-02-17 Thread Greg Patnude
You've got it wrong when you reference the data column (a.x) -- your foreign key should reference the primary key in the referenced table (a.y)... Besides, in your table A -- 1, 99 2, 99 violates your unique constraint on column 'X' -- it would never happen... What I suggested is like this: c

[SQL] SQL query seach + rearranging results

2004-02-17 Thread lowdog
hey guys! I need your help in writing a php name-day searcher script. here's what ive done: i have the hostname, login and pw defined in a file, this one calls it: then i made the query, where (sorry for not translating the variable names, would be easier for you to understand ) the "nev

Re: [SQL] Function

2004-02-17 Thread Sumita Biswas (sbiswas)
Thanks for the answer. I have one more issue. How do I test a function that I wrote? I was able to create a function called Proc_ConferenceSummary(). In SQL Server I used to run it through query analyzer by writing the following command: exec Proc_ConferenceSummary '12/1/2003','1/23/2004',1,1,0,500

Re: [SQL] nextval problem

2004-02-17 Thread Greg Patnude
New feature for posgreSQL 7.3 & later -- sequences are automatically dropped when the owning table is dropped -- you need to recreate the sequence The easiest way is in your CREATE TABLE tblName ( id serial PRIMARY KEY, blah..., blah..., ) WITH OIDS; -- Greg Patnude / The Digit

FW: [SQL] Function

2004-02-17 Thread Sumita Biswas (sbiswas)
Is there nothing like SET NOCOUNT ON; in plpgsql Is there any option like SET ANSI_NULLS ON in plpgsql. Do we append # before the temp table names in plpgsql, like we do for MSSQL ? In case no how do we create a temp table in a function in plsql? -Original Message- From: Stephan Szabo [m

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

2004-02-17 Thread news.postgresql.org
Hello, I just discovered the following change to CHAR(n) (taken from varlena.com, general bits, issue 62). This will cause me serious heart-ache, back-ache and bug-ache if we upgrade to 7.4. Is there any compatibility flag available to use pre-7.4 behaviour for CHAR(n)? Regards, John ==

Re: [SQL] Tip: a function for creating a remote view using dblink

2004-02-17 Thread Josh Berkus
Mark, > I'm posting a function here in the hope others may find it useful > and/or correct my mistakes/make improvements :) Thanks! Way cool! > Is there any existing site (a wiki for example) for posting PostgreSQL > specific tips? > (Wasn't sure if pgsql-sql is the right place for this ki

Re: [SQL] bytea or blobs?

2004-02-17 Thread Jeremy Smith
On this subject, isn't it actually better to just store image names in the database and pull the image itself from a directory? That's what I do on my site because I didn't want to bloat up my database unnecessarily. Are there additional benefits to storing the image information in the database

Re: [SQL] Ok, what am I doing wrong here?

2004-02-17 Thread Karl Denninger
Thanks... -- -- Karl Denninger ([EMAIL PROTECTED]) Internet Consultant & Kids Rights Activist http://www.denninger.netTired of spam at your company? LOOK HERE! http://childrens-justice.orgWorking for family and children's rights http://diversunion.org LOG IN AND GET YOUR TAN

Re: [SQL] Ok, what am I doing wrong here?

2004-02-17 Thread Tomasz Myrta
Dnia 2004-02-17 17:02, Użytkownik Karl Denninger napisał: I want to insert values from one table into another, and add some "default" values (that are not defaults on the table different reasons - that is, this is maintenance function and in normal operation there would be "real" values there - and

Re: [SQL] Ok, what am I doing wrong here?

2004-02-17 Thread Stephan Szabo
[EMAIL PROTECTED] On Tue, 17 Feb 2004, Karl Denninger wrote: > I want to insert values from one table into another, and add some "default" > values (that are not defaults on the table different reasons - that is, this > is maintenance function and in normal operation there would be "real" values

Re: [SQL] bytea or blobs?

2004-02-17 Thread Jan Wieck
beyaNet Consultancy wrote: Hi, what I am trying to do is to be able to store images in my database. What I wanted to know is this: 1. Would it be better to have the image field type as a bytea or a blob? I have heard it mentioned that bytea would be better as doing data dumps would also insure

[SQL] Ok, what am I doing wrong here?

2004-02-17 Thread Karl Denninger
I want to insert values from one table into another, and add some "default" values (that are not defaults on the table different reasons - that is, this is maintenance function and in normal operation there would be "real" values there - and null is valid) So, I want to do, for example, the follow

Re: [SQL] Unique Constraint with foreign Key

2004-02-17 Thread Jan Wieck
Greg Patnude wrote: Pleas also note that the referenced column in the foreign table either needs to be the PRIMARY KEY or have a unique constraint on it or maybe it just requires an index on it -- I'm not sure but I discovered that if the column in the foreign table (containing the REFERENCED key..

Re: [SQL] Trace for postgreSQL

2004-02-17 Thread Andrew Sullivan
On Tue, Feb 10, 2004 at 12:04:42PM +, beyaNet Consultancy wrote: > Hi, > can anyone tell me whether there is a trace facility (application) > available for postgreSQL version 7.4.1 which will enable me to see all > incoming requests being made to the database (ala SQL Server)? Sure. Alter y

Re: [SQL] Tip: a function for creating a remote view using dblink

2004-02-17 Thread Karsten Hilbert
> Hello, >I'm posting a function here in the hope others may find it useful > and/or correct my mistakes/make improvements :) > > This creates a view of a remote table, using dblink: ... > Is there any existing site (a wiki for example) for posting PostgreSQL > specific tips? The PG cookbook