Re: [SQL] ROUND function ??

2001-10-08 Thread Joe Conway
> select ROUND(0.5) ; returns 0 > select ROUND(1.5) ; returns 2; > select ROUND(2.5) ; returns 2; > select ROUND(3.5) ; returns 4;so on . > I'm sure you would have figured out what's happening !!! Why ?? > How do I get to approximate any number x.5 as x+1 ?? Looks like a bug to me: test=# se

Re: [SQL] ROUND function ??

2001-10-08 Thread Tom Lane
"Saurabh Mittal" <[EMAIL PROTECTED]> writes: > select ROUND(0.5) ; returns 0 > select ROUND(1.5) ; returns 2; > select ROUND(2.5) ; returns 2; > select ROUND(3.5) ; returns 4;so on .=20 > I'm sure you would have figured out what's happening !!! Why ?? Because the IEEE float math standard says

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

2001-10-08 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > DECLARE > v_field1 mytable.field1%type > is supported internal to a PL/pgSQL function, but > CREATE FUNCTION test1(int) RETURNS mytable.filed1%type > is not. This is because the %type declaration is supported in PL/pgSQL, > but not in Postgres SQL. It

[SQL] ROUND function ??

2001-10-08 Thread Saurabh Mittal
Hi,   select ROUND(0.5) ; returns 0 select ROUND(1.5) ; returns 2; select ROUND(2.5) ; returns 2; select ROUND(3.5) ; returns 4;so on . I'm sure you would have figured out what's happening !!! Why ?? How do I get to approximate any number x.5 as x+1 ??   Saurabh  

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

2001-10-08 Thread Josh Berkus
Mourad, > > I have an other question about the use of %type and alias in > PL/SQL. So the > > excution of functions containing varibales of type > maytable.field1%type > > prompts parser errors. > > error on the creation of the function : > > create function test (int) returns maytable.field1%ty

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

2001-10-08 Thread Roberto Mello
On Fri, Oct 05, 2001 at 03:37:14PM +0200, Mourad EL HADJ MIMOUNE wrote: > Hi, > I'm looking for PL/SQL programmer tool. I wanted to use SQL-Programmer but > it > doesn't support Postgres data base. > Please can sommeone suggest me an other tool wich can replace this one or > explaine me how w

Re: [SQL] Problem with n to n relation

2001-10-08 Thread Stephan Szabo
On Mon, 8 Oct 2001, Janning Vygen wrote: > Am Montag, 8. Oktober 2001 18:09 schrieb Stephan Szabo: > > On Mon, 8 Oct 2001, Janning Vygen wrote: > > > > > but how do i reach my goal. It should not be allowed to have a > > > person without any address?? > > > > Hmm, do you always have at least on

Re: [SQL] Problem with n to n relation

2001-10-08 Thread Janning Vygen
Am Montag, 8. Oktober 2001 18:09 schrieb Stephan Szabo: > On Mon, 8 Oct 2001, Janning Vygen wrote: > > > but how do i reach my goal. It should not be allowed to have a > > person without any address?? > > Hmm, do you always have at least one known address at the time > you're inserting the perso

Re: [SQL] Problem with n to n relation

2001-10-08 Thread Stephan Szabo
On Mon, 8 Oct 2001, Janning Vygen wrote: > Am Freitag, 5. Oktober 2001 14:30 schrieb Morgan Curley: > > just get rid of the serial_id in person2adress -- there is no > > reason for it. Make the pk of that table a composite --> person_id, > > address_id <-- that way you have added some additional

Re: [SQL] temporary views

2001-10-08 Thread Bruce Momjian
> Bruce Momjian wrote: > > > > We can handle the temp views thing two ways, either allow views to map > > to temp tables by name, or allow temp views to map to temp tables that > > exist at creation time and drop the views on session exit. The original > > poster clearly wanted the first behavio

Re: [SQL] Search by longitude/latitude

2001-10-08 Thread Joe Conway
> Hi all, > > I need to implement "Find all hospitals in a 5 mile radius". Say I have all > the coordinates on them stored in a table with the fields longitude and > latitude. Has anybody some sample code for that? > > Best regards, > Chris > Here's a plpgsql function that will do what you need.

Re: [SQL] How to Return Unique Elements From An Array?

