pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Clint Stotesbery <cstotes@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: assorted Postgres SQL/ORDBMS questions
Date: Tue, 21 Oct 2003 01:40:11 +0000
Message-ID: <BAY9-F15IHRyeH4bgct0002545f@hotmail.com> (raw)

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




view thread (3+ messages)  latest in thread

Message-ID: <BAY9-F15IHRyeH4bgct0002545f@hotmail.com>
Permalink:  ../BAY9-F15IHRyeH4bgct0002545f@hotmail.com/
Also on:    postgresql.org/message-id/BAY9-F15IHRyeH4bgct0002545f@hotmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: cstotes@hotmail.com
  Subject: Re: assorted Postgres SQL/ORDBMS questions
  In-Reply-To: <BAY9-F15IHRyeH4bgct0002545f@hotmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox