Functions DECODE

DB 8.0.1....
Hi,
The decode function is useful for order by, but  I often have problems when table columns differ, e.g. char, number, date.
SQL:
         Select *
         from people
         order by decode(:ORD,'N',name,'C',ID_people,date_born);
error: differ types....
What  is your solution ?
Regards
Jomar

Thanks for the correction
Sth about union all
Elapsed: 00:00:00.85
12:25:06 CTH@XE> with t as
12:30:53 2 ( select 'a'c from dual union all
12:30:53 3 select '1' c from dual union all
12:30:53 4 select '11' c from dual union all
12:30:53 5 select '10' from dual union all
12:30:53 6 select 'A' from dual union all
12:30:53 7 select 'z' from dual union all
12:30:53 8 select 'Z' from dual)
12:30:53 9 select * from t order by ascii(upper(c)), upper(c);
C
1
10
11
A
a
Z
z
7 rows selected.
Elapsed: 00:00:00.01
12:30:54 CTH@XE> with t as
12:31:02 2 ( select 'a'c from dual union
12:31:02 3 select '1' c from dual union
12:31:02 4 select '11' c from dual union
12:31:02 5 select '10' from dual union
12:31:02 6 select 'A' from dual union
12:31:02 7 select 'z' from dual union
12:31:02 8 select 'Z' from dual)
12:31:02 9 select * from t order by ascii(upper(c)), upper(c);
C
1
10
11
A
a
Z
z
7 rows selected.
Elapsed: 00:00:00.00
12:31:02 CTH@XE> with t as
12:31:08 2 ( select 'a'c from dual union all
12:31:08 3 select '1' c from dual union all
12:31:08 4 select '11' c from dual union all
12:31:08 5 --Line duplicate
12:31:08 6 select '11' c from dual union all
12:31:08 7 select '10' from dual union all
12:31:08 8 select 'A' from dual union all
12:31:08 9 select 'z' from dual union all
12:31:08 10 select 'Z' from dual)
12:31:08 11 select * from t order by ascii(upper(c)), upper(c);
C
1
10
11
11
a
A
z
Z
8 rows selected.
Elapsed: 00:00:00.01
12:31:09 CTH@XE>