2001-10-08 Thread Haller Christoph
Have you tried already SELECT DISTINCT FROM ; If you receive an error message like Unable to identify an ordering operator ... Refer to 'Server Programming' section Extending SQL: Operators to learn about creating your own operators for array comparison Or search the mailing-list for simil

Re: [SQL] Search by longitude/latitude

2001-10-08 Thread Colin 't Hart
Better still, check out PostGIS at http://postgis.refractions.net/ Cheers, Colin ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Search by longitude/latitude

2001-10-08 Thread James Orr
Here is some perl code which does what you want. - Original Message - From: "Chris Ruprecht" <[EMAIL PROTECTED]> To: "pgsql" <[EMAIL PROTECTED]> Sent: Monday, October 08, 2001 8:58 AM Subject: [SQL] Search by longitude/latitude > Hi all, > > I need to implement "Find all hospitals in a

Re: [SQL] SQL Syntax / Logic question

2001-10-08 Thread Thurstan R. McDougle
To help you understand SQL I should point out that your version would work (assuming only 1 school per person) if you just left the friends out of the FROMs for the sub-selects:- select frienda, friendb from friends where (select schools.school from schools as schoolsa where friends.frienda = sc

[SQL] Search by longitude/latitude

2001-10-08 Thread Chris Ruprecht
Hi all, I need to implement "Find all hospitals in a 5 mile radius". Say I have all the coordinates on them stored in a table with the fields longitude and latitude. Has anybody some sample code for that? Best regards, Chris _ Do You Yah

[SQL] PEAR Problem

2001-10-08 Thread Gurudutt
Hi, It's me again. I have been able to solve most of the porting problems from mysql to pgsql. But I have got struck in one place. I have a problem where PEAR's associative array doesn't recognise the mix case letters. eg . I issue a query through PEAR db and get results using fetchRow of PEAR.

Re: [SQL] temporary views

2001-10-08 Thread Tomasz Myrta
Bruce Momjian wrote: > > We can handle the temp views thing two ways, either allow views to map > to temp tables by name, or allow temp views to map to temp tables that > exist at creation time and drop the views on session exit. The original > poster clearly wanted the first behavior, but I agr

Re: [SQL] select 5/2???

2001-10-08 Thread BELLON Michel
OK the problem is with ZEOS Components Michel BELLON LCIE - Informatique appliquée 33 (0)1 40 95 60 35 > -Message d'origine- > De: Christopher Sawtell [SMTP:[EMAIL PROTECTED]] > Date: lundi 8 octobre 2001 12:39 > À:BELLON Michel; guard; [EMAIL PROTECTED] > Objet:Re: [SQL] s

Re: [SQL] select 5/2???

2001-10-08 Thread Christopher Sawtell
On Mon, 08 Oct 2001 22:31, BELLON Michel wrote: Works ok for me. chris=# select -5/2.0; ?column? -- -2.5 (1 row) chris=# select version(); version - PostgreSQL 7.1.1 on i586-pc-linux-gnu, compi

Re: [SQL] select 5/2???

2001-10-08 Thread BELLON Michel
The good select is SELECT 5./2. BUT select -5./2. +--+ | ?column? | +--+ | 2.5 | not -2.5 +--+ Michel BELLON LCIE - Informatique appliquée 33 (0)1 40 95 60 35 > -Message d'origine- > De: guard [SMTP:[EMAIL PROTECTED]] > Date: mercredi 3 octo

Re: [SQL] sql + C

2001-10-08 Thread Haller Christoph
I'm having some experience with C embedded SQL and what I can see at first sight is 1) DECLARE CURSOR statement - missing colon: EXEC SQL DECLARE C77 CURSOR FOR select datname from pg_user,pg_database where usename= :user and datdba= :usesysid; 2) before OPEN you have to declare and set the wh

[SQL] How to Return Unique Elements From An Array?

2001-10-08 Thread Bhuvan A
hello all, how can we get unique elements from an array(of any type)? Regards, Bhuvaneswar. ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Problem with n to n relation

2001-10-08 Thread Janning Vygen
Am Freitag, 5. Oktober 2001 14:30 schrieb Morgan Curley: > just get rid of the serial_id in person2adress -- there is no > reason for it. Make the pk of that table a composite --> person_id, > address_id <-- that way you have added some additional integrity to > your structure. Only one record ca