assorted Postgres SQL/ORDBMS questions - Mailing list pgsql-sql

From Clint Stotesbery
Subject assorted Postgres SQL/ORDBMS questions
Date
Msg-id BAY9-F15IHRyeH4bgct0002545f@hotmail.com
Whole thread Raw
Responses Re: assorted Postgres SQL/ORDBMS questions  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
1. You can raise exceptions but you can't catch exceptions in pgsql right?
2. Does Postgres support ORDBMS operations?
Specifically I am wondering about the ability to define your own objects and 
create functions/procedures for the objects (e.g. object.method()). In 
Oracle I would use CREATE TYPE and CREATE TYPE BODY. Postgres' create type 
seems quite different than Oracle's version and they don't seem equivalent 
to each other. The Postgres version seems like it is for creating your own 
datatypes but not your own objets. I couldn't find any docs on this except 
on the SQL commands page.
3. Does it support nested tables?
Again I couldn't find any info in the docs for this.
4. Can dates only be storied in YYYY-MM-DD format?
I've looked over the documentation at 
http://www.postgresql.org/docs/7.3/static/functions-formatting.html and it 
seems that doing to_date(t_date,''DD-MON-YYYY'') should return 20-OCT-2003 
but it returns 2003-10-20 no matter what I do.

An example:

CREATE OR REPLACE FUNCTION datetest()  RETURNS date AS '  DECLARE     t_date varchar;     v_date date;  BEGIN
t_date:= to_char(now(),''DD-MON-YYYY'');     v_date := to_date(t_date,''DD-MON-YYYY'');     RETURN v_date;  END;  '
LANGUAGE'plpgsql';
 

SELECT datetest();

this returns:
datetest
----------
2003-10-20

I wanted it to return 20-OCT-2003 and the documentation suggests that I 
should be able to do that yet it doesn't actually do it.

Now slightly different:

CREATE OR REPLACE FUNCTION datetest()  RETURNS varchar AS '  DECLARE     t_date varchar;     v_date date;  BEGIN
t_date:= to_char(now(),''DD-MON-YYYY'');     v_date := to_date(t_date,''DD-MON-YYYY'');     RETURN t_date;  END;  '
LANGUAGE'plpgsql';
 

SELECT datetest();

This returns:
----------
datetest
20-OCT-2003

This works fine but it is a varchar. I really want it to be stored like that 
but in a date type instead.
Thanks for the answers!
-Clint

_________________________________________________________________
Add MSN 8 Internet Software to your current Internet access and enjoy 
patented spam control and more.  Get two months FREE!     
http://join.msn.com/?page=dept/byoa



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: converting an oracle procedure to postgres
Next
From: Josh Berkus
Date:
Subject: Re: assorted Postgres SQL/ORDBMS questions