Insert while using Decode Statement

Hi,
I have a unique problem(I think so). Is it possibe to insert into a table while selecting from another table using DECODE function. I am giving the select statement below. When I run this statement it says that missing expression. I could not find out the mistake. Is this query right or any changes to be made. Moreover I would like to know whether it is the right way of doing.
The SQL Statement is as follows.
SQL> select decode(EV,'E',(INSERT INTO assets1 VALUES
(31,NULL,NULL))) from assets;
Thanking in advance for timely help.
Guru Prasad.

Hi,
U Cannot do that ... B'cos u cannot have Insert Inside a Select.
What you can do is... Right a Small Pl/SQL Block which will do that for you.
Regards,
Ganesh R

Similar Messages

  • How to Insert Character using Prepared statement

    Hi All,
    Can anyone let me know how can I insert character using prepared statement.
    Thanks
    Sameer

    In the future JDBC related questions should be posted into the JDBC forum.
    Can you please provide some more information about what you are trying to do? It isn't clear to me. Are you trying to update a CHAR field?

  • Error while using Merge statement

    Hi,
    Can any one please look at the merge statement and help me understand the error.Thanks in advance.
    MERGE /*+ APPEND */
    INTO intf_lpa_master m
    USING (SELECT std_district_student_id,
    std_grade_code,
    sub_test,
    test_date,
    performance_lvl_code,
    test_lang_code,
    v_student_id,
    v_test_id,
    v_lang_cd,
    v_plc,
    valid_test_date,
    -- school_year,
    -- school_id,
    valid_src_stu_id,
    test_code
    FROM intf_lpa_master_vw
    MINUS
    SELECT std_district_student_id,
    std_grade_code,
    sub_test,
    test_date,
    performance_lvl_code,
    test_lang_code,
    v_student_id,
    v_test_id,
    v_lang_cd,
    v_plc,
    valid_test_date,
    -- school_yr,
    -- school_id,
    valid_src_stu_id,
    test_code
    FROM intf_lpa_master
    WHERE active_flag = 'Y') v
    ON ( m.std_district_student_id = v.std_district_student_id
    AND m.sub_test = v.sub_test
    AND m.test_date = v.test_date)
    WHEN MATCHED
    THEN
    UPDATE SET m.std_grade_code = v.std_grade_code,
    m.performance_lvl_code = v.performance_lvl_code,
    m.test_lang_code = v.test_lang_code,
    m.active_flag = 'Y', -- if we are touching this record, it is to be active.
    m.error_message = NULL, -- refresh these, to properly reconsider records.
    m.create_date = SYSDATE,
    m.record_id = intf_lpa_master_seq.NEXTVAL,
    m.process_row = 'U',
    m.last_update_date = SYSDATE,
    m.last_update_user = 'PRE_PROCESS_LPA - UPDATE',
    -- m.job_id = c_run_id ,
    m.validation_step = NULL, -- refresh these, to properly reconsider records.
    m.v_student_id = v.v_student_id,
    m.v_test_id = v.v_test_id,
    m.v_lang_cd = v.v_lang_cd,
    m.v_plc = v.v_plc,
    m.valid_test_date = v.valid_test_date,
    -- m.school_year = v.schloo_year,
    -- m.school_id = v.school_id,
    m.valid_src_stu_id = v.valid_src_stu_id,
    m.test_code = v.test_code
    WHEN NOT MATCHED
    THEN
    INSERT (
    m.std_district_student_id,
    m.std_grade_code,
    m.sub_test,
    m.test_date,
    m.performance_lvl_code,
    m.test_lang_code,
    m.active_flag,
    m.error_message,
    m.create_date,
    m.record_id,
    m.process_row,
    m.last_update_date,
    m.last_update_user,
    -- m.job_id,
    m.validation_step,
    m.v_student_id,
    m.v_test_id,
    m.v_lang_cd,
    m.v_plc,
    m.valid_test_date,
    -- m. school_year,
    -- m. school_id,
    m.valid_src_stu_id,
    m.test_code)
    VALUES (
    v.std_district_student_id,
    v.std_grade_code,
    v.sub_test,
    v.test_date,
    v.performance_lvl_code,
    v.test_lang_code,
    'Y',
    NULL,
    SYSDATE,
    intf_lpa_master_seq.NEXTVAL,
    'I',
    SYSDATE,
    'PRE_PROCESS_LPA - INSERT',
    -- c_run_id,
    NULL,
    v.v_student_id,
    v.v_test_id,
    v.v_lang_cd,
    v.v_plc,
    v.valid_test_date,
    -- v. school_year,
    -- v. school_id,
    v.valid_src_stut_id,
    v.test_code);
    Error Message :
    ORA-06553 : PLS-306:wrong number or types of arguments in call to 'V'

    There are a couple of thngs wrong here. In the when matched insert column list, you cannot qualify the field name with the table alias. It should be just:
    insert (std_district_student_id, std_grade_code, sub_test ...)Are v_student_id, v_test_id, v_lang_cd, and v_plc really columns in the intf_lpa_master table? I am more used to seeing v_name as a variable naming convention than a column name, but I could be wrong.
    John

  • Insert while using multi table

    Hi
    I have created a class and using multi table feature to retrieve fields from couple of tables. These tables are associated via Foreign key. This works fine while select, but fails while insert a new record in primary table using unitOfWork.
    Here is the peice of code i am using
    UnitOfWork uow = CfToplink9Helper.getUnitOfWork();
    uow.registerNewObject(basketEntry);
    uow.commit();
    Any suggestions !!! Appreciate your response !!!

    Here is the exception
    TopLink Severe]: UnitOfWork(734604338)--java.lang.NullPointerException
    at oracle.toplink.internal.descriptors.ObjectBuilder.addPrimaryKeyForNonDefaultTable(ObjectBuilder.java:104)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildRowForTranslation(ObjectBuilder.java:631)
    at oracle.toplink.queryframework.WriteObjectQuery.prepareForExecution(WriteObjectQuery.java:141)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:500)
    at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2091)
    at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2291)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1101)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1055)
    at oracle.toplink.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:177)
    at oracle.toplink.publicinterface.Session.writeAllObjectsWithChangeSet(Session.java:3286)
    at oracle.toplink.publicinterface.UnitOfWork.commitToDatabase(UnitOfWork.java:1068)
    at oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeSet(UnitOfWork.java:1115)
    at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOfWork.java:938)
    at oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:754)
    at com.cna.app.sentinelBatch.batch.DBWriter.addBasketEntry(DBWriter.java:48)
    at com.cna.app.sentinelBatch.batch.DBWriter.main(DBWriter.java:327)
    [TopLink Info]: ClientSession(542256178)--Connection(598240304)--rollback transaction
    [TopLink Severe]: UnitOfWork(734604338)--java.lang.NullPointerException
    at oracle.toplink.internal.descriptors.ObjectBuilder.addPrimaryKeyForNonDefaultTable(ObjectBuilder.java:104)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildRowForTranslation(ObjectBuilder.java:631)
    at oracle.toplink.queryframework.WriteObjectQuery.prepareForExecution(WriteObjectQuery.java:141)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:500)
    at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2091)
    at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2291)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1101)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1055)
    at oracle.toplink.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:177)
    at oracle.toplink.publicinterface.Session.writeAllObjectsWithChangeSet(Session.java:3286)
    at oracle.toplink.publicinterface.UnitOfWork.commitToDatabase(UnitOfWork.java:1068)
    at oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeSet(UnitOfWork.java:1115)
    at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOfWork.java:938)
    at oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:754)
    at com.cna.app.sentinelBatch.batch.DBWriter.addBasketEntry(DBWriter.java:48)
    at com.cna.app.sentinelBatch.batch.DBWriter.main(DBWriter.java:327)
    java.lang.NullPointerException
    at oracle.toplink.internal.descriptors.ObjectBuilder.addPrimaryKeyForNonDefaultTable(ObjectBuilder.java:104)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildRowForTranslation(ObjectBuilder.java:631)
    at oracle.toplink.queryframework.WriteObjectQuery.prepareForExecution(WriteObjectQuery.java:141)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:500)
    at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2091)
    at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2291)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1101)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1055)
    at oracle.toplink.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:177)
    at oracle.toplink.publicinterface.Session.writeAllObjectsWithChangeSet(Session.java:3286)
    at oracle.toplink.publicinterface.UnitOfWork.commitToDatabase(UnitOfWork.java:1068)
    at oracle.toplink.publicinterface.UnitOfWork.commitToDatabaseWithChangeSet(UnitOfWork.java:1115)
    at oracle.toplink.publicinterface.UnitOfWork.commitRootUnitOfWork(UnitOfWork.java:938)
    at oracle.toplink.publicinterface.UnitOfWork.commit(UnitOfWork.java:754)
    at com.cna.app.sentinelBatch.batch.DBWriter.addBasketEntry(DBWriter.java:48)
    at com.cna.app.sentinelBatch.batch.DBWriter.main(DBWriter.java:327)

  • Getting an error while using if statement in calculated column.can anyone please help me with this issue

    I am trying to learn HANA on my own.i have product id,product name,delivery date and Grossamount in my calculated view.i am trying to create calculated column where i need Grossamount in two columns based on delivery date.I have 2012 and 2013 as values for my delivery date.so i have created two column as grossamount_2012 and grossamount_2013.if i have delivery date as 4thdec,2012 i want the grossamount value to be in coloumn grossamount_2012 and the grossamount_2013 should be blank.i have written an expression like this
    if("Deliverydate" <= longdate(2012-12-04),"Grossamount","0")
    and it looks like this is wrong.i am getting the text Grossamount rather than values for that field in my output.so can anyone help me please?

    Hi chandra
    i am trying to get the same result by using sql script and CE functions.i have written the following code
    select A."PRODUCTID",
           E."TEXT" as "PRODUCTNAME",
           C."COUNTRY",
           D."DELIVERYDATE",
           Sum(D."GROSSAMOUNT") as "GROSSAMOUNT"
           from "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Products" as A     
           inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.BusinessPartner" as B
           on A."SUPPLIERID" = B."PARTNERID"      
           inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.MasterData.Addresses" as C
           on B."ADDRESSID" = C."ADDRESSID"
           inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.Purchase.Item" as D
           on A."PRODUCTID" = D."PRODUCTID"
           inner join "SAP_HANA_DEMO"."sap.hana.democontent.epm.data::EPM.Util.Texts" as E
           on A."NAMEID" = E."TEXTID"
           GROUP BY A."PRODUCTID",E."TEXT",C."COUNTRY",D."DELIVERYDATE"; 
    this is working fine but i want to split the grossamount based on current year and last year.Any idea how to do this
    In calculation view using script can we use if and case statements?

  • Unreachable statement error occured while using return statement.

    Consider this code
    class q25{
         public static void main(String args[]){
              amethod(args);
         public static void amethod(String args[]){
              String str;
              try{
                   str = "Hello "+args[0];
                   System.out.println(str);
                   System.out.println("Returning to caller");
                   System.exit(0);
              catch(Exception e){
                   System.out.println("Exception ocured");
                   System.exit(0);          
              finally{
                   System.out.println("In finally");
              System.out.println("At the end of method");     
    }Above code compiles and runs successfully without any errors.
    Now consider below code which is same as above one except "System.exit(0)" statements were replace by "return" statements. Below code when compiled gives error as
    "q25.java:22: unreachable statement
    System.out.println("At the end of method");
    ^
    1 error"
    One thing i didn't understood in this context that, the above code when compiled should get same error as stated above. But not. It is obvious that presence of System.exit(0) must generate unreachable statement same as when it is replaced by "return" statement. What is the difference in getting the error for above but not for below code. Pls anyone help.
    class q25{
         public static void main(String args[]){
              amethod(args);
         public static void amethod(String args[]){
              String str;
              try{
                   str = "Hello "+args[0];
                   System.out.println(str);
                   System.out.println("Returning to caller");
                   return;
              catch(Exception e){
                   System.out.println("Exception ocured");
                   return;     
              finally{
                   System.out.println("In finally");
              System.out.println("At the end of method");     
    }

    warnerja wrote:
    masijade. wrote:
    Since you have a "return" in both the try and the catch portions of the try/catch block *(the second of which you should never do)* , anything thing that comes after the try/catch/finally blocks will be unreachable.That is not true. There are plenty of reasons to return from a catch block. If you handle the exception instead of rethrowing it or another exception, then you'll need a return somehow, either there or after the catch block. What you should never do is "return" in a finally block, because that will mask any exception in flight about to be thrown to the caller.Perhaps masijade's use of never is too strong, but I too prefer/tend to avoid using return anywhere in try/catch/finally to avoid potential gotchas. Consider:
    public class TryCatchFinally
      public Data process(String s)
        Data returnData = new Data();
        try
          returnData.value = Integer.parseInt(s);
          returnData.message = "Success";
          return returnData;
        catch (Exception ex)
          returnData.value = -1;
          returnData.message = "Fail";
          return returnData;
        finally
          returnData.value = 42;
          returnData.message = "?";
      public static void main(String[] args)
        TryCatchFinally demo = new TryCatchFinally();
        Data d = demo.process("2");
        System.out.println(d.message + ": " + d.value);
        d = demo.process("2.1");
        System.out.println(d.message + ": " + d.value);
      class Data
        int value = 0;
        String message = "";
    }

  • Issue while using Collect statement in program

    Hi friend's,
    i have some issue regarding Collect statement..
    Issue is somthing like this,i have created a structure and internal table and work area with same type,
    u can look in below code..i wann to collect 'enmng' f'ield value whose matnr,charg,mvt type ,aufnr,rsnum are same but rspos and lgort are differnt for this i need to collect 'ENMNG' field value can any one tel me what to do...it not collectng value instead of this it append entire row...
    types: begin of ty_resb,
            rsnum   type resb-rsnum,                "Resrvation Number
            rspos   type resb-rspos,                "item position
            xloek   type resb-xloek,                "Item Deleted  if = 'X'
            matnr   type resb-matnr,                "Material Number
            lgort   type resb-lgort,                "Storage location  'REJT'
            charg   type resb-charg,                "Batch No
            enmng   type resb-enmng,                "Quantity withdrawn should be greater then '0'
            enwrt   type resb-enwrt,                "Value Withdrawn
            aufnr   type resb-aufnr,                "Order
            bwart   type resb-bwart,                "Movement type
       end of ty_resb.
    data:tt_resb  type table of  ty_resb ,
          tt_resb1 type table of ty_resb ,
          tt_resb2 type standard table of ty_resb ,
    **workarea.
          ts_resb type ty_resb,
          ts_resb2 type ty_resb,
          ts_resb1 type ty_resb.
    **move data to another internal table
    tt_resb1[] = tt_resb[].
    sort tt_resb  by rsnum rspos matnr charg bwart lgort aufnr .
    sort tt_resb1 by rsnum rspos matnr charg bwart lgort aufnr.
    DELETE adjacent duplicates from tt_resb  comparing rsnum rspos matnr charg bwart lgort aufnr .
    DELETE adjacent duplicates from tt_resb1 comparing rsnum rspos matnr charg bwart lgort aufnr.
    loop at tt_resb into ts_resb .
    clear:ts_resb1,ts_resb2.
    read table tt_resb1 into ts_resb1 with key rsnum = ts_resb-rsnum rspos = ts_resb-rspos matnr = ts_resb-matnr
                                                charg = ts_resb-charg aufnr = ts_resb-aufnr binary search.
    if ts_resb1-bwart = '261' .
        move ts_resb1-aufnr to ts_resb2-aufnr.
        move ts_resb1-matnr to ts_resb2-matnr.
        move ts_resb1-charg to ts_resb2-charg.
        move ts_resb1-bwart to ts_resb2-bwart.
        move ts_resb1-enwrt to ts_resb2-enwrt.
        move ts_resb1-lgort to ts_resb2-lgort.
        move ts_resb1-enmng to ts_resb2-enmng.
        collect ts_resb2 into tt_resb2.
    endif.
    clear ts_resb.
    endloop.
    Regard's,
    shaikh khalid.

    Hi Shaikh,
    I have added new declarations as highlighted below and new lines within your loop:
    Execute your program in debug mode and see what happens to the internal tt_collect I added. The collect will sum the fields enmng for all entries that  have same value on the fields matnr,charg,mvt type ,aufnr,rsnum.
    Question from me: what do you want to do with the collected/Summed up entries?
    types: begin of ty_resb,
            rsnum   type resb-rsnum,                "Resrvation Number
            rspos   type resb-rspos,                "item position
            xloek   type resb-xloek,                "Item Deleted  if = 'X'
            matnr   type resb-matnr,                "Material Number
            lgort   type resb-lgort,                "Storage location  'REJT'
            charg   type resb-charg,                "Batch No
            enmng   type resb-enmng,                "Quantity withdrawn should be greater then '0'
            enwrt   type resb-enwrt,                "Value Withdrawn
            aufnr   type resb-aufnr,                "Order
            bwart   type resb-bwart,                "Movement type
       end of ty_resb.
    data:tt_resb  type table of  ty_resb ,
          tt_resb1 type table of ty_resb ,
          tt_resb2 type standard table of ty_resb ,
    types: begin of ty_collect,
      rsnum   type resb-rsnum,
      matnr   type resb-matnr,
      charg   type resb-charg,
      bwart   type resb-bwart,
      aufnr   type resb-aufnr, 
      enmng   type resb-enmng,
           end of ty_collect.
    data: tt_collect type table of ty_collect,
          ts_collect type ty_collect.
    **workarea.
          ts_resb type ty_resb,
          ts_resb2 type ty_resb,
          ts_resb1 type ty_resb.
    **move data to another internal table
    tt_resb1[] = tt_resb[].
    sort tt_resb  by rsnum rspos matnr charg bwart lgort aufnr .
    sort tt_resb1 by rsnum rspos matnr charg bwart lgort aufnr.
    DELETE adjacent duplicates from tt_resb  comparing rsnum rspos matnr charg bwart lgort aufnr .
    DELETE adjacent duplicates from tt_resb1 comparing rsnum rspos matnr charg bwart lgort aufnr.
    loop at tt_resb into ts_resb .
    clear:ts_resb1,ts_resb2.
    read table tt_resb1 into ts_resb1 with key rsnum = ts_resb-rsnum rspos = ts_resb-rspos matnr = ts_resb-matnr
                                                charg = ts_resb-charg aufnr = ts_resb-aufnr binary search.
    if ts_resb1-bwart = '261' .
        move ts_resb1-aufnr to ts_resb2-aufnr.
        move ts_resb1-matnr to ts_resb2-matnr.
        move ts_resb1-charg to ts_resb2-charg.
        move ts_resb1-bwart to ts_resb2-bwart.
        move ts_resb1-enwrt to ts_resb2-enwrt.
        move ts_resb1-lgort to ts_resb2-lgort.
        move ts_resb1-enmng to ts_resb2-enmng.
        collect ts_resb2 into tt_resb2.
         move-corresponding ts_resb1 to ts_collect.
         collect ts_collect into tt_collect
    endif.
    clear ts_resb.
    clear ts_collect.
    endloop.

  • How to pass select-options in key while using Read Statement.

    Hi SAP gurus,
    I was using a select stmt. with were clause of Select-options it was working fine,
    now my scenerio is changed i need to read an internal table
    with key of select-options....
    how to read internal table with key S_MATNR (Select-options).

    Hi,
    We can certainly do this.
    We need to loop the internal table with select-options condition.
    Example  :
    LOOP AT ITAB WHERE FIELD =  S_FIELD.
    ENDLOOP.
    This should solve your problem.
    Plz reward if useful.
    Thanks,
    Dhanashri.

  • Insert using select statement

    Hi,
    I am trying to insert values using select statement. But this is not working
    INSERT INTO contribution_temp_upgrade
    (PRO_ID,
    OBJECT_NAME,
    DELIVERY_DATE,
    MODULE_NAME,
    INDUSTRY_CATERGORIZATION,
    ADVANTAGES,
    REUSE_DETAILS)
    VALUES
    SELECT
    :P1_PROJECTS,
    wwv_flow.g_f08(vRow),
    wwv_flow.g_f09(vRow),
    wwv_flow.g_f10(vRow),
    wwv_flow.g_f11(vRow),
    wwv_flow.g_f12(vRow),
    wwv_flow.g_f13(vRow)
    FROM DUAL;
    Please let me know what i am missing..
    Thanks
    Sudhir

    Try this
    INSERT INTO contribution_temp_upgrade
    (PRO_ID,
    OBJECT_NAME,
    DELIVERY_DATE,
    MODULE_NAME,
    INDUSTRY_CATERGORIZATION,
    ADVANTAGES,
    REUSE_DETAILS)
    SELECT
    :P1_PROJECTS,
    wwv_flow.g_f08(vRow),
    wwv_flow.g_f09(vRow),
    wwv_flow.g_f10(vRow),
    wwv_flow.g_f11(vRow),
    wwv_flow.g_f12(vRow),
    wwv_flow.g_f13(vRow)
    FROM DUAL;Note: when you are selecting a value using select statement, you should not specify the keyword "values".
    i assume you have already assigned value for your bind variable :P1_PROJECTS and rest of the functions will return some value.
    Regards,
    Prazy

  • 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

  • How to format body message while using SO_DOCUMENT_SEND_API1?

    hi,
               i am having some data in internal table that i want to format as text message and mail through SO_DOCUMENT_SEND_API1 function module but not as a attachement. i am using contents in body message. but i am not able to do formating , is there any way ?
    internal table:
    claimid  claimdate    expensetype amount
    0001     01.06.2008  FUMD          20000
    0002     02.06.2008  SUND              500
    0003     05.06.2008  ENTM             1500
    i want to print this in message body part and send it throgh mail, while using write statement , it takes lot time.
    plz suggest me.
    Saurin Shah

    Hi
    Take a table as mentioned below.
    GT_OBJTXT LIKE SOLISTI1
           OCCURS 0 WITH HEADER LINE,      " Mail Text options
    and populate the data that you want to print as body in this table line by line.
    Formating/allignment only can be done while populating the table.  U have to check the mail and keep adjusting the allignment.
    And after populating send the table to one table parameter in funciton module that is...
                CONTENTS_TXT               = LT_OBJTXT.
    This will populate the mail body.
    <REMOVED BY MODERATOR>
    Venkat.
    Edited by: Alvaro Tejada Galindo on Jun 12, 2008 2:17 PM

  • Using Decode in where clause in free hand sql

    Hi,
        I want to use decode in free hand sql.
    for eg : this is a where condition
    Outlet_Lookup.City  =  @variable('Enter City')
    Requirement :
    if we put the user prompt as "Enter City and % for all cities"
    and the user enters % then the data display should be all cities or else it shld be the specific city entered in the prmpt..
    Can we do that using Decode statement,
    I have tried
    Outlet_Lookup.City  =  Decode(@variable('Enter City'),'%',Outlet_Lookup.City,(@variable('Enter City')))
    This is not working....
    Pls guide on the same..
    Thanks.

    Hi Mathieu,
            Thanks for the solution,
    I tried the following
    ((Outlet_Lookup.City  =  @variable('Enter City or % for All') or @variable('Enter City or % for All')='%'))
    This is working fine....
    Thanks
    Regards,
    Aparna.

  • 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

  • Decode Statement Inside the Case statement

    Can we use Decode Statement inside a CASE Statement as show below --
    It is giving an error -- Is the a better way to write with out any error
    create or replace
    function test (a varchar2) RETURN VARCHAR2
    is
    m varchar2(20);
    begin
    m :=
    CASE
    WHEN a IN (
    '1009' -- (soon obsolete)
    ,'1010'
    ,'1019'
    ,'1051'
    ,'XGP'
    ,'XSC')
    THEN (SELECT DECODE(v_lef_cd,'NAM','71','GLB','99','01') into m FROM DUAL)
    -- ) THEN '01' -- UNITED STATES OF AMERICA
    WHEN a IN (
    '1069' -- South Africa
    ,'SAO' -- South Africa
    ,'SA' -- South Africa
    ) THEN '26' -- South Africa
    ELSE NULL
    END;
    return m;
    end;

    Hi,
    You can only use DECODE in SQL statements.
    Your SELECT DECODE (...) INTO statement would work anywhere a PL/SQL statement is allowed; but PL/SQL statements are not allowed within CASE expressions.
    Remember, the expression that comes after THEN in a CASE expression must be a single value.
    I would write a function like this using IF ... ELSIF statements. It's a little more typing than CASE, but a lot easier to code, test and maintain.
    If you want to use CASE, here's one way:
    ...     m := CASE
              WHEN  a  IN ('1069', 'SAO', 'SA')
                   THEN  '26'     -- South Africa
              WHEN  a  NOT IN ('1009', '1019', '1051', 'XGP', 'XSC')
              OR    a  IS NULL
                   THEN  NULL
              WHEN  v_lef_cd = 'NAM'
                   THEN  '71'
              WHEN  v_lef_cd = 'GLB'
                   THEN  '99'
                   ELSE  '01'     -- USA
              END;This assumes that you have a variable v_lef_cd defined.
    If you want, you can nest CASE expressions, like this:
    ...     m := CASE
              WHEN  a  IN ('1069', 'SAO', 'SA')
                   THEN  '26'     -- South Africa
              WHEN  a  IN ('1009', '1019', '1051', 'XGP', 'XSC')
                   THEN  CASE  v_lef_cd
                          WHEN  'NAM'
                             THEN  '71'
                          WHEN  'GLB'
                             THEN  '99'
                             ELSE  '01'     -- USA
                         END
              END;Always format your code, so you can see where the CASE expressions and each of the WHEN clauses begin and end.
    When posting formatted text on this site, type these 6 characters:
    (all small letters, inside curly brackets) before and after sections of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Insert with Select while Using Merge

    Actual Query
    MERGE INTO schema1.employees D
       USING (SELECT employee_id, salary, department_id FROM schema2.employees
       WHERE department_id = 80) S
       ON (D.employee_id = S.employee_id)
       WHEN MATCHED THEN
       UPDATE
       SET D.bonus = D.bonus + S.salary*.01
       WHERE (S.salary > 8000)
       WHEN NOT MATCHED THEN INSERT (D.employee_id, D.bonus)
       VALUES (S.employee_id, S.salary*.01)
       WHERE (S.salary <= 8000) Is there a possible way to write a select Query in Insert Statement while using Merge.
      WHEN NOT MATCHED THEN
       INSERT
       SELECT * FROM schema2.employees
       WHERE S.salary <= 8000;

    it works:
    MERGE INTO fifapps.tes2
    using dual
    on (1=2)
    when not matched then insert values(59,'yes');
    commit;or
    MERGE INTO fifapps.tes2
    using dual
    on (1=2)
    when not matched then insert values ((select 99 from dual),(select'weii' from dual));
    commit;Edited by: ʃʃp on Jun 13, 2012 2:03 AM
    Edited by: ʃʃp on Jun 13, 2012 2:03 AM

Maybe you are looking for