Similar Messages

  • Use sql function decode with Zend code

    Hi,
    I need to use sql function DECODE() in a query for PHP Code. This query works well in sql*plus but PHP returns
    the following error message:
    Parse error: syntax error, unexpected T_STRING in C:\Program Files\Zend\Apache2\htdocs\Compta\compta2.php on line 16
    the query is :
    $query =
    'select substr(c.NUM,1 ,2) Compte ,
    c.designation , a.Periode
    ,decode(substr(c.NUM,1 ,1), '1',1, '2',1,'3',1,-1) cp_type ,
    sum(credit) - sum(debit) Montant
    from ecritures a, clients b, compte c
    where
    b.NUM (+) =a.NUM
    and a.DATEECRITURE between to_date(:debut, \'dd/mm/yy\') and to_date(:fin, \'dd/mm/yy\')
    and substr(a.num,1,2) =c.num
    group by substr(c.NUM,1 ,1), substr(c.NUM,1,2) , c.designation ,a.periode
    order by compte ';
    Can any one help me ???
    Thanks by advance
    nb: Iuse Zend 2.0

    Hi,
    You need to escape single quote mark:
    decode(substr(c.NUM,1 ,1), \'1\',1, \'2\',1,\'3\',1,-1) cp_type ,
    the same way you did for to_date:
    to_date(:debut, \'dd/mm/yy\')
    Regards,
    Paweł

  • Does the condition specified in the function 'DECODE' allow 'BETWEEN' expression?

    Does the condition specified in the function 'DECODE' allow 'BETWEEN' expression?

    As a completely different approach, in 8i SQL and 9i PL/SQL we can use the CASE function. This delivers decode functionality, but allows us to use conditions e.g.
    SELECT CASE WHEN col BETWEEN 1 and 9 THEN 'one' ELSE 'two' END FROM my_table;I love DECODE and wouldn't use anything else for straight value substitutions but CASE does have the advantage of clarity when it comes to maths, etc. Also I believe DECODE is not ANSI compliant. In which case (ho ho!) I suspect it will probably be deprecated, as Oracle seems to be moving towards ANSI SQL compliance, as part of its open standards drive.
    Cheers, APC

  • Using function Decode inside Decode for Oracle Reports

    Has anyone used a decode inside of a decode to get a single record from mulitple records?
    Thanks

    I've used decode inside of decode to create a view. Then in the report, I used a group by query to combine the records. Let me know if you want to my sql.

  • Is it possible to return an operator-type from a function/decode ?

    Hi ,
    I have a query that is calling a decode and based on the operator type (i.e <> , >= , <= etc ..) that it returns to compare 2 fields of a table
    is this possible and if so could anyone advise me how to ?
    below is my current declaration that gives invalid relational operator error
    SELECT 1 into TmpCnt FROM Tbl1a where
    a.id = ID and a.part = PART and a.parmn = TESTNAME
    and a.paval DECODE(TESTCONDITION , 'LT' , '<' ,
    'LE' , '<=' ,
    'EQ' , '=' ,
    'GE' , '>=' ,
    'GT' , '>' ,
    'NE' , '<>' ) TPARAMVALUE ';
    tks & rdgs

    You can't replace an operator with an expression.
    For a limited number of operators you may be able to code this explicitly, something like...
    SELECT 1
    FROM   tbl1a
    WHERE  a.ID = ID
    AND    a.part = part
    AND    a.parmn = testname
    AND    DECODE (testcondition,
             'LT', CASE WHEN a.paval <= tparamvalue THEN 'Y' END,
             'LE', CASE WHEN a.paval = tparamvalue THEN 'Y' END,
             'EQ', CASE WHEN a.paval >= tparamvalue THEN 'Y' END,
             'GE', CASE WHEN a.paval >= tparamvalue THEN 'Y' END,
             'GT', CASE WHEN a.paval > tparamvalue THEN 'Y' END,
             'NE', CASE WHEN a.paval != tparamvalue THEN 'Y' END) = 'Y'Otherwise you are looking at Dynamic SQL.

  • DECODE function with ' ' and ' '

    I need of a command to compare intervals of dates, similar to DECODE, only that using '<' and '>'.
    Example: if the date will be minor who ' 2005-10-01 ' then return ' problem ', else if the date will be minor who 2005-11-01 and greater that 2005-10-01, then returns ' ok '
    I tried to use the function ' decode ' with the function ' sign ', but this only functions for numbers and it does not stop dates.
    Former: Using a column that contains numbers, ok.
    SELECT decode(SIGN(col_number-10),-1,'<10',decode(SIGN(col_number-20),-1,'<20',decode(SIGN(col_number-30),-1,'<30'))) col_number
    FROM table
    If to use a column that contains dates (dates or timestamp), problem (types of incosistentes dates: it waited NUMBER got YOU DATE).
    SELECT decode(SIGN(col_date-10),-1,'<10',decode(SIGN(col_date-20),-1,'<20',decode(SIGN(col_date-30),-1,'<30'))) col_date
    FROM table
    Somebody has some idea?

    Somebody has some idea?Yes, CASE().
    Cheers, APC

  • Function-based indexes

    Oracle documentation on "How Function-Based Indexes Work" states that for the creation of a function-based index in the user's own schema, the user must be granted the QUERY REWRITE system privileges. And MUST have the following initialization parameters defined to create a function-based index:
    QUERY_REWRITE_INTEGRITY set to TRUSTED
    QUERY_REWRITE_ENABLED set to TRUE.
    I have created a function-based unique index, which uses the SQL function DECODE(). But the user doesn't have the QUERY REWRITE sytem privilege. The user has the following privileges:
    CREATE PROCEDURE
    CREATE SEQUENCE
    CREATE SESSION
    CREATE TABLE
    CREATE TRIGGER
    CREATE VIEW
    And also the initialization parameters for QUERY_REWRITE_INTEGRITY and QUERY_REWRITE_ENABLED are set to their DEFAULT values as follows:
    QUERY_REWRITE_INTEGRITY set to ENCFORCED
    QUERY_REWRITE_ENABLED set to FALSE.
    Note: The index is an unique index for data integrity purpose. I am using Oracle 9.2.0.6 version.
    Kindly explain me the reason how the function-based index is created without the system privilege and the initialization parmaters defined as stated in the Oracle9i Database Administrator's Guide Release 2 (9.2).

    You can change those parameter at session level as well.
    Following link would be helpful:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:2552324147195810457::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:667694821129
    Jaffar

  • Oracle Query Performance While calling a function in a View

    Hi,
    We have a performance issue in one of our Oracle queries.
    Here is the scenario
    We use a hard coded value (which is the maximum value from a table) in couple of DECODE statements in our query. We would like to remove this hard coded value from the query. So we wrote a function which will return a maximum value from the table. Now when we execute the query after replacing the hard coded value with the function, this function is called four times which hampers the query performance.
    Pl find below the DECODE statements in the query. This query is part of a main VIEW.
    Using Hardcoded values
    =================
    DECODE(pro_risk_weighted_ctrl_scr, 10, 9.9, pro_risk_weighted_ctrl_scr)
    DECODE(pro_risk_score, 46619750, 46619749, pro_risk_score)
    Using Functions
    ============
    DECODE (pro_risk_weighted_ctrl_scr, rprowbproc.fn_max_rcsa_range_values ('CSR'), rprowbproc.fn_max_rcsa_range_values('CSR')- 0.1, pro_risk_weighted_ctrl_scr)
    DECODE (pro_risk_score, rprowbproc.fn_max_rcsa_range_values ('RSR'), rprowbproc.fn_max_rcsa_range_values ('RSR') - 1, pro_risk_score)
    Can any one suggest a way to improve the performance of the query.
    Thanks & Regards,
    Raji

    drop table max_demo;
    create table max_demo
    (rcsa   varchar2(10)
    ,value  number);
    insert into max_demo
    select case when mod(rownum,2) = 0
                then 'CSR'
                else 'RSR'
           end
    ,      rownum
    from   dual
    connect by rownum <= 10000;   
    create or replace function f_max (
      i_rcsa    in   max_demo.rcsa%TYPE
    return number
    as
      l_max number;
    begin
       select max(value)
       into   l_max
       from   max_demo
       where  rcsa = i_rcsa;
       return l_max;
    end;
    -- slooooooooooooowwwwww
    select m.*
    ,      f_max(rcsa)
    ,      decode(rcsa,'CSR',decode(value,f_max('CSR'),'Y - max is '||f_max('CSR'),'N - max is '||f_max('CSR'))) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,f_max('RSR'),'Y - max is '||f_max('RSR'),'N - max is '||f_max('RSR'))) is_max_rsr
    from   max_demo m
    order by value desc;
    -- ssllooooowwwww
    with subq_max as
         (select f_max('CSR') max_csr,
                 f_max('RSR') max_rsr
          from   dual)
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      subq_max s
    order by value desc;
    -- faster
    with subq_max as
         (select /*+materialize */
                 f_max('CSR') max_csr,
                 f_max('RSR') max_rsr
          from   dual)
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      subq_max s
    order by value desc;
    -- faster
    with subq_max as
         (select f_max('CSR') max_csr,
                 f_max('RSR') max_rsr,
                 rownum
          from   dual)
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      subq_max s
    order by value desc;
    -- sloooooowwwwww
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      (select /*+ materialize */
                 f_max('CSR') max_csr,
                 f_max('RSR') max_rsr
          from   dual) s
    order by value desc;
    -- faster
    select m.*
    ,      decode(rcsa,'CSR',s.max_csr,'RSR',s.max_rsr) max
    ,      decode(rcsa,'CSR',decode(value,s.max_csr,'Y - max is '||s.max_csr,'N - max is '||s.max_csr)) is_max_csr
    ,      decode(rcsa,'RSR',decode(value,s.max_rsr,'Y - max is '||s.max_rsr,'N - max is '||s.max_rsr)) is_max_rsr
    from   max_demo m
    ,      (select f_max('CSR') max_csr,
                   f_max('RSR') max_rsr,
                   rownum
            from   dual) s
    order by value desc;

  • How does one access custom function in OBIEE RPD for Session Init Block SQL

    Hello:
    We are using SSO for authentication and authorization for OBIEE, using Init Blocks in the RPD and httpHeader as the source of variables in the Instanceconfig.xml file. (As long as the user is member of one group, the results are fine. However, as soon as the user is assigned to multiple groups, group values become URI-encoded.)
    To solve the problem of URI-encoding, we have deployed a function to the DB (ora 10gr2).
    The problem I am running into is that when I call the function from an Init Block (Security), OBIEE Presentation Services (OPS) acts as though the function does not exist or is not called.
    Initialization String: select group_OBIEE(WEBGROUPS) from dual
    ("group_OBIEE" is the function that was deployed.)
    Testing: Successfully tested the function in PL/SQL as well as using the Test button in RPD.
    Reason for the fuction: The function decodes the extra characters using a substr function. SSO uses Shibboleth for Authentication and Authorization.
    For example, for our group name, we expect to obtain the following value:
    edw:hrdir;edw:findir (2 groups separated by a semi-colon)
    However, we are obtaining the following: (Determined via the narrative view in Answers: @{biServer.variables['NQ_SESSION.GROUP']} )
    URI-ENCODED&lt;edw%3ahrdir%3bedw%3bfindir&gt;
    Please note: There are no such problems when we are passing only a single group value (i.e. edw:hrdir). So, in cases when we pass only for Group for the user, we are able to authenticate and authorize w/o a problem.
    Any suggestion on how to call the function or a better way to approach this problem?
    Thanks in advance for your help.

    You don't need a function to assign the groups in your Init Block. In fact you should not use it. You need to use a standard select and define the Init Block as Row-Wise. This means the BI Server knows the Init Block will return more than one row. You select statement should look like this:
    SELECT 'GROUP', YOUR_GROUP_NAME FROM YOUR GROUP_USERS_TABLE WHERE YOUR_USER_ID_COLUMN = ':USER'

  • SQLLoader - using more than 1 function in a single field

    Hi.
    I have problem with sqlloader. i'm trying to call 2 function (DECODE and NPCS_FINBOUND_CTRL) for field type like below
    LOAD DATA
    INFILE "TEST.txt"
    APPEND
    INTO TABLE NPCS_INBOUND_NIZ
    TYPE POSITION(1:1) "DECODE(:TYPE,1,2,:TYPE)" "NPCS_FINBOUND_CTRL(:TYPE,NPCS_FSEQCTRL('P_GFA','0',:TYPE),NPCS_FSEQC
    TRL('P_GFA','1',:TYPE),NPCS_TRANS_ID_SEQ.nextval,null,null,null)"
    ,FILE_ID "NPCS_FSEQCTRL('P_GFA','0',DECODE(:TYPE,1,2,:TYPE))"
    ,BATCH_ID "NPCS_FSEQGET('P_GFA','1',:TYPE)"
    ,TRANS_ID "TRANS_ID_SEQ.nextval"
    ,DATA POSITION(1:160)
    is sqlloader allow us to call more than 1 function because when i run the loader i got error like this
    SQL*Loader-350: Syntax error at line 6.
    Expecting valid column specification, "," or ")", found "DECODE(:TYPE,1,2,:TYPE)".
    DECODE(:TYPE,1,2,:TYPE)" "DECODE(:TYPE,1,2,:TYPE)"
    ,FILE_ID "NP
    ok
    tq.

    create the control file as given below
    load data
    infile *
    into table emp1 truncate
    (empno char terminated by '\n',
    ename expression "substr(function1(:empno),1,3)",
    ename1 expression "substr(function2(:empno),1,3)")
    begindata
    111
    222
    333
    Regards,
    Abu

  • How to solve [CASE or DECODE]

    Suppoe i ve 2 columns
    Col_1 Col_2 both are number
    how to write this condtion in query
    if
    col_1>col_2 then
    return coL_1-col_2
    else
    return
    col_2_col1i ve tried decode and case...........but fail to build query.
    Waiting for Reply
    Regards
    Danish Hayder

    case is preferable but if you want to learn about decode
    SQL> select decode(sign(11-10),-1,'less',0,'=','greater') col1 from dual;
    COL1
    greaterhttp://www.techonthenet.com/oracle/functions/decode.php

  • Can we write function with variable number of argument

    Hi
    Can anybody tell that can we pass variable number of arguments to a function in oracle 10gR2.
    As in function decode we can pass variable no. of arguments upto 255 arguments, similarly can we creat a function which accept any no. of variables.

    I'm not sure that this is what you were asking about, but depending on the logic you want to implement, you can declare the maximum possible number of parameters to your function, give them default values, and then pass to your func as many parameters as you want:
    SQL> create or replace function test(p_a number:=null, p_b number:=null) return varchar2 is
      2    Result varchar2(100);
      3  begin
      4    result:='a='||p_a||', b='||p_b;
      5    return(Result);
      6  end test;
      7  /
    Function created
    SQL> select test() from dual;
    TEST()
    a=, b=
    SQL> select test(1) from dual;
    TEST(1)
    a=1, b=
    SQL> select test(1,2) from dual;
    TEST(1,2)
    a=1, b=2
    SQL> drop function test;
    Function dropped
    SQL>

  • JSON.decode not working

    Hi All,
    I have some JSON code that is generated from my server. I am
    trying to decode the JSON using the as3corelib. I am receiving the
    error Unexpected character v encountered. It's from the viewentry
    line at the beginning of the attached JSON code.
    Any thoughts on why this is?
    I can't change the JSON being generated so I'm going to have
    to handle it in the JSON decoder . . .

    You property name -- xaxis in this case -- must be a quoted
    string:
    private function decode() : void {
    var s:String = '{
    "xaxis":["test1","test2","test3","test4","test5"]}';
    var o:Object = JSON.decode(s);
    var a:Array = o['xaxis'] as Array;
    Alert.show(a.length.toString());

  • Decode and Ifthenelse

    Hi Experts,
                    I would like to know the functioning of decode and ifthenelse functions. Which one is faster. Is there difference in the performance of these two.
    Thanks & Regards
    Alex Oommen

    Hi Alex,
    ifthenelse function Allows conditional logic in expressions Returns one of the values provided, based on the result of condition. The data type of the return
    value is the data type of the expression in true_branch. If the data type of false_branch is not
    convertible to the data type of true_branch, Data Services produces an error at validation.
    decode returns the value associated with the first condition that evaluates to TRUE. The data type of the return value is the data type of the first expression in the condition_and_expression_list. If the data type of any subsequent expression or the default_expression is not convertible to the data type of the first expression, Data Services produces an error at validation. If the data types are convertible but do not match, a warning appears at validation.
    The decode function provides an easier way to write nested ifthenelse functions. In nested
    ifthenelse functions, you must write nested conditions and ensure that the parentheses are in the
    correct places, as the following example shows:
    ifthenelse ((EMPNO = 1), '111',
    ifthenelse((EMPNO = 2), '222',
    ifthenelse((EMPNO = 3), '333',
    ifthenelse((EMPNO = 4), '444',
    'NO_ID'))))
    In the decode function, you list the conditions, as the following example shows. Therefore, decode is
    less error prone than nested ifthenelse functions.
    decode ((EMPNO = 1), '111',
    (EMPNO = 2), '222',
    (EMPNO = 3), '333',
    (EMPNO = 4), '444',
    'NO_ID')
    Regards,
    M Ramesh

  • How  to exclude columns dynamic using group functions or any other function

    i have a select that look like this
    SELECT *
      FROM (SELECT DISTINCT gruposcomerciales.cod_gcomercial,
                            gruposcomerciales.descripcion,
                            DECODE (:0,
                                    'OFICIAL', pbeoficialesjerarquia.oficial_id,
                                    NULL
                                   ) oficial_id,
                            DECODE (:0,
                                    'BANCA', NULL,
                                    pbeoficialesjerarquia.id_cluster
                                   ) id_cluster,
                            pbeoficialesjerarquia.cod_banca
                       FROM grupos_comerciales gruposcomerciales,
                            clientes clientes,
                            clientes_oficiales clientesoficiales,
                            pbe_oficiales_jerarquia pbeoficialesjerarquia,
                            bancos_clientes bancosclientes
                      WHERE gruposcomerciales.cod_gcomercial =  bancosclientes.cod_gcomercial
                        AND clientes.ID = bancosclientes.cliente_id
                        AND clientes.ID = clientesoficiales.cliente_id
                        AND bancosclientes.cliente_id = clientesoficiales.cliente_id
                        AND bancosclientes.entidad_id = clientesoficiales.entidad_id
                        AND clientesoficiales.oficial_id = pbeoficialesjerarquia.oficial_id
                        AND gruposcomerciales.cod_gcomercial <> 'SINGRUPO100'
                        AND clientesoficiales.tipo_oficial = 'PRINCIPA'
                        AND bancosclientes.estado_clientes_ibs = 'ACTIVO') qrslt
    WHERE (cod_banca = :1 AND id_cluster = :2 AND oficial_id = :3)This SQL duplicate rows so i use a distinct to exclude duplicate rows and decode to set null for columns that not are interested at runtime to avoid duplicate rows
    I use decode to dynamicly set null (a way fo not show duplicate rows from colums)
    If :0 is OFICIAL its show 3 columns values for oficial_id,cod_banca,id_cluster
    if :0 is CLUSTER its show 2 columns values for cod_banca,id_cluster
    There is a way to group by columns without take in consideration duplicate rows of other columns

    If i do my query passing pameters to [b]OFICIAL_ID, ID_CLUSTER, AND COD_BANCA get this info
    COD_GCOMERCIAL  DESCRIPCION                          OFICIAL_ID ID_CLUSTER COD_BANCA
    ==============  ===========                          ========== ========== =========
    GRUPOALC1149     GRUPO ALCAP                          JESS329     39        BANCAEMP
    GRUPOALQ533     GRUPO ALQUILERES NACIONALES          JESS329     39        BANCAEMP
    GRUPOANA649     GRUPO ANA MARIA CHEN                 JESS329     39        BANCAEMP
    GRUPOANC253     GRUPO ANCON                          JESS329     39        BANCAEMP
    GRUPOARI104     GRUPO ARIAS Y DE LA GUARDIA          JESS329     39        BANCAEMP
    GRUPOATL813     GRUPO ATLAS CORPORATION              JESS329     39        BANCAEMP
    IF I pass parameters to ID_CLUSTER, AND COD_BANCA i get
    COD_GCOMERCIAL  DESCRIPCION                          OFICIAL_ID ID_CLUSTER COD_BANCA
    ==============  ===========                          ========== ========== =========
    GRUPOALC1149     GRUPO ALCAP                                    39        BANCAEMP
    GRUPOALQ533     GRUPO ALQUILERES NACIONALES                    39        BANCAEMP
    GRUPOANA649     GRUPO ANA MARIA CHEN                           39        BANCAEMP
    GRUPOANC253     GRUPO ANCON                                    39        BANCAEMP
    GRUPOARI104     GRUPO ARIAS Y DE LA GUARDIA                    39        BANCAEMP
    GRUPOATL813     GRUPO ATLAS CORPORATION                        39        BANCAEMP
    IF I pass parameters to COD_BANCA i get
    COD_GCOMERCIAL  DESCRIPCION                          OFICIAL_ID ID_CLUSTER COD_BANCA
    ==============  ===========                          ========== ========== =========
    GRUPOALC1149     GRUPO ALCAP                                            BANCAEMP
    GRUPOALQ533     GRUPO ALQUILERES NACIONALES                            BANCAEMP
    GRUPOANA649     GRUPO ANA MARIA CHEN                                   BANCAEMP
    GRUPOANC253     GRUPO ANCON                                            BANCAEMP
    GRUPOARI104     GRUPO ARIAS Y DE LA GUARDIA                            BANCAEMP
    GRUPOATL813     GRUPO ATLAS CORPORATION                                BANCAEMPMy decode on select do this functionality of set null to columns because there are sometimes in wich oficial_id or id_cluster get rows
    that i dont need take in consideration.
    this get overhead on my select and on 10g using inline views by dblink not work fine
    this decode on my select do this functionality
    decode('OFICIAL', 'OFICIAL' , pbeoficialesjerarquia.oficial_id, NULL) oficial_id,
    decode('OFICIAL', 'BANCA' , NULL, pbeoficialesjerarquia.id_cluster) id_cluster,
    So i know oracle has a lot off grouping function some of this should help me to get this work
    Tnx Warren

Maybe you are looking for