Re: [SQL] COPY command and required file permissions

2010-06-25 Thread Adrian Klaver
On Friday 25 June 2010 6:07:35 pm Bruno Scovoli Santos wrote: > * Are you connecting to the database as a superuser to run the COPY > command? * > > Yes. This \copy command is in the database build script (create table > blablabla). So it almost (I think) must have to be a superuser. > > But he

Re: [SQL] enforcing constraints across multiple tables

2010-06-25 Thread Ben Morrow
Quoth andrew.ge...@gmail.com (Andrew Geery): > > I have a question about checking a constraint that is spread across multiple > (in the example below, two) tables. In the example below, every food (food > table) is in a food group (food_group table). For every person (person > table), I want to

Re: [SQL] Round integer division

2010-06-25 Thread Lee Hachadoorian
Thanks. That was a fairly recent post, too, but I couldn't come up with the right keyword search to find it. On 06/25/2010 07:25 PM, Adrian Klaver wrote: > On Friday 25 June 2010 3:53:01 pm Lee Hachadoorian wrote: > >> Is it documented anywhere that floating-point numbers round >> "scientifical

Re: [SQL] How do I remove selected words from text field?

2010-06-25 Thread Osvaldo Kussama
2010/6/25 Frank Bax : > I'm not quite sure how to ask for the query I want, so let's start with > data: > > create table t1 (i int, val varchar); > insert into t1 values(1,'A B C D'); > insert into t1 values(2,'B D E F'); > insert into t1 values(3,'G H I J'); > create table t2 (q varchar, z varchar

Re: [SQL] Round integer division

2010-06-25 Thread Adrian Klaver
On Friday 25 June 2010 3:53:01 pm Lee Hachadoorian wrote: > Is it documented anywhere that floating-point numbers round > "scientifically", that is 0.5 rounds to the nearest even number? Compare: > > SELECT round(2.5::real), round(2.5::numeric), round(3.5::real), > round(3.5::numeric); > > generate

Re: [SQL] Round integer division

2010-06-25 Thread Lee Hachadoorian
On 06/25/2010 07:00 PM, Scott Marlowe wrote: > That all floating point representations are approximate? > But if it's error due to approximation, shouldn't the result be random? I tried this for a handful of larger numbers, and it appears to consistently round to the even number. Wouldn't that ha

Re: [SQL] Round integer division

2010-06-25 Thread Scott Marlowe
On Fri, Jun 25, 2010 at 6:53 PM, Lee Hachadoorian wrote: > Is it documented anywhere that floating-point numbers round > "scientifically", that is 0.5 rounds to the nearest even number? Compare: > > SELECT round(2.5::real), round(2.5::numeric), round(3.5::real), > round(3.5::numeric); > > generate

[SQL] Round integer division

2010-06-25 Thread Lee Hachadoorian
Is it documented anywhere that floating-point numbers round "scientifically", that is 0.5 rounds to the nearest even number? Compare: SELECT round(2.5::real), round(2.5::numeric), round(3.5::real), round(3.5::numeric); generates 2 | 3 | 4 | 4 I stumbled across this when I was trying to use roun

[SQL] How do I remove selected words from text field?

2010-06-25 Thread Frank Bax
I'm not quite sure how to ask for the query I want, so let's start with data: create table t1 (i int, val varchar); insert into t1 values(1,'A B C D'); insert into t1 values(2,'B D E F'); insert into t1 values(3,'G H I J'); create table t2 (q varchar, z varchar); insert into t2 values('A','vowel

Re: [SQL] Average of Array?

2010-06-25 Thread Ireneusz Pluta
Lee Hachadoorian pisze: Is there a function that returns the average of the elements of an array? I'm thinking of something that would work like the avg() aggregate function where it returns the average of all non-NULL values. Can't find anything like it in the docs, and I'd like to make sure I'm

Re: [SQL] enforcing constraints across multiple tables

2010-06-25 Thread Tim Landscheidt
Andrew Geery wrote: > [...] > My questions are: > (A) Is there a way to check (2) above using a constraint and not a trigger? > (B) Is there an easier way to solve this problem? Does the complicated > nature of the solution make the design poor? > (C) Should I not worry about this constraint at

Re: [SQL] COPY command and required file permissions

2010-06-25 Thread Adrian Klaver
On 06/23/2010 02:01 PM, bruno.scovoli wrote: I have an script with many "\copy" commands. For example: \copy privilegios from '/work/eclipse-workspace/Canoan Server/database/load/privilegios.dat' \copy privilegios_de_usuarios from '/work/eclipse-workspace/Canoan Server/database/load/privilegios

[SQL] enforcing constraints across multiple tables

2010-06-25 Thread Andrew Geery
I have a question about checking a constraint that is spread across multiple (in the example below, two) tables. In the example below, every food (food table) is in a food group (food_group table). For every person (person table), I want to enforce the constraint that there can only be one food i

Re: [SQL] Average of Array?

2010-06-25 Thread Lee Hachadoorian
Thanks Tom & Pavel, these are very helpful. On Fri, Jun 25, 2010 at 12:29 PM, Pavel Stehule wrote: > Hello > > 2010/6/25 Lee Hachadoorian : >> Is there a function that returns the average of the elements of an >> array? I'm thinking of something that would work like the avg() >> aggregate functio

Re: [SQL] Average of Array?

2010-06-25 Thread Pavel Stehule
Hello 2010/6/25 Lee Hachadoorian : > Is there a function that returns the average of the elements of an > array? I'm thinking of something that would work like the avg() > aggregate function where it returns the average of all non-NULL > values. Can't find anything like it in the docs, and I'd lik

Re: [SQL] Average of Array?

2010-06-25 Thread Tom Lane
Lee Hachadoorian writes: > Is there a function that returns the average of the elements of an > array? I'm thinking of something that would work like the avg() > aggregate function where it returns the average of all non-NULL > values. Can't find anything like it in the docs, and I'd like to make

[SQL] Average of Array?

2010-06-25 Thread Lee Hachadoorian
Is there a function that returns the average of the elements of an array? I'm thinking of something that would work like the avg() aggregate function where it returns the average of all non-NULL values. Can't find anything like it in the docs, and I'd like to make sure I'm not missing something. T

Re: [SQL] COPY command and required file permissions

2010-06-25 Thread bruno.scovoli
I have an script with many "\copy" commands. For example: \copy privilegios from '/work/eclipse-workspace/Canoan Server/database/load/privilegios.dat' \copy privilegios_de_usuarios from '/work/eclipse-workspace/Canoan Server/database/load/privilegios_de_usuarios.dat' \copy classificacoes from '/w

[SQL] Re: How to Insert and retrieve multilingual (Hindi "an Indian language") into PostgreSQL

2010-06-25 Thread Stephane Bortzmeyer
On Tue, Jun 22, 2010 at 04:18:48PM +0530, venkat wrote a message of 39 lines which said: > I want to insert and retrieve multilingual (Hindi) into database.is > PostgreSQL supports that ? [Currently, I'm storing arabic texts in a PostgreSQL database.

[SQL] Re: [GENERAL] How to Insert and retrieve multilingual (Hindi "an Indian language") into PostgreSQL

2010-06-25 Thread Thom Brown
On 22 June 2010 11:48, venkat wrote: > Dear All, > >   I want to insert and retrieve multilingual (Hindi) into > database.is PostgreSQL supports that ?if it is ... please guide me how to > enable multilingual in the table. > >     I am waiting for your great response. > Thanks and Regards, > Venka