About decode statement

hi Gurus
can anybody tell me how to convert following if condition into decode
also i put my isnumber funtion.
Thanks
Vijay
if (SOURCE = 'QU'  AND RSLT_NBR = -999999.999999) then null
else if SOURCE = 'LC' AND RSLT_NBR = 0 AND IS_NUMBER(RSLT_TXT) then TO_DECIMAL(RSLT_TXT)
else RSLT_NBR
CREATE OR REPLACE function IS_NUMBER(str in varchar2) return number IS
dummy number;
begin
dummy := TO_NUMBER(str);
return (1);
Exception WHEN OTHERS then
return (0);
end;

we want to use this function in Sqlloader and I am not sure whether case will work in Sqlloader.It works fine. Did you test it and get an error? I'm using 10.2.0.4 (database and client).
Data:
MN
MI
SD.ctl file:
LOAD DATA
TRUNCATE
INTO TABLE t
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
(c      "case :c when 'MN' then 'Minnesota' when 'MI' then 'Michigan' else 'Other' end"
{code}
Result:
{code}
Table T, loaded from every logical record.
Insert option in effect for this table: TRUNCATE
   Column Name                  Position   Len  Term Encl Datatype
C                                   FIRST     *   ,  O(") CHARACTER           
    SQL string for column : "case :c when 'MN' then 'Minnesota' when 'MI' then 'Michigan' else 'Other' end"
Table T:
  3 Rows successfully loaded.
  0 Rows not loaded due to data errors.
  0 Rows not loaded because all WHEN clauses were failed.
  0 Rows not loaded because all fields were null.The table:
SQL> select * from t;
C
Minnesota
Michigan
Other

Similar Messages

  • Problem with DECODE statement while migrating forms to 6i

    Hi,
    I'm migrating a form from 5 to 6i. When I compiled the form, I got this error witha decode statement.
    The error is
    Error 307 at line 15 column 7
    too many declarations of "DECODE" match this call
    The trigger has this code:
    IF :PRUN_RECS_INSERTED = 'Y' THEN
          RETURN ;
       END IF ;
       INSERT INTO GJBPRUN
        ( GJBPRUN_JOB,
          GJBPRUN_ONE_UP_NO,
          GJBPRUN_NUMBER,
          GJBPRUN_ACTIVITY_DATE,
          GJBPRUN_VALUE )
       SELECT :KEYBLCK_JOB,
              :ONE_UP_NO,
               GJBPDFT_NUMBER,
               SYSDATE,
          DECODE(GJBPDFT_VALUE, 'SYSDATE',
                          DECODE(GJBPDEF_LENGTH,'11',TO_CHAR(SYSDATE,'DD-MON-YYYY'), SYSDATE),
                          GJBPDFT_VALUE)
       FROM   GJBPDFT G, GJBPDEFEdited by: Charan on Mar 16, 2011 9:15 AM

    Hi Charan
    i think it's all about using both CHARACTER and DATE values at the same time in a DECODE statment u should either use char or date datatype.
    DECODE compares expr to each search value one by one. If expr is equal to a search, then Oracle Database returns the corresponding result. If no match is found, then Oracle returns default. If default is omitted, then Oracle returns null.
    e.g.
    If expr and search are character data, then Oracle compares them using nonpadded comparison semantics.
    expr, search, and result can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2.
    The string returned is of VARCHAR2 datatype and is in the same character set as the first result parameter.
    for more pls have a look here
    Hope this helps,
    Regards,
    Abdetu...

  • DECODE Statement and argument limitations

    Does anyone know the number of arguments that the DECODE statement will allow you to enter. I currently have 863 and it gives me an error message when i try and run the query.
    Database Error - ORA-00939: too many arguments for function.
    Thanks
    Chris

    I dont have the rights to create/edit database, just pull data from it.
    Here is my attempt at the nest, but i stil get the error message about size.
    DECODE(
    DECODE(Point Of Sales His.End User Baan Account,'4260','Croteau; Mark','5001','Croteau; Mark','10714','Croteau; Mark','11966','Croteau; Mark','13739','Croteau; Mark','16233','Croteau; Mark','16736','Croteau; Mark','17276','Croteau; Mark','17377','Croteau; Mark','17387','Croteau; Mark','17436','Croteau; Mark','17452','Croteau; Mark','17485','Croteau; Mark','17681','Croteau; Mark','17741','Croteau; Mark','17794','Croteau; Mark','17799','Croteau; Mark','19364','Croteau; Mark','19462','Croteau; Mark','20205','Croteau; Mark','20995','Croteau; Mark','21916','Croteau; Mark','22269','Croteau; Mark','22629','Croteau; Mark','23562','Croteau; Mark','24078','Croteau; Mark','24079','Croteau; Mark','24550','Croteau; Mark','24796','Croteau; Mark','25196','Croteau; Mark','25506','Croteau; Mark','31494','Croteau; Mark','38067','Croteau; Mark','750457','Croteau; Mark'),
    DECODE(Point Of Sales His.End User Baan Account,'314','Bruning; Barbara','500','Bruning; Barbara','3601','Bruning; Barbara','4142','Bruning; Barbara','4433','Bruning; Barbara','8219','Bruning; Barbara','8584','Bruning; Barbara','13839','Bruning; Barbara','15195','Bruning; Barbara','15307','Bruning; Barbara','15523','Bruning; Barbara','16394','Bruning; Barbara','16529','Bruning; Barbara','17111','Bruning; Barbara','17410','Bruning; Barbara','17471','Bruning; Barbara','19158','Bruning; Barbara','19219','Bruning; Barbara','20219','Bruning; Barbara','20308','Bruning; Barbara','20687','Bruning; Barbara','22364','Bruning; Barbara','22895','Bruning; Barbara','23411','Bruning; Barbara','23983','Bruning; Barbara','24343','Bruning; Barbara','24890','Bruning; Barbara','25828','Bruning; Barbara','25866','Bruning; Barbara','32850','Bruning; Barbara','38046','Bruning; Barbara','38048','Bruning; Barbara','38049','Bruning; Barbara','38051','Bruning; Barbara','38192','Bruning; Barbara','38237','Bruning; Barbara'),
    DECODE(Point Of Sales His.End User Baan Account,'7781','Weber; Ed','8668','Weber; Ed','9016','Weber; Ed','12219','Weber; Ed','12669','Weber; Ed','13200','Weber; Ed','13529','Weber; Ed','13704','Weber; Ed','15453','Weber; Ed','16643','Weber; Ed','17127','Weber; Ed','17399','Weber; Ed','17400','Weber; Ed','17480','Weber; Ed','18064','Weber; Ed','18267','Weber; Ed','18914','Weber; Ed','20121','Weber; Ed','20177','Weber; Ed','21523','Weber; Ed','22155','Weber; Ed','22347','Weber; Ed','31405','Weber; Ed','31445','Weber; Ed','31542','Weber; Ed','31545','Weber; Ed','31696','Weber; Ed','31830','Weber; Ed','31960','Weber; Ed','32818','Weber; Ed','33111','Weber; Ed','34060','Weber; Ed','38061','Weber; Ed','38062','Weber; Ed','38063','Weber; Ed','38208','Weber; Ed','38213','Weber; Ed'),
    DECODE(Point Of Sales His.End User Baan Account,'3455','Rogers; Mary Jill','6854','Rogers; Mary Jill','7277','Rogers; Mary Jill','7376','Rogers; Mary Jill','8223','Rogers; Mary Jill','8645','Rogers; Mary Jill','12063','Rogers; Mary Jill','15449','Rogers; Mary Jill','16086','Rogers; Mary Jill','16782','Rogers; Mary Jill','16940','Rogers; Mary Jill','17036','Rogers; Mary Jill','17232','Rogers; Mary Jill','17285','Rogers; Mary Jill','17316','Rogers; Mary Jill','17430','Rogers; Mary Jill','17462','Rogers; Mary Jill','17656','Rogers; Mary Jill','20015','Rogers; Mary Jill','20277','Rogers; Mary Jill','23184','Rogers; Mary Jill','23318','Rogers; Mary Jill','23387','Rogers; Mary Jill','23388','Rogers; Mary Jill','23689','Rogers; Mary Jill','23696','Rogers; Mary Jill','24157','Rogers; Mary Jill','24219','Rogers; Mary Jill','24336','Rogers; Mary Jill','24676','Rogers; Mary Jill','24681','Rogers; Mary Jill','24793','Rogers; Mary Jill','24827','Rogers; Mary Jill','25038','Rogers; Mary Jill','25245','Rogers; Mary Jill','25281','Rogers; Mary Jill','25416','Rogers; Mary Jill','25417','Rogers; Mary Jill','25418','Rogers; Mary Jill','25419','Rogers; Mary Jill','25420','Rogers; Mary Jill','25421','Rogers; Mary Jill','25422','Rogers; Mary Jill','25423','Rogers; Mary Jill','25424','Rogers; Mary Jill','25425','Rogers; Mary Jill','25426','Rogers; Mary Jill','25427','Rogers; Mary Jill','25428','Rogers; Mary Jill','25429','Rogers; Mary Jill','25430','Rogers; Mary Jill','25431','Rogers; Mary Jill','25432','Rogers; Mary Jill','25433','Rogers; Mary Jill','25434','Rogers; Mary Jill','25435','Rogers; Mary Jill','25436','Rogers; Mary Jill','25437','Rogers; Mary Jill','25438','Rogers; Mary Jill','25439','Rogers; Mary Jill','25440','Rogers; Mary Jill','25441','Rogers; Mary Jill','25442','Rogers; Mary Jill','25443','Rogers; Mary Jill','25444','Rogers; Mary Jill','25445','Rogers; Mary Jill','25446','Rogers; Mary Jill','25447','Rogers; Mary Jill','25448','Rogers; Mary Jill','25449','Rogers; Mary Jill','25450','Rogers; Mary Jill','25451','Rogers; Mary Jill','25452','Rogers; Mary Jill','25453','Rogers; Mary Jill','25454','Rogers; Mary Jill','25455','Rogers; Mary Jill','25456','Rogers; Mary Jill','25457','Rogers; Mary Jill','25458','Rogers; Mary Jill','25459','Rogers; Mary Jill','25460','Rogers; Mary Jill','25461','Rogers; Mary Jill','25462','Rogers; Mary Jill','25463','Rogers; Mary Jill','25464','Rogers; Mary Jill','25465','Rogers; Mary Jill','25466','Rogers; Mary Jill','25467','Rogers; Mary Jill','25468','Rogers; Mary Jill','25469','Rogers; Mary Jill','25470','Rogers; Mary Jill','25471','Rogers; Mary Jill','25472','Rogers; Mary Jill','25473','Rogers; Mary Jill','25474','Rogers; Mary Jill','25475','Rogers; Mary Jill','25476','Rogers; Mary Jill','25477','Rogers; Mary Jill','25478','Rogers; Mary Jill','25479','Rogers; Mary Jill','25488','Rogers; Mary Jill','25489','Rogers; Mary Jill','25522','Rogers; Mary Jill','25532','Rogers; Mary Jill','25541','Rogers; Mary Jill','25547','Rogers; Mary Jill','25570','Rogers; Mary Jill','25775','Rogers; Mary Jill','25845','Rogers; Mary Jill','25875','Rogers; Mary Jill','32164','Rogers; Mary Jill','33328','Rogers; Mary Jill','33844','Rogers; Mary Jill','38057','Rogers; Mary Jill','38060','Rogers; Mary Jill'),
    DECODE(Point Of Sales His.End User Baan Account,'4188','Gallo; Peter','7520','Gallo; Peter','8371','Gallo; Peter','9524','Gallo; Peter','9647','Gallo; Peter','10768','Gallo; Peter','12788','Gallo; Peter','15248','Gallo; Peter','16641','Gallo; Peter','17284','Gallo; Peter','17330','Gallo; Peter','17331','Gallo; Peter','17332','Gallo; Peter','17333','Gallo; Peter','17334','Gallo; Peter','17335','Gallo; Peter','17336','Gallo; Peter','17347','Gallo; Peter','17431','Gallo; Peter','17598','Gallo; Peter','17763','Gallo; Peter','17801','Gallo; Peter','18529','Gallo; Peter','19071','Gallo; Peter','19328','Gallo; Peter','19572','Gallo; Peter','21003','Gallo; Peter','22975','Gallo; Peter','23548','Gallo; Peter','23562','Gallo; Peter','23985','Gallo; Peter','24088','Gallo; Peter','25665','Gallo; Peter','32145','Gallo; Peter','32905','Gallo; Peter','38053','Gallo; Peter','38059','Gallo; Peter','38070','Gallo; Peter','38071','Gallo; Peter','38072','Gallo; Peter','38200','Gallo; Peter'),
    DECODE(Point Of Sales His.End User Baan Account,'142','Coady; Ed','1291','Coady; Ed','2420','Coady; Ed','7726','Coady; Ed','9334','Coady; Ed','10678','Coady; Ed','11487','Coady; Ed','12052','Coady; Ed','12223','Coady; Ed','15386','Coady; Ed','15597','Coady; Ed','16245','Coady; Ed','17277','Coady; Ed','17278','Coady; Ed','17469','Coady; Ed','17674','Coady; Ed','17675','Coady; Ed','17731','Coady; Ed','17826','Coady; Ed','18500','Coady; Ed','18791','Coady; Ed','19035','Coady; Ed','19100','Coady; Ed','19130','Coady; Ed','19131','Coady; Ed','19132','Coady; Ed','19133','Coady; Ed','19134','Coady; Ed','19135','Coady; Ed','19136','Coady; Ed','19137','Coady; Ed','19138','Coady; Ed','19139','Coady; Ed','19140','Coady; Ed','19141','Coady; Ed','19142','Coady; Ed','19143','Coady; Ed','19144','Coady; Ed','19145','Coady; Ed','19146','Coady; Ed','19147','Coady; Ed','19148','Coady; Ed','19149','Coady; Ed','19150','Coady; Ed','19151','Coady; Ed','19152','Coady; Ed','19175','Coady; Ed','19300','Coady; Ed','19533','Coady; Ed','19999','Coady; Ed','20900','Coady; Ed','21020','Coady; Ed','21053','Coady; Ed','21144','Coady; Ed','21470','Coady; Ed','21665','Coady; Ed','21720','Coady; Ed','21731','Coady; Ed','22829','Coady; Ed','22841','Coady; Ed','23457','Coady; Ed','24243','Coady; Ed','24257','Coady; Ed','24345','Coady; Ed','24383','Coady; Ed','25184','Coady; Ed','25354','Coady; Ed','25777','Coady; Ed','25865','Coady; Ed','30181','Coady; Ed','31349','Coady; Ed','38052','Coady; Ed','38224','Coady; Ed'),
    DECODE(Point Of Sales His.End User Baan Account,'1106','Saale; Thomas','2726','Saale; Thomas','6840','Saale; Thomas','7785','Saale; Thomas','7834','Saale; Thomas','8464','Saale; Thomas','8843','Saale; Thomas','8897','Saale; Thomas','9074','Saale; Thomas','9809','Saale; Thomas','10259','Saale; Thomas','10301','Saale; Thomas','10313','Saale; Thomas','10314','Saale; Thomas','10604','Saale; Thomas','10662','Saale; Thomas','10788','Saale; Thomas','10789','Saale; Thomas','10790','Saale; Thomas','10791','Saale; Thomas','10792','Saale; Thomas','10793','Saale; Thomas','10794','Saale; Thomas','10795','Saale; Thomas','10796','Saale; Thomas','10798','Saale; Thomas','10799','Saale; Thomas','10800','Saale; Thomas','10801','Saale; Thomas','10802','Saale; Thomas','10803','Saale; Thomas','10804','Saale; Thomas','10805','Saale; Thomas','10806','Saale; Thomas','10807','Saale; Thomas','10808','Saale; Thomas','10809','Saale; Thomas','10810','Saale; Thomas','10811','Saale; Thomas','10812','Saale; Thomas','10813','Saale; Thomas','10814','Saale; Thomas','10815','Saale; Thomas','10816','Saale; Thomas','10817','Saale; Thomas','10818','Saale; Thomas','10819','Saale; Thomas','10820','Saale; Thomas','10821','Saale; Thomas','10822','Saale; Thomas','10823','Saale; Thomas','10824','Saale; Thomas','10825','Saale; Thomas','10826','Saale; Thomas','10827','Saale; Thomas','10828','Saale; Thomas','10829','Saale; Thomas','10830','Saale; Thomas','10831','Saale; Thomas','10832','Saale; Thomas','10833','Saale; Thomas','10834','Saale; Thomas','10835','Saale; Thomas','10836','Saale; Thomas','10837','Saale; Thomas','10838','Saale; Thomas','10839','Saale; Thomas','10840','Saale; Thomas','10841','Saale; Thomas','10842','Saale; Thomas','10843','Saale; Thomas','10845','Saale; Thomas','10846','Saale; Thomas','10853','Saale; Thomas','10854','Saale; Thomas','10855','Saale; Thomas','10856','Saale; Thomas','10858','Saale; Thomas','10859','Saale; Thomas','10860','Saale; Thomas','10906','Saale; Thomas','10916','Saale; Thomas','10960','Saale; Thomas','11012','Saale; Thomas','11420','Saale; Thomas','11723','Saale; Thomas','11872','Saale; Thomas','11939','Saale; Thomas','11940','Saale; Thomas','11941','Saale; Thomas','12650','Saale; Thomas','12657','Saale; Thomas','12717','Saale; Thomas','12749','Saale; Thomas','12756','Saale; Thomas','12792','Saale; Thomas','12847','Saale; Thomas','12969','Saale; Thomas','13063','Saale; Thomas','13323','Saale; Thomas','13413','Saale; Thomas','13433','Saale; Thomas','13475','Saale; Thomas','13493','Saale; Thomas','13754','Saale; Thomas','13859','Saale; Thomas','14204','Saale; Thomas','14612','Saale; Thomas','14615','Saale; Thomas','14748','Saale; Thomas','15147','Saale; Thomas','15149','Saale; Thomas','15473','Saale; Thomas','15551','Saale; Thomas','15613','Saale; Thomas','15659','Saale; Thomas','15872','Saale; Thomas','15891','Saale; Thomas','16360','Saale; Thomas','16837','Saale; Thomas','16849','Saale; Thomas','16909','Saale; Thomas','16981','Saale; Thomas','17048','Saale; Thomas','17153','Saale; Thomas','17402','Saale; Thomas','17833','Saale; Thomas','18095','Saale; Thomas','18226','Saale; Thomas','18342','Saale; Thomas','18900','Saale; Thomas','19331','Saale; Thomas','19651','Saale; Thomas','19667','Saale; Thomas','19850','Saale; Thomas','19856','Saale; Thomas','20054','Saale; Thomas','20069','Saale; Thomas','20120','Saale; Thomas','20454','Saale; Thomas','20753','Saale; Thomas','20758','Saale; Thomas','20765','Saale; Thomas','21860','Saale; Thomas','22062','Saale; Thomas','22548','Saale; Thomas','22772','Saale; Thomas','22966','Saale; Thomas','22972','Saale; Thomas','22989','Saale; Thomas','23623','Saale; Thomas','23816','Saale; Thomas','23817','Saale; Thomas','23893','Saale; Thomas','24014','Saale; Thomas','24022','Saale; Thomas','24122','Saale; Thomas','24158','Saale; Thomas','24179','Saale; Thomas','24248','Saale; Thomas','24329','Saale; Thomas','24338','Saale; Thomas','24366','Saale; Thomas','24481','Saale; Thomas','24517','Saale; Thomas','24611','Saale; Thomas','24618','Saale; Thomas','24816','Saale; Thomas','24820','Saale; Thomas','24880','Saale; Thomas','24924','Saale; Thomas','24925','Saale; Thomas','24936','Saale; Thomas','24985','Saale; Thomas','24998','Saale; Thomas','25191','Saale; Thomas','25326','Saale; Thomas','25327','Saale; Thomas','25598','Saale; Thomas','25821','Saale; Thomas'),
    DECODE(Point Of Sales His.End User Baan Account,'620753','Saale; Thomas','620758','Saale; Thomas','620765','Saale; Thomas','623816','Saale; Thomas','623817','Saale; Thomas','624014','Saale; Thomas','624022','Saale; Thomas','624248','Saale; Thomas','624329','Saale; Thomas','624816','Saale; Thomas','624880','Saale; Thomas','625598','Saale; Thomas','899998','Saale; Thomas','E99998','Saale; Thomas','UPS001','Saale; Thomas'),
    'Other')

  • How to replace huge decode statements with lookups to some simple code/key

    I have a legacy PL/SQL application, composed of many very huge decode statements. And the most terribe one is that the guys who develops the application left the company now, leaves no documentation.
    We are trying to read and understand those PL/SQL programs, and I'm asked to replace those huge decode statements with lookups to some simple code/key tables? But I have no idea about how to design such code/key tables. Is there any one who has similar experience may help me? Besides code/key tables, any idea will be welcome.
    Thank you very much!

    Not sure what your data looks like but sometimes decode can be replaced with more appropriate functions, ie;
    SQL> with t as (
       select 'DAY' a, 30 b, null c, null d from dual union all
       select null a, null b, 'MONTH' c, 12 from dual)
    select coalesce(b,d)
    from t
    COALESCE(B,D)
               30
               12
    2 rows selected.
    SQL> with t as (
       select 'DAY' a, 30 b, null c, 0 d from dual union all
       select null a, 0 b, 'MONTH' c, 12 from dual)
    select greatest(b,d)
    from t
    GREATEST(B,D)
               30
               12
    2 rows selected.

  • Decode statement in Select line of a View Object Query

    I attempted to create a view object in expert mode with a customized query.
    The query had a decode statement in the select line of the query. The view
    object compiled correctly but gave an error when run.
    ex: select .... decode(CrpSchools.SCHOOLS_ID,null,CrpCustSchools.SCHOOL_NAME,CrpSchools.SCHOOL_NAME) SCHOOL_VALUE, ...
    from ....
    where ....
    The error was that school_value does not exist in the statement. I got the error when
    doing a vo.executeQuery().
    When I removed the decode statement everything worked correctly. Does anyone know if
    the decode statement cannont be used in the select line of a query in a view object?
    Or maybe I was linking the query column (SCHOOLS_ID) up to the view attribute (SCHOOL_VALUE) incorrectly in the
    Attribute Mappings tab of the VO wizard?

    There should be no problem using a DECODE() statement, provided that you've aliases the column as you have done.
    At design time, if you click on the (Test) button, does your query test ok?
    Are you by chance applying a custom where clause at runtime?
    If so, are you saying:
    setWhereClause("yourtable.column_alias = ?";
    or are you doing:
    setWhereClause("column_alias = ?";
    for an expert-mode query, you'll need to use the latter syntax.

  • Logical Standby SQL Apply Using Incorrect Decode Statement

    We are seeing statements erroring out on our logical standby that have been rewritten (presumably by sql apply) with decode statements that don't appear to be correct. For example, here is one of the rewritten statements.
    update /*+ streams restrict_all_ref_cons */ "CADPROD"."OMS_SQL_STATEMENT" p
    set *"APPLICATION"=decode(:1,'N',"APPLICATION",:2)*,
    "STATEMENT"=dbms_reputil2.get_final_lob(:3,"STATEMENT",:4)
    where (:5='N' or(1=1 and (:6='N' or(dbms_lob.compare(:7,"STATEMENT")=0)or(:7 is null and "STATEMENT" is null)))) and(:8="APPLICATION")
    The problem comes in, we believe, with the attempt to write the value "APPLICATION" to the application column which is only a 10 character field. the value for the :1 bind variable is "N" and the value for :2 is null.
    We see the following error on the logical standby:
    ORA-00600: internal error code, arguments: [kgh_heap_sizes:ds], [0x01FCDBE60], [], [], [], [], [], []
    ORA-07445: exception encountered: core dump [ACCESS_VIOLATION] [kxtoedu+54] [PC:0x2542308] [ADDR:0xFFFFFFFFFFFFFFFF] [UNABLE_TO_READ] []
    ORA-12899: value too large for column "CADPROD"."OMS_SQL_STATEMENT"."APPLICATION" (actual: 19576, maximum: 10)
    Is this a configuration issue or is it normal for SQL Apply to convert statements from logminer into decode statements?
    We have an Oracle 10.2.0.4 database running on windows 2003 R2 64-bit os. We have 3 physical and 2 logical standby's, no problems on the physical standbys.

    Hello;
    I noticed some of your parameters seem to be wrong.
    fal_client - This is Obsolete in 11.2
    You have db_name='test' on the Standby, it should be 'asadmin'
    fal_server=test is set like this on the standby, it should be 'asadmin'
    I might consider changing VALID_FOR to this :
    VALID_FOR=(ONLINE_LOGFILES,ALL_ROLES)Would review 4.2 Step-by-Step Instructions for Creating a Logical Standby Database of Oracle Document E10700-02
    Document 278371.1 is showing its age in my humble opinion.
    -----Wait on this until you fix your parameters----------------------
    Try restarting the SQL Apply
    ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATEI don't see the parameter MAX_SERVERS, try setting it to 8 times the number of cores.
    Use these statements to trouble shoot :
    SELECT NAME, VALUE, UNIT FROM V$DATAGUARD_STATS;
    SELECT NAME, VALUE FROM V$LOGSTDBY_STATS WHERE NAME LIKE ;TRANSACTIONS%';
    SELECT COUNT(1) AS IDLE_PREPARERS FROM V$LOGSTDBY_PROCESS WHERE
    TYPE = 'PREPERER' AND STATUS_CODE = 16166;Best Regards
    mseberg
    Edited by: mseberg on Feb 14, 2012 7:37 AM

  • How to determine INT and FLOAT in a DECODE statement

    Can anyone help me with the following problem:
    I have a column defined as a NUMBER(15,4). I am trying to determine the java type using the getScale() method in ResultSetMetaData. When the scale is greater than 0, then it is an float, else it is an int. In this case, the getScale() method should return 4. However, when querying with a DECODE statement on the NUMBER(15,4) field, the getScale() method always returns 0 and the value is therefore converted to an int. Anyone knows how to solve this problem?
    Thanks

    Alcides,
    Oracle NUMBER data type is mapped to "java.math.BigDecimal" class.
    You will find more information in the JDBC Developer's Guide and Reference which is part of the Oracle documentation and available from:
    http://www.oracle.com/technology/documentation/index.html
    Good Luck,
    Avi.

  • About Decode Function in oracle(on 28th)

    Hi all
    Can i use Decode function with Distinct as following.
    SUM(DISTINCT DECODE(LR.QUESTIONNAIRE_ID,62, L.WORK_SPACE))
    Regards

    Hi,
    The argument to SUM can be any numeric expression, including a DECODE statement that evaluates to a number.
    "SUM (DISTINCT ..." is very suspicious. If you have three rows, with values 1, 1 and 3, the "SUM (DISTINCT" is 4. Is that what you want?
    Perhaps your problem is that whenever you have more than one row, they will always be identical (e.g., a one-to-may join), so you have rows with 1, 1, and 1, from which you want to return 1. Most people do that by adding the value to the GROUP BY list, or by using MAX or MIN instead of SUM: they get the same results, but the code is clearer, and it works on non-numeric columns.

  • Need help on decode statement

    I had the table as follows :
    ITEMCODE TEDCODE AMOUNT
    AAAA BED 12345
    AAAA EDU CESS 1234
    AAAA SHECESS 123
    AAAA CST 3% 12456
    AND SO ON.
    Now i want to convert the rows in Column heading TEDCODE to columns. But i want the specific rows like BED, EDU CESS, SHECESS in one column suppose EXCISE, and the other row i.e CST 3% in other column under heading TAX.
    Please help me how i can do it using Decode statement.

    SQL> create table t (itemcode varchar(4),tedcode varchar(10),amount number);
    Table created.
    SQL> insert into t values('AAAA','BED',12345);
    1 row created.
    SQL> insert into t values('AAAA','EDU CESS',1234);
    1 row created.
    SQL> insert into t values('AAAA','SHECESS',123);
    1 row created.
    SQL> insert into t values('AAAA','CST 3%',12456);
    1 row created.
    SQL> select itemcode, tedcode,decode(tedcode,'CST 3%',null,amount) EXCISE, decod
    e(tedcode,'CST 3%',amount,null) TAX from t;
    ITEM TEDCODE    EXCISE                                          TAX
    AAAA BED        12345
    AAAA EDU CESS   1234
    AAAA SHECESS    123
    AAAA CST 3%                                                   12456

  • Calling a stored proc in a decode statement

    I am having a problem calling a store procedure in a SQL statement. I am using Oracle's thin driver.
    I have been able to do the following:
    select col1,
    col2,
    SOME_STORED_PROC(var1,var2,col3)
    from some_table
    where col3 = var3
    However, when I try to call a stored procedure with-in a decode statement, the call fails. I have tested the call from a sql prompt and it works fine but it does not work when I execute the query in my Java program.
    Here is an example of what I am trying to do:
    select col1,
    col2,
    decode((select col1
    from some_other_table
    where col2 = var1), 'X',
    SOME_STORED_PROC(var1,var2,col3),
    SOME_OTHER_STORED_PROC(var2,var4,col5))
    from some_table
    where col3 = var3
    Does anyone know if this type of call is not supported in Oracle's thin driver?
    Thanks,
    Cory
    null

    I played around with a [parallel PL/SQL launcher|http://www.williamrobertson.net/feed/2008/08/parallel-plsql-launcher-update.html] a while ago, but I wouldn't call it production-ready.
    You could also [submit procedure calls in background|http://www.williamrobertson.net/feed/2005/12/job-control-object.html] using DBMS_ALERT to track completion status.

  • Problem with Decode statement

    Hi
    I am trying to achieve the following in my report:
    If an employee has a surname of . (dot) or a first name of . (dot), the report should not display a dot. An employee's name is made up of surname, first name and middle name which should all be concatenated together. To try to achieve this, I have the following statement in my report:
    decode(e.Surname, '.', ( LTRIM(RTRIM((INITCAP(e.FIRST_NAME)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
    e.FIRST_NAME, '.', ( LTRIM(RTRIM((INITCAP(e.Surname)))||' '||INITCAP(e.MIDDLE_NAME)) ) ,
    ( LTRIM(RTRIM((INITCAP(e.SURNAME )))||', '||INITCAP(e.FIRST_NAME)||' '||INITCAP(e.MIDDLE_NAME)) ) ) as emp_name
    FROM Employee e
    Problem: The above statement is only working for those employees with surname of . (dot). It's not working for first names of dot. How can I use the decode statement OR is there any other way of doing it without using the CASE statement?
    It seems my decode statement doesn't work with 2 different fields (surname, firstname) being tested within one decode statement.Thanks.

    Thank you so much InoL . I have used the ltrim with Replace but now have a new problem.
    Because I am joining Surname, First name and middle name together and put a comma after the Surname, the name now appears as follows:
    , Maria Ane (if Surname is a dot)
    Boiler, (if first name is a dot)
    I would like to get rid of a comma and only have comma when surname or first name does not have a dot, i.e. for those people with full names e.g. Blake, Anna Marie.
    InoL, how can I achieve this? Thanks.

  • Question about delete statement

    I have question about delete statement...
    i am performing some simple delete statement against one table..but its taking so long..How can we check whether particular delete statements actually deleting records or not..?

    Is the associated select-statement returning rows or not?
    If yes -> delete is deleting
    If no -> delete is just using CPU-cycles
    To tune the delete-statement, you have to tune the corresponding select-statement. To tune the select-statement, you want to read the thread When your query takes too long ...

  • DECODE statement

    please can someone kindly code the following line of SQL using the DECODE statement:
    case when Student_Status in ('Registered','Repeat','Referral', 'Deferral')and GRADE <> 'MISSING' then EXAM1_RESULT else Null end as Valid_EX1
    It will be most appreciated.
    Thanks

    user607929 wrote:
    I'm ever so sorry, I keep sending the same Wrong thing.
    This is what i need translated to DECODE:
    "case when
    Student_Status in ('Registered','Repeat','Referral', 'Deferral') and GRADE is not 'MISSING'
    then EXAM1_RESULT
    else Null end as Valid_EX1"
    the issue is with the NOT 'MISSING' string.Check this. Just re-arrange of Andrés Muchiut post
    DECODE (
    STUDENT_STATUS
    ,'Registered',DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Repeat' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Referral' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    ,'Deferral' ,DECODE(GRADE,'MISSING',null,EXAM1_RESULT)
    , null) Valid_EX1Hope this may help you...

  • Decode statement in a mapping involve Source Text File & Table.

    Hi All,
    Oracle 9i Warehouse Builder Client: 9.2.0.4.0
    Oracle 9i Warehouse Builder Repository: 9.2.0.2.0
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit Production
    Does OWB allow to use Decode statement in a mapping involves Source Text File and Oracle Table.
    My understanding is it's not possible, since OWB makes use of Sqlloader. For this work arround could be make use of External Table instead of Text Flat File.
    However I came across an old posting (June-2003) which says that this feature is available OWB 9.2.
    Following is the url:
    IF THEN LOGIC from Flat File to Table
    Can someone please confirm this?
    Thanks in Advance.
    Regards,
    Vidyanand

    Hi all,
    If you want to validate correctly this mapping you must to :
    1. Right click on the mapping, then Configure
    2. Right click on Sql Loader Data Files, then Create
    3. Verify that the location name is correct and complete the Data File Name
    4. OK
    The validation is now OK.
    I hope it will be help you
    Best Regards
    Samy

  • NULLIF Function converts to illegal DECODE Statement

    I am converting a SQLServer 2000 application to Oracle 8i (release 3) using release 9.2.0.1.7 of the Migration Workbench. I have 39 SQLServer stored procedures which utilize the NULLIF function. The Migration Workbench is converting the NULLIF into a DECODE statement which results in the following PL/SQL compilation error.
    Line: 59 Column: 40 Error: PLS-00204: function or pseudo-column 'DECODE' may be used inside a SQL statement only
    T-SQL line --> SET @VAL = LTRIM(RTRIM(NULLIF(@VAL,'')))
    PL/SQL line --> PROCNAME.VAL := LTRIM(RTRIM(DECODE(PROCNAME.VAL,'',NULL,PROCNAME.VAL)));
    Why is the workbench creating an illegal use of the DECODE function in the PL/SQL ? Is there another workaround or 'trick' that I could apply so I don't have to manually correct a lot of code ?

    Stephen,
    Bug logged: Bug3393406
    The workaround is to use select from dual:
    SELECT LTRIM(RTRIM(DECODE(PROCNAME.VAL,'',NULL,PROCNAME.VAL)))
    INTO PROCNAME.VAL FROM DUAL;
    This is automatically done if 'SELECT' is used in place of 'SET' in T-SQL.
    Turloch

Maybe you are looking for

  • Old external drive; how to check for virus?

    I`ve an old external drive from the time I was a Windows PC user. I just don`t want a virus on my macbook, so I want to make sure that the drive is clean, and wipe out all the deadly ****. So, what do I do? PS, I have really important stuff in there

  • [b]Strange Java.rmi.ServerError[/b]  (very Urgent)

    I have a rmi application runninfg on one server (called 1), and web application accessing that application (running on JRUN 3.0) from onother server (called 2). [ I am newly setting up this structure on another servers (fallback server). Its working

  • Runtime Error CALL_FUNCTION_PARM_MISSING in a custom report program

    Hi All, I've created a custom report program to create parameters for a user in a system. I'm getting a runtime error in the code. The code snippet as below. I'm getting that error at line no 161. I'm not able to figure it out. Please help me to corr

  • Error in receiving goods - fiscal year

    Hello everyone, To receive goods with the transaction MIGO and get the following error message : "version 0 is not defined for 2009 fiscal year" (#GP626). Does anyone know what this message means and what can be done? Many thanks! SB

  • The browser will not keep its preferences or options.

    Every time I set them and reboot or shutdown, settings all reset back to first use (i.e. show all splash screens for extensions etc.) Happens everytime no exception. No preferences saved and reused you have to reset all items contained in the Options