Re: [SQL] How do I convert an integet to a timestamp?

2005-09-12 Thread Michael Fuhr
On Mon, Sep 12, 2005 at 11:01:08AM -0700, Wei wrote: > I followed the doc and tried "select CAST(1126547334 AS timestamp)" and > I only got an error response that says: ERROR: cannot cast type > integer to timestamp without time zone. What documentation suggested casting an integer to a timestamp

Re: [SQL] user defined type, plpgsql function and NULL

2005-09-12 Thread Tom Lane
"Bjoern A. Zeeb" <[EMAIL PROTECTED]> writes: > Is this correct or is it just a "works like that this time but may > change at any time in the future"? The meaning of a NULL for a composite value isn't real well-defined at the moment. I tend to agree that "fbt IS NULL" should yield true in your ex

Re: [SQL] Age in days

2005-09-12 Thread Michael Glaesemann
On Sep 10, 2005, at 1:04 AM, Mark A. Strivens wrote: select date_trunc('day',age(now(),dateofbirth)) from people My questions is, is there any way to convert that figure into an age expressed as a number days only? Try select current_date - dateofbirth from people; Michael Glaesemann grz

Re: [SQL] Age in days

2005-09-12 Thread Gnanavel S
This will give you the no of days.select current_date - dateofbirth::date from people; On 9/9/05, Mark A. Strivens <[EMAIL PROTECTED]> wrote: If you need to know the age to the nearest day on the present dayI think you can use something like:select date_trunc('day',age(now(),dateofbirth)) from peop

[SQL] Age in days

2005-09-12 Thread Mark A. Strivens
If you need to know the age to the nearest day on the present day I think you can use something like: select date_trunc('day',age(now(),dateofbirth)) from people gives: 3 years 2 mons 12 days My questions is, is there any way to convert that figure into an age expressed as a number days only?

Re: [SQL] Indexing an array?

2005-09-12 Thread Ron Mayer
Silke Trissl wrote: As far I could read from the documentation - this should be possible. But my question is, is there a kind of index on the array. If your needs are a bit more modest (say, a few thousands instead of billions) the stuff in contrib/intarray works well; and if you needed types

Re: [SQL] Performance issue

2005-09-12 Thread Tim Goodaire
On Tue, Aug 30, 2005 at 03:38:52PM +0700, Ricky Sutanto wrote: > I use Apache Web Server and PostgreSQL 7.3 to collect data everyday. Now it > has been 5 month since I install that server. > > I wonder why now my web very slow to retrieve and display data? > When I check the memory, I found that

[SQL] user defined type, plpgsql function and NULL

2005-09-12 Thread Bjoern A. Zeeb
Hi, let's say one has an user defined data type CREATE TYPE foobar_t AS ( va varchar(25), vb varchar(4), vc varchar(20), ia integer, ib integer ); and a stored procedure in plgpsql (stripped and sample only): CREATE OR REPLACE FUNCTION foobar(int, foobar_t, int, varchar) RETURNS IN

[SQL] How do I convert an integet to a timestamp?

2005-09-12 Thread Wei
Hi. I followed the doc and tried "select CAST(1126547334 AS timestamp)" and I only got an error response that says: ERROR: cannot cast type integer to timestamp without time zone. What is the proper way to do the conversion? Thanks Wei ---(end of broadcast)---

Re: [SQL] Need help with `unique parents` constraint

2005-09-12 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > Thank you for an excellent answer. I think I will have to study your > code for a while. But is it such a bad idea to have a separate column > for the primary key here? I see that there are two schools on this, > with diametrically opposed views.

Re: [SQL] refer a column as a varible name?

2005-09-12 Thread Michael Fuhr
On Mon, Sep 12, 2005 at 12:21:22PM -0300, [EMAIL PROTECTED] wrote: > suppose the > > type mycolumn as (field1, varchar, field2 varchar) > and > > field_name = ''field1'' > > and returnValue declared as mycolumn > ... > can i say returnValue.$field_name = ''ok''? To achieve this in PL/pgSQL you'

Re: [SQL] Need help with 'unique parents' constraint

2005-09-12 Thread Leif B. Kristensen
On Sunday 11 September 2005 16:04, Greg Sabino Mullane wrote: > Not just old-fashioned, it's the biological law! (among homo sapiens > anyway). I'd approach this with a trigger, as you can do complex > checks and get back nice customized error messages. A sample script > follows. Hard to tell with

[SQL] refer a column as a varible name?

2005-09-12 Thread gherzig
Hi all. I have troubles trying to achieve this assignment: suppose the type mycolumn as (field1, varchar, field2 varchar) and field_name = ''field1'' and returnValue declared as mycolumn ... can i say returnValue.$field_name = ''ok''? There is a way to achieve this piece of code? Thanks a lot!

Re: [SQL] Please help, can't figure out what's wrong with this function...

2005-09-12 Thread Tom Lane
Moritz Bayer <[EMAIL PROTECTED]> writes: > I get the following error: > ERROR: missing .. at end of SQL expression > I haven't figured out what this message wants to tell me and why it is > thrown at all. I think it's telling you that you are using a 7.3 or older server. Try 7.4 or later --- plp

Re: [SQL] Please help, can't figure out what's wrong with this function...

2005-09-12 Thread John DeSoi
On Sep 12, 2005, at 8:14 AM, Moritz Bayer wrote: I get the following error: ERROR: missing .. at end of SQL expression it looks like your for loop is being interpreted as the integer variant, e.g. for i in 1..10 loop CREATE TYPE "public"."ty_stadtlandflussentry" AS ( DECLARE objRetu

[SQL] Please help, can't figure out what's wrong with this function...

2005-09-12 Thread Moritz Bayer
Hello group,   I 've written the following function:   CREATE OR REPLACE FUNCTION "public"."getstadtlandflussentrybyid" (integer) RETURNS SETOF "public"."ty_stadtlandflussentry" AS'DECLARE objReturn ty_stadtlandflussentry; DECLARE iid  integer;BEGIN    iid := $1;    for objReturn IN