Re: assorted Postgres SQL/ORDBMS questions

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: "Clint Stotesbery" <cstotes(at)hotmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: assorted Postgres SQL/ORDBMS questions
Date: 2003-10-21 02:47:45
Message-ID: 200310201947.45530.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Clint,

> 1. You can raise exceptions but you can't catch exceptions in pgsql right?

right. We'd like to do exception-trapping, but nobody has offered to program
it.

> 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.

Not with that syntax, no. Our ORDBMS functionality is more aimed at creating
your own datatypes, domains, operators, aggregates, and similar.

> 3. Does it support nested tables?
> Again I couldn't find any info in the docs for this.

No. Nor will it if I have any clout on the Hackers list; Nested tables are a
Bad Idea and they Violate The Relational Standard. Arrays are as far as I am
willing to go, and only in special cases.

> 4. Can dates only be storied in YYYY-MM-DD format?

Dates are stored in an internal format in order to ensure compliance with the
SQL date standard. The DATE type is stored as an integer; the TIMESTAMP is
(I believe) binary. Depending on your locale, the default *representation*
of dates may be yyyy-mm-dd, or something else.

> 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.

You want to re-format the date; see the docs on to_char().

> This works fine but it is a varchar. I really want it to be stored like
> that but in a date type instead.

No, you don't need it to be stored that way.

If you want dates to display a particular way, use to_char() when you query
them. Dates are stored as dates, not as strings.

BTW, MS SQL Server's implementation of DATETIME sucks rocks and violates the
SQL standard besides. So don't go comparing them on me.

--
Josh Berkus
Aglio Database Solutions
San Francisco

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-10-21 03:59:17 Re: assorted Postgres SQL/ORDBMS questions
Previous Message Clint Stotesbery 2003-10-21 01:40:11 assorted Postgres SQL/ORDBMS questions