472,340 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,340 software developers and data experts.

pgplsql - Oracle nvl

Hi,

I'll try to switch from Oracle to postgres for some small applications.
Is it possible to build functions like Oracle's nvl or decode with pgplsql?
How can I make a function like nvl that works for every datatype?

Best regards,
Christian

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #1
5 8632
On Wednesday 27 August 2003 09:58, Christian Traber wrote:
Hi,

I'll try to switch from Oracle to postgres for some small applications.
Is it possible to build functions like Oracle's nvl or decode with pgplsql?
How can I make a function like nvl that works for every datatype?

Write as many "nvl" functions as you have different types of params.
Overloading works just fine in postgres. (I do not know what function "nvl"
actually does, so maybe You can explain it.)

for example :

CREATE OR REPLACE FUNCTION nvl( INTEGER ) AS ...
CREATE OR REPLACE FUNCTION nvl( TEXT ) AS ...

Regards !

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #2
On Wed, Aug 27, 2003 at 09:58:00 +0200,
Christian Traber <ch*******@traber-net.de> wrote:
Hi,

I'll try to switch from Oracle to postgres for some small applications.
Is it possible to build functions like Oracle's nvl or decode with pgplsql?
How can I make a function like nvl that works for every datatype?


You can use coalesce to do what nvl does.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #3
OK, clear.
But if you have access to your application code, it's maybe better to
create an abstraction layer in front of the DB specific SQLs, and
implement for each DB differently (this is how we do it).
The "nvl" and "decode" statements are Oracle specific, so I can't see
why not use the Postgres specific syntax for Postgres. A lot of Oracle
queries will work a lot better on postgres if rewritten differently, and
some of them can be even expressed more elegantly in Postgres. AFAIKT,
designing your application so it can use a DB abstraction layer will
give you far less trouble in the long run than trying to make the Oracle
queries work unchanged on Postgres...

Cheers,
Csaba.

On Wed, 2003-08-27 at 10:55, Christian Traber wrote:
I know this functions, but I do not want to change the statements in my
old application.
So I want to make the functions with the Oracle names for compatibility.

Best regards,
Christian

Csaba Nagy wrote:
You don't need to build any function for this, you have them ready:
http://www.postgresql.org/docs/view....l.html#AEN9753
http://www.postgresql.org/docs/view....l.html#AEN9698

Cheers,
Csaba.

On Wed, 2003-08-27 at 09:58, Christian Traber wrote:

Hi,

I'll try to switch from Oracle to postgres for some small applications.
Is it possible to build functions like Oracle's nvl or decode with pgplsql?
How can I make a function like nvl that works for every datatype?

Best regards,
Christian

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org




---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 11 '05 #4
I know this functions, but I do not want to change the statements in my
old application.
So I want to make the functions with the Oracle names for compatibility.

Best regards,
Christian

Csaba Nagy wrote:
You don't need to build any function for this, you have them ready:
http://www.postgresql.org/docs/view....l.html#AEN9753
http://www.postgresql.org/docs/view....l.html#AEN9698

Cheers,
Csaba.

On Wed, 2003-08-27 at 09:58, Christian Traber wrote:

Hi,

I'll try to switch from Oracle to postgres for some small applications.
Is it possible to build functions like Oracle's nvl or decode with pgplsql?
How can I make a function like nvl that works for every datatype?

Best regards,
Christian

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 11 '05 #5
You don't need to build any function for this, you have them ready:
http://www.postgresql.org/docs/view....l.html#AEN9753
http://www.postgresql.org/docs/view....l.html#AEN9698

Cheers,
Csaba.

On Wed, 2003-08-27 at 09:58, Christian Traber wrote:
Hi,

I'll try to switch from Oracle to postgres for some small applications.
Is it possible to build functions like Oracle's nvl or decode with pgplsql?
How can I make a function like nvl that works for every datatype?

Best regards,
Christian

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jan Bols | last post by:
I've been trying to install Oracle 8.1.7 on a fresh Mandrake 9.1 O.S for days, but I'm still not able to get it running. I've tried several install...
0
by: Luc Martineau | last post by:
Hello, I have a question about pgplsql: Is it faster to execute a compact function (with minimal spaces and comments) than a function with many...
13
by: Chris Botha | last post by:
The machine is running XP Pro with all the latest service packs, etc. I must access an Oracle database so I installed the Oracle client stuff. I can...
2
by: Kuti Attila | last post by:
Hi, I have a pgplsql function. It is quite short and simple. The problem:
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze...
2
by: Ruslan A Dautkhanov | last post by:
Hello ! I'm about to install O9i on FreeBSD box. uname -a: FreeBSD stat2.scn.ru 5.2.1-RELEASE-p3 FreeBSD 5.2.1-RELEASE-p3 #2: Fri Apr 23...
0
by: Jack | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location...
0
by: Winder | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location...
0
by: sathyguy | last post by:
when i type the below in my RHEL AS 4's Firefox 1.5 http://appsworld.ncc.com:7777/forms/...&form=test.fmx iam getting the below error... The...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.