Thread: Porting from Oracl to Postgres

Porting from Oracl to Postgres

From
Jomon Skariah
Date:


Hi,

Thanks for your replys.

We are facing another problem now.

we need to find an alternative for Oracle's ADD_MONTHS in PostGres..


Regards

Jomon





-----Original Message-----
From: Rod Taylor [mailto:rbt@rbt.ca]
Sent: Friday, September 05, 2003 1:20 AM
To: Jomon Skariah
Cc: pgsql-sql@postgresql.org
Subject: Re: MINUS & ROWNUM in PostGres


> 1)     Do we have a replacement in PostGres for MINUS operator of Oracle .

I believe MINUS is non-standard word for EXCEPT, correct?
> 2    Also I need to find an alternative for ROWNUM in oracle..

If you are looking for a unique identifier, try using the OID.



Re: Porting from Oracl to Postgres

From
Rod Taylor
Date:
On Fri, 2003-09-05 at 00:24, Jomon Skariah wrote:
>
> Hi,
>
> Thanks for your replys.
>
> We are facing another problem now.
>
> we need to find an alternative for Oracle's ADD_MONTHS in PostGres..

Guessing based on the name that it adds a quantity of months to a
timestamp.  How about an SQL Interval?

now() + interval '15 months'

List of functions:
http://www.postgresql.org/docs/7.3/interactive/functions.html


Re: Porting from Oracl to Postgres

From
Richard Huxton
Date:
On Friday 05 September 2003 05:24, Jomon Skariah wrote:
> Hi,
>
> Thanks for your replys.
>
> We are facing another problem now.
>
> we need to find an alternative for Oracle's ADD_MONTHS in PostGres..

SELECT now() + '1 hour'::interval;
SELECT now() + '2 days'::interval;
SELECT now() + '3 months':: interval;

See the data-types section of the manual for details.

--  Richard Huxton Archonet Ltd


Re: Porting from Oracl to Postgres

From
Jeff Eckermann
Date:
--- Rod Taylor <rbt@rbt.ca> wrote:
> On Fri, 2003-09-05 at 00:24, Jomon Skariah wrote:
> > 
> > Hi,
> > 
> > Thanks for your replys.
> > 
> > We are facing another problem now.
> > 
> > we need to find an alternative for Oracle's
> ADD_MONTHS in PostGres..
> 
> Guessing based on the name that it adds a quantity
> of months to a
> timestamp.  How about an SQL Interval?
> 
> now() + interval '15 months'
> 
> List of functions:
>
http://www.postgresql.org/docs/7.3/interactive/functions.html

For compatibility in your application, you could do
something like:

CREATE FUNCTION add_months(date, integer) RETURNS date
AS '
SELECT ($1 + ( $2::text || ''
months'')::interval)::date;
' LANGUAGE 'sql';

I second the recommendation to spend some time looking
over the available functions in PostgreSQL.

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com