Re: Oracle Decode Function

Поиск
Список
Период
Сортировка
От Chris Humphries
Тема Re: Oracle Decode Function
Дата
Msg-id 15680.23733.858258.744912@metalico.drauku.net
обсуждение исходный текст
Ответ на Re: Oracle Decode Function  (Marc Lavergne <mlavergne-pub@richlava.com>)
Список pgsql-hackers
if you find yourself using the decode statement, you are probably
doing something wrong. why have it, do you _need_ it?

if you are using it for display strings based on conditions, 
you shouldnt be using a function to do this. it should be a table,
or something in the middle layer. try to keep the frame of mind of
letting the db do it's job of just managing data; middle layer for
doing something useful with the data and sending to the top layer
for presentation or formatted data that is meaningful there. It 
is the right(tm) way to do things, and will make life alot easier :)

would be interested to hear a valid reason why you feel the need
to use decode(). seems that oracle gives you alot of functions and
abilities that allow dba's and programmers to be lazy, instead of 
having a good db [relational] design (and that is more standards
compliant). 

though like Tom Lane said, there is case, if you need it. 
good luck!

-chris

Marc Lavergne writes:> That would get ugly in a real hurry! Oracle does get around the issue of > parameter datatypes
byhaving automatic datatype conversions, more or > less, everything becomes a varchar2. The only real attractants to >
implementinga DECODE() function is that it's one less thing to convert > when migrating apps from Oracle and,
unfortunately,this is also a piece > of the SQL*Net compatibility that I'm looking into doing!> > > Tom Lane wrote:> >
MarcLavergne <mlavergne-pub@richlava.com> writes:> > > >>If you're asking about whether a custom function can have
vararg> >>parameters, the answer appears to depend on the CREATE FUNCTION> >>syntax. > > > > > > Can't do it, though
youcould imagine creating a family of functions> > of the same name and different numbers of parameters.  Trying to> >
emulateDECODE this way would have a much worse problem: what's the> > datatype of the parameters?  (Or the result?)> >
>> Use CASE; it does more than DECODE *and* is ANSI-standard.> > > >             regards, tom lane> > > >
---------------------------(endof broadcast)---------------------------> > TIP 1: subscribe and unsubscribe commands go
tomajordomo@postgresql.org> > > > > > ---------------------------(end of broadcast)---------------------------> TIP 5:
Haveyou checked our extensive FAQ?> > http://www.postgresql.org/users-lounge/docs/faq.html
 


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Marc Lavergne
Дата:
Сообщение: Re: Oracle Decode Function
Следующее
От: "Kangmo, Kim"
Дата:
Сообщение: Re: tuple concurrently updated