Dyanamic Where with IN Clause

Hi,
I have written the following query
SELECT (list) FROM (t_condtables-tabname)
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
FOR ALL ENTRIES IN itab_kschl
WHERE kschl = itab_kschl-kschl AND
(lt_table).
when I passing the dyanamic where clause as folows
lt_table means ( KAPPL = ' V ' and vkorg in s_vkorg and kschl in s_kschl )
I am getting the error in "IN" clause , Please suggest how to pass "IN" clause in the above senario as the sap understand IN clause as Fieldname in (o1,o2,o3) like but I have to pass as select option (Select options I have already declared)
thanks

Hi Bobby,
Try and use the following code.
SELECT (list) FROM (t_condtables-tabname)
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>
FOR ALL ENTRIES IN itab_kschl
WHERE kschl = itab_kschl-kschl
      AND KAPPL = ' V '
      AND vkorg IN s_vkorg
      AND kschl in s_kschl.
Regards,
Subhrangsu

Similar Messages

  • Default where with order by clause

    Hi all
    How to use Default where with order by clause
    for example i want to use Default_where clause with order by clause
    Regards
    Shahzaib ismail

    Hi,
    I have a similar query for where clause.
    my query-find form is a multi record form like below:
    Criteria - Condition - Value
    Item/Category/Planner (List_Item) - Equals/Among (List_Item) - text_FIELD
    Item - Equals - ITEM_1
    Category - Among - ('CAT1', 'CAT2')
    Planner - Equals - PL1
    Find_BUTTON Clear_BUTTON
    User can select any criteria and condition combination and then enter the value in "Value" text field.
    My query is: how can I prepare a where clause based on user input since the user can enter any number of values/combinations? I guess I would have to use some looping to generate where clause.
    Thanks
    Imran

  • Using bind variable with IN clause

    My application runs a limited number of straight up queries (no stored procs) using ODP.NET. For the most part, I'm able to use bind variables to help with query caching, etc... but I'm at a loss as to how to use bind variables with IN clauses. Basically, I'm looking for something like this:
    int objectId = 123;
    string[] listOfValues = { "a", "b", "c"};
    OracleCommand command = new OracleCommand();
    command.Connection = conn;
    command.BindByName = true;
    command.CommandText = @"select blah from mytable where objectId = :objectId and somevalue in (:listOfValues)";
    command.Parameters.Add("objectId", objectId);
    command.Parameters.Add("listOfValues", listOfValues);
    I haven't had much luck yet using an array as a bind variable. Do I need to pass it in as a PL/SQL associative array? Cast the values to a TABLE?
    Thanks,
    Nick

    Nevermind, found this
    How to use OracleParameter whith the IN Operator of select statement
    which contained this, which is a brilliant solution
    http://oradim.blogspot.com/2007/12/dynamically-creating-variable-in-list.html

  • SQL statement with union clause

    Hi,
    I have a scenario where i need to generate a sql statement with UNION .
    Eg:
    SELECT B.YY_ID,
    FROM XXXX.YY B
    WHERE (B.YY_TY= 'as')
    UNION
    SELECT B.YY_ID
    FROM XXXX.YY_ALT_NAME A, XXXX.YY B
    WHERE (A.YY_TY= 'zx'
    AND (B.YY_ID=A.YY_ID)"
    I tried ns1:table1() union ns3:table2() in XQuery.
    But it is pushdown as 2 seperate sqls.
    Is it possible to create XQuery that pushdown as SINGLE SQL statement with union clause ?
    Thanks

    No. See 3.1.1.5 in the document I referenced in your previous post.

  • ORA-22816: unsupported feature with RETURNING clause

    My database is: 10g 10.2.0.3.0
    Sorry this is a little long but I need some help!
    The insert is being done in PLSQL with SQL.
    I am trying to Insert a row into a view the view has 3 Instead of triggers. (insert, update, delete)
    I have looked up this error and have seen that you cannot use a RETURNING clause on view with INSTEAD OF triggers
    because it is not supported?
    My issue is, I cannot find any code around this view where a RETURNING clause is being used.
    Does anyone have any idea what else this could be??
    1. The trigger populates old and new values based on wether it is an insert update or delete,
    and then calls a procedure to do the insert, update or delete.
    2. Then calls another procedure that builds an XML string to pass into oracle queueing.
    They are all new triggers and procedures I have written.
    I searched for "RETURNING" in all other dependent objects for this view and could not find anything.
    Thats why I was wondering if it could be anything else?
    Another FYI. This whole procedure is actually on some other tables as well. It works fine with no issue on the tables.
    It wasn't until I started testing the VIEW that I started getting this error.
    I commented out the procedure calls and I still have an issue. I disabled the trigger and the issue went away.
    Another FYI to make it more interesting, The instead of update and the instead of delete triggers on this view
    work just fine with the package calls and everything. They are written exactly as the instead of insert trigger.
    It is only the instead of insert trigger that it is getting this error.
    Can someone help??? See Instead of Insert trigger below.
    {CREATE OR REPLACE TRIGGER TRIIBTF97A
    INSTEAD OF INSERT ON RTI_BUS_TA_FORM97A_VW
    FOR EACH ROW
    DECLARE
      old_rec        RTI_BUS_TA_FORM97A_VW%ROWTYPE;
      new_rec        RTI_BUS_TA_FORM97A_VW%ROWTYPE;
      v_change_type  VARCHAR2(8);
      v_event_source VARCHAR2(20) := 'TRIIBTF97A';
    BEGIN
      -- only new values on inserts
      new_rec.DOC_LOC_NBR                                   := :new.DOC_LOC_NBR              ;
      new_rec.TRAN_ID                                       := :new.TRAN_ID                  ;
      new_rec.RPTD_ADJ_SUBTOT_AMT                           := :new.RPTD_ADJ_SUBTOT_AMT      ;
      new_rec.CALC_ADJ_SUBTOT_AMT                           := :new.CALC_ADJ_SUBTOT_AMT      ;
      new_rec.RPTD_ADJ_SUBTOT2_AMT                          := :new.RPTD_ADJ_SUBTOT2_AMT     ;
      new_rec.CALC_ADJ_SUBTOT2_AMT                          := :new.CALC_ADJ_SUBTOT2_AMT     ;
      new_rec.RPTD_AGI_PRENOL_AMT                           := :new.RPTD_AGI_PRENOL_AMT      ;
      new_rec.CALC_AGI_PRENOL_AMT                           := :new.CALC_AGI_PRENOL_AMT      ;
      new_rec.RPTD_BAL_DUE_AMT                              := :new.RPTD_BAL_DUE_AMT         ;
      new_rec.CALC_BAL_DUE_AMT                              := :new.CALC_BAL_DUE_AMT         ;
      new_rec.RPTD_CC_CRED_AMT                              := :new.RPTD_CC_CRED_AMT         ;
      new_rec.CALC_CC_CRED_AMT                              := :new.CALC_CC_CRED_AMT         ;
      new_rec.RPTD_CHAR_CONTRIB_AMT                         := :new.RPTD_CHAR_CONTRIB_AMT    ;
      new_rec.CALC_CHAR_CONTRIB_AMT                         := :new.CALC_CHAR_CONTRIB_AMT    ;
      new_rec.RPTD_DIV_DEDUC_AMT                            := :new.RPTD_DIV_DEDUC_AMT       ;
      new_rec.CALC_DIV_DEDUC_AMT                            := :new.CALC_DIV_DEDUC_AMT       ;
      new_rec.RPTD_EST_PMT_AMT                              := :new.RPTD_EST_PMT_AMT         ;
      new_rec.CALC_EST_PMT_AMT                              := :new.CALC_EST_PMT_AMT         ;
      new_rec.RPTD_EZ_EMP_CRED_AMT                          := :new.RPTD_EZ_EMP_CRED_AMT     ;
      new_rec.CALC_EZ_EMP_CRED_AMT                          := :new.CALC_EZ_EMP_CRED_AMT     ;
      new_rec.RPTD_FED_INCM_AMT                             := :new.RPTD_FED_INCM_AMT        ;
      new_rec.CALC_FED_INCM_AMT                             := :new.CALC_FED_INCM_AMT        ;
      new_rec.RPTD_FRGN_GROSS_UP_AMT                        := :new.RPTD_FRGN_GROSS_UP_AMT   ;
      new_rec.CALC_FRGN_GROSS_UP_AMT                        := :new.CALC_FRGN_GROSS_UP_AMT   ;
      new_rec.RPTD_LREPT_AMT                                := :new.RPTD_LREPT_AMT           ;
      new_rec.CALC_LREPT_AMT                                := :new.CALC_LREPT_AMT           ;
      new_rec.RPTD_HRSJT_AMT                                := :new.RPTD_HRSJT_AMT           ;
      new_rec.CALC_HRSJT_AMT                                := :new.CALC_HRSJT_AMT           ;
      new_rec.RPTD_RELST_TAX_AMT                            := :new.RPTD_RELST_TAX_AMT       ;
      new_rec.CALC_RELST_TAX_AMT                            := :new.CALC_RELST_TAX_AMT       ;
      new_rec.RPTD_GOVT_INT_AMT                             := :new.RPTD_GOVT_INT_AMT        ;
      new_rec.CALC_GOVT_INT_AMT                             := :new.CALC_GOVT_INT_AMT        ;
      new_rec.RPTD_IN_AGI1_AMT                              := :new.RPTD_IN_AGI1_AMT         ;
      new_rec.CALC_IN_AGI1_AMT                              := :new.CALC_IN_AGI1_AMT         ;
      new_rec.RPTD_LRSJT_AMT                                := :new.RPTD_LRSJT_AMT           ;
      new_rec.CALC_LRSJT_AMT                                := :new.CALC_LRSJT_AMT           ;
      new_rec.RPTD_IN_NOL_AMT                               := :new.RPTD_IN_NOL_AMT          ;
      new_rec.CALC_IN_NOL_AMT                               := :new.CALC_IN_NOL_AMT          ;
      new_rec.RPTD_INCM_SUBTOT_AMT                          := :new.RPTD_INCM_SUBTOT_AMT     ;
      new_rec.CALC_INCM_SUBTOT_AMT                          := :new.CALC_INCM_SUBTOT_AMT     ;
      new_rec.RPTD_INT_DUE_AMT                              := :new.RPTD_INT_DUE_AMT         ;
      new_rec.CALC_INT_DUE_AMT                              := :new.CALC_INT_DUE_AMT         ;
      new_rec.RPTD_IRECV_CRED_AMT                           := :new.RPTD_IRECV_CRED_AMT      ;
      new_rec.CALC_IRECV_CRED_AMT                           := :new.CALC_IRECV_CRED_AMT      ;
      new_rec.RPTD_LATE_PEN_AMT                             := :new.RPTD_LATE_PEN_AMT        ;
      new_rec.CALC_LATE_PEN_AMT                             := :new.CALC_LATE_PEN_AMT        ;
      new_rec.RPTD_LIC_CRED_AMT                             := :new.RPTD_LIC_CRED_AMT        ;
      new_rec.CALC_LIC_CRED_AMT                             := :new.CALC_LIC_CRED_AMT        ;
      new_rec.RPTD_MODIF_AMT                                := :new.RPTD_MODIF_AMT           ;
      new_rec.CALC_MODIF_AMT                                := :new.CALC_MODIF_AMT           ;
      new_rec.RPTD_NAC_CRED_AMT                             := :new.RPTD_NAC_CRED_AMT        ;
      new_rec.CALC_NAC_CRED_AMT                             := :new.CALC_NAC_CRED_AMT        ;
      new_rec.RPTD_NONBUS_DISTA_AMT                         := :new.RPTD_NONBUS_DISTA_AMT    ;
      new_rec.CALC_NONBUS_DISTA_AMT                         := :new.CALC_NONBUS_DISTA_AMT    ;
      new_rec.RPTD_LTOT_AMT                                 := :new.RPTD_LTOT_AMT            ;
      new_rec.CALC_LTOT_AMT                                 := :new.CALC_LTOT_AMT            ;
      new_rec.RPTD_OTH_ADJ_AMT                              := :new.RPTD_OTH_ADJ_AMT         ;
      new_rec.CALC_OTH_ADJ_AMT                              := :new.CALC_OTH_ADJ_AMT         ;
      new_rec.RPTD_OTH_CRED_AMT                             := :new.RPTD_OTH_CRED_AMT        ;
      new_rec.CALC_OTH_CRED_AMT                             := :new.CALC_OTH_CRED_AMT        ;
      new_rec.RPTD_OTH_PMT_AMT                              := :new.RPTD_OTH_PMT_AMT         ;
      new_rec.CALC_OTH_PMT_AMT                              := :new.CALC_OTH_PMT_AMT         ;
      new_rec.RPTD_OVERPMT_CRED_AMT                         := :new.RPTD_OVERPMT_CRED_AMT    ;
      new_rec.CALC_OVERPMT_CRED_AMT                         := :new.CALC_OVERPMT_CRED_AMT    ;
      new_rec.RPTD_PRIOR_EXT_PMT_AMT                        := :new.RPTD_PRIOR_EXT_PMT_AMT   ;
      new_rec.CALC_PRIOR_EXT_PMT_AMT                        := :new.CALC_PRIOR_EXT_PMT_AMT   ;
      new_rec.RPTD_HRNTX_AMT                                := :new.RPTD_HRNTX_AMT           ;
      new_rec.CALC_HRNTX_AMT                                := :new.CALC_HRNTX_AMT           ;
      new_rec.RPTD_LRNTX_AMT                                := :new.RPTD_LRNTX_AMT           ;
      new_rec.CALC_LRNTX_AMT                                := :new.CALC_LRNTX_AMT           ;
      new_rec.RPTD_REFUND_DUE_AMT                           := :new.RPTD_REFUND_DUE_AMT      ;
      new_rec.CALC_REFUND_DUE_AMT                           := :new.CALC_REFUND_DUE_AMT      ;
      new_rec.RPTD_RELST_PP_TAX_AMT                         := :new.RPTD_RELST_PP_TAX_AMT    ;
      new_rec.CALC_RELST_PP_TAX_AMT                         := :new.CALC_RELST_PP_TAX_AMT    ;
      new_rec.RPTD_STATE_TAX_AMT                            := :new.RPTD_STATE_TAX_AMT       ;
      new_rec.CALC_STATE_TAX_AMT                            := :new.CALC_STATE_TAX_AMT       ;
      new_rec.RPTD_SU_TAX_AMT                               := :new.RPTD_SU_TAX_AMT          ;
      new_rec.CALC_SU_TAX_AMT                               := :new.CALC_SU_TAX_AMT          ;
      new_rec.RPTD_HREPT_AMT                                := :new.RPTD_HREPT_AMT           ;
      new_rec.CALC_HREPT_AMT                                := :new.CALC_HREPT_AMT           ;
      new_rec.RPTD_SUPP_NI_TAX1_AMT                         := :new.RPTD_SUPP_NI_TAX1_AMT    ;
      new_rec.CALC_SUPP_NI_TAX1_AMT                         := :new.CALC_SUPP_NI_TAX1_AMT    ;
      new_rec.RPTD_TAX_BUS_INC_AMT                          := :new.RPTD_TAX_BUS_INC_AMT     ;
      new_rec.CALC_TAX_BUS_INC_AMT                          := :new.CALC_TAX_BUS_INC_AMT     ;
      new_rec.RPTD_TOT_REL_TAX_AMT                          := :new.RPTD_TOT_REL_TAX_AMT     ;
      new_rec.CALC_TOT_REL_TAX_AMT                          := :new.CALC_TOT_REL_TAX_AMT     ;
      new_rec.RPTD_TAX_SUBTOT_AMT                           := :new.RPTD_TAX_SUBTOT_AMT      ;
      new_rec.CALC_TAX_SUBTOT_AMT                           := :new.CALC_TAX_SUBTOT_AMT      ;
      new_rec.RPTD_TCSP_CRED_AMT                            := :new.RPTD_TCSP_CRED_AMT       ;
      new_rec.CALC_TCSP_CRED_AMT                            := :new.CALC_TCSP_CRED_AMT       ;
      new_rec.RPTD_TOT_CRED_AMT                             := :new.RPTD_TOT_CRED_AMT        ;
      new_rec.CALC_TOT_CRED_AMT                             := :new.CALC_TOT_CRED_AMT        ;
      new_rec.RPTD_TOT_DUE_AMT                              := :new.RPTD_TOT_DUE_AMT         ;
      new_rec.CALC_TOT_DUE_AMT                              := :new.CALC_TOT_DUE_AMT         ;
      new_rec.RPTD_TOT_OVERPMT_AMT                          := :new.RPTD_TOT_OVERPMT_AMT     ;
      new_rec.CALC_TOT_OVERPMT_AMT                          := :new.CALC_TOT_OVERPMT_AMT     ;
      new_rec.RPTD_TOT_PMT_AMT                              := :new.RPTD_TOT_PMT_AMT         ;
      new_rec.CALC_TOT_PMT_AMT                              := :new.CALC_TOT_PMT_AMT         ;
      new_rec.RPTD_HTOT_AMT                                 := :new.RPTD_HTOT_AMT            ;
      new_rec.CALC_HTOT_AMT                                 := :new.CALC_HTOT_AMT            ;
      new_rec.RPTD_TAX_DUE_AMT                              := :new.RPTD_TAX_DUE_AMT         ;
      new_rec.CALC_TAX_DUE_AMT                              := :new.CALC_TAX_DUE_AMT         ;
      new_rec.RPTD_TAX_DUE2_AMT                             := :new.RPTD_TAX_DUE2_AMT        ;
      new_rec.CALC_TAX_DUE2_AMT                             := :new.CALC_TAX_DUE2_AMT        ;
      new_rec.RPTD_UNDERPMT_PEN_AMT                         := :new.RPTD_UNDERPMT_PEN_AMT    ;
      new_rec.CALC_UNDERPMT_PEN_AMT                         := :new.CALC_UNDERPMT_PEN_AMT    ;
      new_rec.RFND_1_INT_RATE                               := :new.RFND_1_INT_RATE          ;
      new_rec.RFND_1_AMT                                    := :new.RFND_1_AMT               ;
      new_rec.RFND_2_INT_RATE                               := :new.RFND_2_INT_RATE          ;
      new_rec.RFND_2_AMT                                    := :new.RFND_2_AMT               ;
      new_rec.RFND_3_INT_RATE                               := :new.RFND_3_INT_RATE          ;
      new_rec.RFND_3_AMT                                    := :new.RFND_3_AMT               ;
      new_rec.RFND_4_INT_RATE                               := :new.RFND_4_INT_RATE          ;
      new_rec.RFND_4_AMT                                    := :new.RFND_4_AMT               ;
      new_rec.RPTD_HRAMT_AMT                                := :new.RPTD_HRAMT_AMT           ;
      new_rec.CALC_HRAMT_AMT                                := :new.CALC_HRAMT_AMT           ;
      new_rec.RPTD_LRAMT_AMT                                := :new.RPTD_LRAMT_AMT           ;
      new_rec.CALC_LRAMT_AMT                                := :new.CALC_LRAMT_AMT           ;
      new_rec.RPTD_CMBTX_AMT                                := :new.RPTD_CMBTX_AMT           ;
      new_rec.CALC_CMBTX_AMT                                := :new.CALC_CMBTX_AMT           ;
      new_rec.RPTD_HRSUB_AMT                                := :new.RPTD_HRSUB_AMT           ;
      new_rec.CALC_HRSUB_AMT                                := :new.CALC_HRSUB_AMT           ;
      new_rec.RPTD_LRSUB_AMT                                := :new.RPTD_LRSUB_AMT           ;
      new_rec.CALC_LRSUB_AMT                                := :new.CALC_LRSUB_AMT           ;
      new_rec.RPTD_FUEL_CRED_AMT                            := :new.RPTD_FUEL_CRED_AMT       ;
      new_rec.CALC_FUEL_CRED_AMT                            := :new.CALC_FUEL_CRED_AMT       ;
      new_rec.RPTD_ADJUST_AMT                               := :new.RPTD_ADJUST_AMT          ;
      new_rec.CALC_ADJUST_AMT                               := :new.CALC_ADJUST_AMT          ;
      new_rec.RPTD_CARRY_YR_NBR                             := :new.RPTD_CARRY_YR_NBR        ;
      new_rec.CALC_CARRY_YR_NBR                             := :new.CALC_CARRY_YR_NBR        ;
      new_rec.RPTD_APPORT_PCNT                              := :new.RPTD_APPORT_PCNT         ;
      new_rec.CALC_APPORT_PCNT                              := :new.CALC_APPORT_PCNT         ;
      new_rec.RPTD_IN_APPORT_AMT                            := :new.RPTD_IN_APPORT_AMT       ;
      new_rec.CALC_IN_APPORT_AMT                            := :new.CALC_IN_APPORT_AMT       ;
      new_rec.RPTD_AGI_TAX_AMT                              := :new.RPTD_AGI_TAX_AMT         ;
      new_rec.CALC_AGI_TAX_AMT                              := :new.CALC_AGI_TAX_AMT         ;
      new_rec.RPTD_NONBUS_DISTB_AMT                         := :new.RPTD_NONBUS_DISTB_AMT    ;
      new_rec.CALC_NONBUS_DISTB_AMT                         := :new.CALC_NONBUS_DISTB_AMT    ;
      new_rec.RPTD_TOT_INC_AMT                              := :new.RPTD_TOT_INC_AMT         ;
      new_rec.CALC_TOT_INC_AMT                              := :new.CALC_TOT_INC_AMT         ;
      new_rec.REMIT_AMT                                     := :new.REMIT_AMT                ;
      new_rec.RFND_1_DT                                     := :new.RFND_1_DT                ;
      new_rec.PPIS_NAME                                     := :new.PPIS_NAME                ;
      new_rec.RFND_2_DT                                     := :new.RFND_2_DT                ;
      new_rec.EXT_FILED_INDC                                := :new.EXT_FILED_INDC           ;
      new_rec.RFND_3_DT                                     := :new.RFND_3_DT                ;
      new_rec.INIT_RET_INDC                                 := :new.INIT_RET_INDC            ;
      new_rec.RFND_4_DT                                     := :new.RFND_4_DT                ;
      new_rec.FINAL_RET_INDC                                := :new.FINAL_RET_INDC           ;
      new_rec.INT_PD_TO_DT                                  := :new.INT_PD_TO_DT             ;
      new_rec.UNITARY_COMB_INDC                             := :new.UNITARY_COMB_INDC        ;
      new_rec.PPIS_ST_3_ADDR                                := :new.PPIS_ST_3_ADDR           ;
      new_rec.PPIS_ST_1_ADDR                                := :new.PPIS_ST_1_ADDR           ;
      new_rec.PPIS_CHK_BOX                                  := :new.PPIS_CHK_BOX             ;
      new_rec.PPIS_PHN_NMBR                                 := :new.PPIS_PHN_NMBR            ;
      new_rec.INTERNAL_ID                                   := :new.INTERNAL_ID              ;
      new_rec.PPIS_ST_2_ADDR                                := :new.PPIS_ST_2_ADDR           ;
      new_rec.PPIS_CTRY_CD                                  := :new.PPIS_CTRY_CD             ;
      new_rec.PPIS_CTY_ADDR                                 := :new.PPIS_CTY_ADDR            ;
      new_rec.PPIS_CTRY_OLD                                 := :new.PPIS_CTRY_OLD            ;
      new_rec.PPIS_STATE_CD                                 := :new.PPIS_STATE_CD            ;
      new_rec.EXT_ATT_INDC                                  := :new.EXT_ATT_INDC             ;
      new_rec.PPIS_ZIP                                      := :new.PPIS_ZIP                 ;
      new_rec.SCORP_INDC                                    := :new.SCORP_INDC               ;
      new_rec.PPIS_ID                                       := :new.PPIS_ID                  ;
      new_rec.PPIS_ID_TP_CD                                 := :new.PPIS_ID_TP_CD            ;
      new_rec.APPORT_METHOD_CD                              := :new.APPORT_METHOD_CD         ;
      new_rec.INS_CO_INDC                                   := :new.INS_CO_INDC              ;
      new_rec.PER_BEGIN_DT                                  := :new.PER_BEGIN_DT             ;
      new_rec.PER_END_DT                                    := :new.PER_END_DT               ;
      new_rec.FORM_DT                                       := :new.FORM_DT                  ;
      new_rec.FORM_TYPE_ID                                  := :new.FORM_TYPE_ID             ;
      new_rec.NOL_CARRYBACK_CD                              := :new.NOL_CARRYBACK_CD         ;
      new_rec.FARM_COOP_INDC                                := :new.FARM_COOP_INDC           ;
      new_rec.ADD_DT                                        := :new.ADD_DT                   ;
      new_rec.ADD_ID                                        := :new.ADD_ID                   ;
      new_rec.UPD_DT                                        := :new.UPD_DT                   ;
      new_rec.UPD_ID                                        := :new.UPD_ID                   ;
      new_rec.VENDOR_CD                                     := :new.VENDOR_CD                ;
      new_rec.RPTD_HLTHINSASN_CR_AMT                        := :new.RPTD_HLTHINSASN_CR_AMT   ;
      new_rec.CALC_HLTHINSASN_CR_AMT                        := :new.CALC_HLTHINSASN_CR_AMT   ;
      new_rec.RPTD_GIT_FINAL_AMT                            := :new.RPTD_GIT_FINAL_AMT       ;
      new_rec.CALC_GIT_FINAL_AMT                            := :new.CALC_GIT_FINAL_AMT       ;
      new_rec.FISCAL_YR_CD                                  := :new.FISCAL_YR_CD             ;
      new_rec.RPTD_BONUS_DEPR_AMT                           := :new.RPTD_BONUS_DEPR_AMT      ;
      new_rec.CALC_BONUS_DEPR_AMT                           := :new.CALC_BONUS_DEPR_AMT      ;
      new_rec.RPTD_PREV_CRYFWD_AMT                          := :new.RPTD_PREV_CRYFWD_AMT     ;
      new_rec.CALC_PREV_CRYFWD_AMT                          := :new.CALC_PREV_CRYFWD_AMT     ;
      new_rec.RPTD_DOM_PROD_DED_AMT                         := :new.RPTD_DOM_PROD_DED_AMT    ;
      new_rec.CALC_DOM_PROD_DED_AMT                         := :new.CALC_DOM_PROD_DED_AMT    ;
      new_rec.RPTD_XS_IRC_DED_AMT                           := :new.RPTD_XS_IRC_DED_AMT      ;
      new_rec.CALC_XS_IRC_DED_AMT                           := :new.CALC_XS_IRC_DED_AMT      ;
      new_rec.RPTD_COAL_CR_AMT                              := :new.RPTD_COAL_CR_AMT         ;
      new_rec.CALC_COAL_CR_AMT                              := :new.CALC_COAL_CR_AMT         ;
      new_rec.SCHD_M_INDC                                   := :new.SCHD_M_INDC              ;
      new_rec.INTANG_EXP_INDC                               := :new.INTANG_EXP_INDC          ;
      new_rec.RPTD_INTANGEXP_ADJ_AMT                        := :new.RPTD_INTANGEXP_ADJ_AMT   ;
      new_rec.CALC_INTANGEXP_ADJ_AMT                        := :new.CALC_INTANGEXP_ADJ_AMT   ;
      new_rec.AGIT_CONSOL_INDC                              := :new.AGIT_CONSOL_INDC         ;
      new_rec.INCRP_DT                                      := :new.INCRP_DT                 ;
      new_rec.INCRP_STATE_CD                                := :new.INCRP_STATE_CD           ;
      new_rec.COMMERCIAL_ST_CD                              := :new.COMMERCIAL_ST_CD         ;
      new_rec.INIT_IN_RTN_YR                                := :new.INIT_IN_RTN_YR           ;
      new_rec.REC_LOC_ADDR                                  := :new.REC_LOC_ADDR             ;
      new_rec.EST_TAX_OTH_FID_INDC                          := :new.EST_TAX_OTH_FID_INDC     ;
      new_rec.FED_1120_CONSOL_INDC                          := :new.FED_1120_CONSOL_INDC     ;
      new_rec.UNTRY_MTRL_CHG_INDC                           := :new.UNTRY_MTRL_CHG_INDC      ;
      new_rec.FED_ELEC_CONF_NBRV                            := :new.FED_ELEC_CONF_NBRV       ;
      new_rec.RTN_SRC_CD                                    := :new.RTN_SRC_CD               ;
      new_rec.BANKRPT_INDC                                  := :new.BANKRPT_INDC             ;
      new_rec.FIT_FILER_INDC                                := :new.FIT_FILER_INDC           ;
      new_rec.NAME_CHG_INDC                                 := :new.NAME_CHG_INDC            ;
      new_rec.REMIC_INDC                                    := :new.REMIC_INDC               ;
      new_rec.INPUT_SRC_METH_CD                             := :new.INPUT_SRC_METH_CD        ;
      new_rec.ANNULZN_INDC                                  := :new.ANNULZN_INDC             ;
      new_rec.RPTD_REIT_DIV_DED_AMT                         := :new.RPTD_REIT_DIV_DED_AMT    ;
      new_rec.CALC_REIT_DIV_DED_AMT                         := :new.CALC_REIT_DIV_DED_AMT    ;
      new_rec.RPTD_PAT_INCM_AMT                             := :new.RPTD_PAT_INCM_AMT        ;
      new_rec.CALC_PAT_INCM_AMT                             := :new.CALC_PAT_INCM_AMT        ;
      new_rec.RPTD_MDA_PROD_CR_AMT                          := :new.RPTD_MDA_PROD_CR_AMT     ;
      new_rec.CALC_MDA_PROD_CR_AMT                          := :new.CALC_MDA_PROD_CR_AMT     ; 
      IF inserting THEN                                              
        v_change_type := 'INSERT';                                   
      ELSIF updating THEN                                            
        v_change_type := 'UPDATE';                                   
      ELSIF deleting THEN                                            
        v_change_type := 'DELETE';
      END IF;
      --call to do base table insert, update or delete          
        RSDGP004.bus_ta_form_97A(in_event_user      => user,
                                 in_event_source    => v_event_source,
                                 in_change_type     => v_change_type,
                                 in_old_rec         => old_rec,
                                 in_new_rec         => new_rec);
      -- call to build xml for rti_table_audits and queues        --xdbaud
        RSDGP001.bus_ta_form_97A(in_event_user      => user,
                                 in_event_source    => v_event_source,
                                 in_change_type     => v_change_type,
                                 in_old_rec         => old_rec,
                                 in_new_rec         => new_rec);
    END;}
    Edited by: SDL on Feb 17, 2009 4:54 AM
    Edited by: SDL on Feb 17, 2009 5:09 AM
    Edited by: SDL on Feb 17, 2009 5:14 AM

    Here is the insert code that is in the package RSDGP004 that does the insert into the base table for the view.
    I think maybe this is what you meant, when you asked for the code that does the insert?
    {ELSIF in_change_type = 'INSERT' THEN
                levent := 'INSERT';
                INSERT INTO rti_bus_ta_forms(
                                               add_dt         
                                            ,  add_id         
                                            ,  tran_id        
                                            ,  doc_loc_nbr    
                                            ,  field_009_amt  
                                            ,  field_01_txt   
                                            ,  field_010_amt  
                                            ,  field_015_amt  
                                            ,  field_016_amt  
                                            ,  field_02_txt   
                                            ,  field_029_amt  
                                            ,  field_03_txt   
                                            ,  field_030_amt  
                                            ,  field_039_amt  
                                            ,  field_04_txt   
                                            ,  field_040_amt  
                                            ,  field_041_amt  
                                            ,  field_042_amt  
                                            ,  field_05_txt   
                                            ,  field_053_amt  
                                            ,  field_054_amt  
                                            ,  field_06_txt   
                                            ,  field_063_amt  
                                            ,  field_064_amt  
                                            ,  field_067_amt  
                                            ,  field_068_amt  
                                            ,  field_07_txt   
                                            ,  field_079_amt  
                                            ,  field_08_txt   
                                            ,  field_080_amt  
                                            ,  field_085_amt  
                                            ,  field_086_amt  
                                            ,  field_09_txt   
                                            ,  field_091_amt  
                                            ,  field_092_amt  
                                            ,  field_095_amt  
                                            ,  field_096_amt  
                                            ,  field_10_txt   
                                            ,  field_101_amt  
                                            ,  field_102_amt  
                                            ,  field_103_amt  
                                            ,  field_104_amt  
                                            ,  field_105_amt  
                                            ,  field_106_amt  
                                            ,  field_11_txt   
                                            ,  field_111_amt  
                                            ,  field_112_amt  
                                            ,  field_12_txt   
                                            ,  field_125_amt  
                                            ,  field_126_amt  
                                            ,  field_127_amt  
                                            ,  field_128_amt  
                                            ,  field_13_txt   
                                            ,  field_131_amt  
                                            ,  field_132_amt  
                                            ,  field_137_amt  
                                            ,  field_138_amt  
                                            ,  field_139_amt  
                                            ,  field_14_txt   
                                            ,  field_140_amt  
                                            ,  field_141_amt  
                                            ,  field_142_amt  
                                            ,  field_143_amt  
                                            ,  field_144_amt  
                                            ,  field_147_amt  
                                            ,  field_148_amt  
                                            ,  field_149_amt  
                                            ,  field_15_txt   
                                            ,  field_150_amt  
                                            ,  field_151_amt  
                                            ,  field_152_amt  
                                            ,  field_153_amt  
                                            ,  field_154_amt  
                                            ,  field_16_txt   
                                            ,  field_165_amt  
                                            ,  field_166_amt  
                                            ,  field_167_amt  
                                            ,  field_168_amt  
                                            ,  field_169_amt  
                                            ,  field_170_amt  
                                            ,  field_171_amt  
                                            ,  field_172_amt  
                                            ,  field_181_amt  
                                            ,  field_182_amt  
                                            ,  field_175_amt  
                                            ,  field_176_amt  
                                            ,  field_177_amt  
                                            ,  field_178_amt  
                                            ,  field_179_amt  
                                            ,  field_180_amt  
                                            ,  field_193_amt  
                                            ,  field_194_amt  
                                            ,  field_195_amt  
                                            ,  field_196_amt  
                                            ,  field_197_amt  
                                            ,  field_198_amt  
                                            ,  field_199_amt  
                                            ,  per_begin_dt   
                                            ,  per_end_dt     
                                            ,  form_dt        
                                            ,  form_type_id   
                                            ,  field_31_txt   
                                            ,  field_201_amt  
                                            ,  upd_dt         
                                            ,  upd_id         
                                            ,  field_27_txt   
                                            ,  field_006_amt  
                                            ,  field_007_amt  
                                            ,  field_008_amt  
                                            ,  field_005_amt  
                                            ,  field_21_txt   
                                            ,  field_22_txt   
                                            ,  field_23_txt   
                                            ,  field_020_amt  
                                            ,  field_021_amt  
                                            ,  field_022_amt  
                                            ,  field_023_amt  
                                            ,  field_024_amt  
                                            ,  field_025_amt  
                                            ,  field_026_amt  
                                            ,  field_027_amt  
                                            ,  field_028_amt  
                                            ,  field_031_amt  
                                            ,  field_183_amt  
                                            ,  field_184_amt  
                                            ,  field_034_amt  
                                            ,  field_035_amt  
                                            ,  field_036_amt  
                                            ,  field_191_amt  
                                            ,  field_192_amt  
                                            ,  field_188_amt  
                                            ,  field_189_amt  
                                            ,  field_17_txt   
                                            , field_18_txt    
                                            , field_33_txt    
                                            , field_19_txt    
                                            , field_39_txt    
                                            , field_20_txt    
                                            ,  field_185_amt  
                                            ,  field_186_amt  
                                            , field_24_txt   )
                                     VALUES(
                                            in_new_rec.ADD_DT,                       
                                            in_new_rec.ADD_ID,                       
                                            in_new_rec.TRAN_ID,                      
                                            in_new_rec.DOC_LOC_NBR,                  
                                            in_new_rec.RPTD_BAL_DUE_AMT,             
                                            in_new_rec.EXT_ATT_INDC,                 
                                            in_new_rec.CALC_BAL_DUE_AMT,             
                                            in_new_rec.RPTD_REL_TAX_AMT,             
                                            in_new_rec.CALC_REL_TAX_AMT,             
                                            in_new_rec.EXT_FILED_INDC,               
                                            in_new_rec.RPTD_EST_PMT_AMT,             
                                            in_new_rec.PPIS_CTRY_CD,                 
                                            in_new_rec.CALC_EST_PMT_AMT,             
                                            in_new_rec.RPTD_HRAMT_AMT,               
                                            in_new_rec.PPIS_ST_3_ADDR,               
                                            in_new_rec.CALC_HRAMT_AMT,               
                                            in_new_rec.RPTD_CMBTX_AMT,               
                                            in_new_rec.CALC_CMBTX_AMT,               
                                            in_new_rec.INTERNAL_ID,                  
                                            in_new_rec.RPTD_LTOT_AMT,                
                                            in_new_rec.CALC_LTOT_AMT,                
                                            in_new_rec.PPIS_ID,                      
                                            in_new_rec.RPTD_INT_DUE_AMT,             
                                            in_new_rec.CALC_INT_DUE_AMT,             
                                            in_new_rec.RPTD_LATE_PEN_AMT,            
                                            in_new_rec.CALC_LATE_PEN_AMT,            
                                            in_new_rec.PPIS_ID_TP_CD,                
                                            in_new_rec.RPTD_HRNTX_AMT,               
                                            in_new_rec.PPIS_NAME,                    
                                            in_new_rec.CALC_HRNTX_AMT,               
                                            in_new_rec.RPTD_OTH_PMT_AMT,             
                                            in_new_rec.CALC_OTH_PMT_AMT,             
                                            in_new_rec.PPIS_ST_1_ADDR,               
                                            in_new_rec.RPTD_OVERPMT_CRED_AMT,        
                                            in_new_rec.CALC_OVERPMT_CRED_AMT,        
                                            in_new_rec.RPTD_PRIOR_EXT_PMT_AMT,       
                                            in_new_rec.CALC_PRIOR_EXT_PMT_AMT,       
                                            in_new_rec.PPIS_ST_2_ADDR,               
                                            in_new_rec.RPTD_HREPT_AMT,               
                                            in_new_rec.CALC_HREPT_AMT,               
                                            in_new_rec.RPTD_HRSUB_AMT,               
                                            in_new_rec.CALC_HRSUB_AMT,               
                                            in_new_rec.RPTD_REFUND_DUE_AMT,          
                                            in_new_rec.CALC_REFUND_DUE_AMT,          
                                            in_new_rec.PPIS_CTY_ADDR,                
                                            in_new_rec.RPTD_RENT_AMT,                
                                            in_new_rec.CALC_RENT_AMT,                
                                            in_new_rec.PPIS_STATE_CD,                
                                            in_new_rec.RPTD_SU_TAX_AMT,              
                                            in_new_rec.CALC_SU_TAX_AMT,              
                                            in_new_rec.RPTD_HRSJT_AMT,               
                                            in_new_rec.CALC_HRSJT_AMT,               
                                            in_new_rec.PPIS_ZIP,                     
                                            in_new_rec.RPTD_SUPP_NI_TAX1_AMT,        
                                            in_new_rec.CALC_SUPP_NI_TAX1_AMT,        
                                            in_new_rec.RPTD_TAX_DUE_AMT,             
                                            in_new_rec.CALC_TAX_DUE_AMT,             
                                            in_new_rec.RPTD_TOT_DUE_AMT,             
                                            in_new_rec.PPIS_PHN_NMBR,                
                                            in_new_rec.CALC_TOT_DUE_AMT,             
                                            in_new_rec.RPTD_TOT_OVERPMT_AMT,         
                                            in_new_rec.CALC_TOT_OVERPMT_AMT,         
                                            in_new_rec.RPTD_TOT_PMT_AMT,             
                                            in_new_rec.CALC_TOT_PMT_AMT,             
                                            in_new_rec.RPTD_TOT_REL_TAX_AMT,         
                                            in_new_rec.CALC_TOT_REL_TAX_AMT,         
                                            in_new_rec.RPTD_UNDERPMT_PEN_AMT,        
                                            in_new_rec.PPIS_CHK_BOX,                 
                                            in_new_rec.CALC_UNDERPMT_PEN_AMT,        
                                            in_new_rec.RPTD_HTOT_AMT,                
                                            in_new_rec.CALC_HTOT_AMT,                
                                            in_new_rec.RPTD_HRBAL_AMT,               
                                            in_new_rec.CALC_HRBAL_AMT,               
                                            in_new_rec.PPIS_CTRY_OLD,                
                                            in_new_rec.RPTD_LRNTX_AMT,               
                                            in_new_rec.CALC_LRNTX_AMT,               
                                            in_new_rec.RPTD_LRBAL_AMT,               
                                            in_new_rec.CALC_LRBAL_AMT,               
                                            in_new_rec.RPTD_LREPT_AMT,               
                                            in_new_rec.CALC_LREPT_AMT,               
                                            in_new_rec.RPTD_LRSUB_AMT,               
                                            in_new_rec.CALC_LRSUB_AMT,               
                                            in_new_rec.RPTD_LRSJT_AMT,               
                                            in_new_rec.CALC_LRSJT_AMT,               
                                            in_new_rec.RPTD_LRAMT_AMT,               
                                            in_new_rec.CALC_LRAMT_AMT,               
                                            in_new_rec.RPTD_AGI_TAX_AMT,             
                                            in_new_rec.CALC_AGI_TAX_AMT,             
                                            in_new_rec.RPTD_TOT_UNREL_TAX_AMT,       
                                            in_new_rec.CALC_TOT_UNREL_TAX_AMT,       
                                            in_new_rec.RPTD_GI_TAX_AMT,              
                                            in_new_rec.CALC_GI_TAX_AMT,              
                                            in_new_rec.RPTD_TAX_DUE2_AMT,            
                                            in_new_rec.CALC_TAX_DUE2_AMT,            
                                            in_new_rec.RPTD_TOT_URL_AMT,             
                                            in_new_rec.CALC_TOT_URL_AMT,             
                                            in_new_rec.REMIT_AMT,                    
                                            in_new_rec.PER_BEGIN_DT,                 
                                            in_new_rec.PER_END_DT,                   
                                            in_new_rec.FORM_DT,                      
                                            in_new_rec.FORM_TYPE_ID,                 
                                            in_new_rec.NOL_CARRYBACK_CD,             
                                            in_new_rec.CALC_IN_NOL_AMT,              
                                            in_new_rec.UPD_DT,
                                            in_new_rec.UPD_ID,               
                                            in_new_rec.VENDOR_CD,                    
                                            in_new_rec.RPTD_PREV_CRYFWD_AMT,         
                                            in_new_rec.CALC_PREV_CRYFWD_AMT,         
                                            in_new_rec.RPTD_TOT_CRED_AMT,            
                                            in_new_rec.CALC_TOT_CRED_AMT,            
                                            in_new_rec.FISCAL_YR_CD,                 
                                            in_new_rec.INIT_RET_INDC,                
                                            in_new_rec.FINAL_RET_INDC,               
                                            in_new_rec.RPTD_FED_INCM_AMT,            
                                            in_new_rec.CALC_FED_INCM_AMT,            
                                            in_new_rec.RPTD_BONUS_DEPR_AMT,          
                                            in_new_rec.CALC_BONUS_DEPR_AMT,          
                                            in_new_rec.RPTD_SPF_DEDUCT_AMT,          
                                            in_new_rec.CALC_SPF_DEDUCT_AMT,          
                                            in_new_rec.RPTD_GOVT_INT_AMT,            
                                            in_new_rec.CALC_GOVT_INT_AMT,            
                                            in_new_rec.RPTD_URL_SUBTOT_AMT,          
                                            in_new_rec.CALC_URL_SUBTOT_AMT,          
                                            in_new_rec.RPTD_APPORT_PCNT,             
                                            in_new_rec.CALC_APPORT_PCNT,             
                                            in_new_rec.RPTD_IN_INCM_AMT,             
                                            in_new_rec.CALC_IN_INCM_AMT,             
                                            in_new_rec.RPTD_IN_NOL_AMT,              
                                            in_new_rec.RPTD_TOT_URL_INCM_AMT,        
                                            in_new_rec.CALC_TOT_URL_INCM_AMT,        
                                            in_new_rec.RPTD_TOT_MOD_AMT,             
                                            in_new_rec.CALC_TOT_MOD_AMT,             
                                            in_new_rec.SCHD_M_INDC,                  
                                            in_new_rec.FED_ELEC_CONF_NBRV,           
                                            in_new_rec.RTN_SRC_CD,                   
                                            in_new_rec.BANKRPT_INDC,                 
                                            in_new_rec.NAME_CHG_INDC,                
                                            in_new_rec.INPUT_SRC_METH_CD,            
                                            in_new_rec.RPTD_PAT_INCM_AMT,            
                                            in_new_rec.CALC_PAT_INCM_AMT,            
                                            in_new_rec.ANNULZN_INDC) ;}

  • Outer join with BETWEEN clause

    Hi All,
    I have 2 tables (A and B) which i need to join. I need all records from table A and matching records from the table B. below is the structure.
    TABLE A (total rows = 10)
    ROW_WID
    GL_DATE
    LOCATION_CODE
    TABLE B (total = 7)
    ROW_WID
    START_DATE
    END_DATE
    LOCATION_CODE
    Initially, we were asked to join based on location_code. In the table B, some of the LOCATION_CODE are missing, which is present in table A.
    We wrote below query
    SELECT A.*, B.START_DATE, B.END_DATE
    FROM A, B
    WHERE A.LOCATION_CODE = B.LOCATION_CODE (+)
    This gives 10 records, where 3 records have START_DATE and END_DATE NULL. because of outer join
    It gave all records from the A table. It worked fine. Now i need to add one more condition where A.GL_DATE between B.START_DATE and B.END_DATE
    If i write this
    SELECT A.*, B.START_DATE, B.END_DATE
    FROM A, B
    WHERE A.LOCATION_CODE = B.LOCATION_CODE (+)
    AND A.GL_DATE BETWEEN B.START_DATE and B.END_DATE
    This gives me only 7 records. IS IT POSSIBLE TO ADD OUTER JOIN with BETWEEN clause.

    Hi All,
    I'm in a similar situation,
    I have a complex query, everything is working fine, except this part (I will simplify everything, removing other stuffs because I need help only on the following condition)
    SELECT *
    from transaction t, card c
    where c.card_id = t.card_id (+)
    and t.trn_date between to_date ('01/01/2012','dd/mm/yy') and ('01/01/2013,'dd/mm/yy')
    How could i OUTER JOIN the between condition?
    I tried with
    and t.trn_date between to_date ('01/01/2012','dd/mm/yy') (+) and ('01/01/2013','dd/mm/yy') (+)
    but returns a "missing expression" error.
    Surely I'm missing some stupid thing about it, could you help me on this? (probably because I'm talking about parameters and I cannot put the outer join on a value)
    How can I rewrite the condition in order to satisfy what I'm trying to accomplish?
    Thanks in Advance,
    Alex
    Edited by: 981667 on 14-gen-2013 4.23
    Edited by: 981667 on 14-gen-2013 4.24

  • Outer join on query with OR clause

    hi all, i am having problem outerjoining a query with or clause
    here is my data
    WITH table1 AS
    SELECT  'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    SELECT  null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual
    ,table2 AS
    SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL
      SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual
    SELECT b.pid, a.*
    from table1 a, table2 b
    WHERE (a.txt1 = b.txt1 OR
           a.txt1 IS NULL AND a.txt2=b.txt2 OR
           Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR
           Nvl(a.txt2, a.txt1) IS NULL  AND a.txt3 IS NULL AND a.txt4 = b.txt4
           ) as you can see i am joining table1 and table 2. i am joining with txt1, if txt1 is null then join by txt2, if null then join by txt3 and so on.
    the code above product this output
    PID     TXT1     TXT2     TXT3     TXT4
    ===     ====     ===   ==== ====
    111     test     pak      ced     su
    222             pak      ced2     su2
    333                     ced3     su3
    444                          su3this output is partially correct. only 4 rows were display and two was left out
    SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
    SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual i tried using outer join but oracle complain that i cannot use outerjoin with OR clause.
    can someone help modify my query to display the output below ?
    PID     TXT1     TXT2     TXT3     TXT4
    ===    ====      ===   ====  ====
    111     test     pak      ced     su
    222             pak      ced2     su2
    333                     ced3     su3
    444                          su3
    NULL  NULL   NULL    NULL   NULL
         test5

    Not sure you can do it with the Oracle style outer joins, but wioth ANSI style joins it is simple, actually exactly as you had it.
    SQL> set null null;
    SQL> WITH table1 AS (
      2   SELECT  'test' txt1, 'pak' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
      3   SELECT  null txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
      4   SELECT  null txt1, NULL txt2, 'ced3' txt3, 'su3' txt4 FROM dual UNION ALL
      5   SELECT  null txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
      6   SELECT  'text5' txt1, NULL txt2, null txt3, 'su3' txt4 FROM dual UNION ALL
      7   SELECT  null txt1, NULL txt2, null txt3, null txt4 FROM dual),
      8  table2 AS (
      9   SELECT 111 pid, 'test' txt1, 'pak4' txt2, 'ced' txt3, 'su' txt4 FROM dual UNION ALL
    10   SELECT 222 pid, 'test1' txt1, 'pak' txt2, 'ced2' txt3, 'su2' txt4 FROM dual UNION ALL
    11   SELECT 333 pid, 'test2' txt1, 'pak3' txt2, 'ced3' txt3, 'su4' txt4 FROM dual UNION ALL
    12   SELECT 444 pid, 'test2' txt1, 'pak3' txt2, 'ced4' txt3, 'su3' txt4 FROM dual)
    13  SELECT b.pid, a.*
    14  from table1 a
    15     LEFT JOIN table2 b
    16        ON (a.txt1 = b.txt1 OR
    17            a.txt1 IS NULL AND a.txt2=b.txt2 OR
    18            Nvl(a.txt2, a.txt1) IS NULL AND a.txt3 = b.txt3 OR
    19            Nvl(a.txt2, a.txt1) IS NULL  AND a.txt3 IS NULL AND a.txt4 = b.txt4);
           PID TXT1   TXT2   TXT3   TXT4
           111 test   pak    ced    su
           222 null   pak    ced2   su2
           333 null   null   ced3   su3
           444 null   null   null   su3
    null       text5  null   null   su3
    null       null   null   null   nullJohn

  • WITH AS Clause

    Hi all
    I am using 'with as' clause in RDF to build a dynamic query.
    I just want to know whether Report builder 6i supports this, if yes means how i shud use this as my RDF throws signal 11 error if i use it
    Comments on this from u r experience will be highly helpful
    Thanks in advance
    Sundar

    Hi All,
    I am using WITH Clause to achieve my reporting requirement.
    I am creating almost 15 Alias to achieve the calculation but the query is not working.
    As i am a beginner , i just want to know is there any limitation of  No of alias  table in "WITH clause"?
    My query is something like below:
    With BaseTable as (select
    dim.Desc    as    Desc,
    Dim.ID    as TabID,
    Fact.Amount as Amount,
    from Fact
    inner join Dim on dim.id=fact.id),
    Table2 as
    (Select   2 as TabID,
    'Desc' as Desc,
    (CASE WHEN (SUM(Tab1.Amount*0.1)-500)  as Amount
    from
    BaseTable Tab1
    where Tab1.TabID in (1,2,5,6)
    Table3 as
    (select  3 as TabID,
    'Desc' as Desc,
    (CASE WHEN (SUM(Tab1.Amount)-0.1*SUM(Tab2.Amount)) > 0 then (SUM(Tab1.Amount)-0.1*SUM(Tab2.Amount)) else 0 end) as Amount
    from
    BaseTable Tab1,
    Table2 Tab2
    where  Tab1.TabID=Tab2.TabID
    and Tab1.RepID in (8,10)
    select * from  BaseTable
    union
    select * from Table2
    union
    select * from Table3

  • Problem with IN clause substitution in Sybase

    I am experiencing a problem with IN clause substitution in
    embedded SQL with a Sybase databse.
    My Cold Fusion server is MX 7.
    The Database is Adaptive Server Enterprise/12.5.0.3/EBF 10689
    IR/P/Sun_svr4/OS 5.8/rel12503/1915/64-bit/FBO/Thu Jan 23 16:05:19
    2003
    Here's the problem. I have a Cold Fusion variable
    bureau_incode which I am using to define the values in my IN
    clause. When I comment out my query and display this value to the
    HTML page, bureau_incode has the following value:
    ('OET','OGC','OIG','OLA','OMD','OMR','OSP','OTHER','OWD','PSHSB','WCB','WTB')
    My embedded SQL CFQUERY looks like this:
    quote:
    <cfquery name="qResults" datasource="#request.dsn#">
    Select Name,
    bureau_code,
    Telephone,
    CellPhone,
    Pager,
    Email,
    Availability,
    Explanation,
    Password,
    Admin,
    last_login = convert(varchar(20),last_login,0)
    from PAMS where Availability = 'N'
    <cfif #request.seltype# IS NOT "ALL">
    and bureau_code IN #bureau_incode#
    </cfif>
    </cfquery>
    When the code runs, I get the error
    Error Executing Database Query. Incorrect syntax near 'OET'.
    There is no incorrect syntax. Is there any special way to
    submit the IN clause to ColdFusion MX 7? Previously, we were using
    ColdFusion 4.5 (I believe) server, and the code worked perfectly,
    albiet with double-quotes in the replacement string. Any help would
    be appreciated. This type of substitution worked nicely in the
    previous server version, I can't imagine why it would no longer
    work.

    No, I am not. The parentheses are part of the #bureau_incode#
    coldfusion variable. I've edited the first message to make this
    more clear. I have tried the query with the parentheses in the
    #bureau_incode# variable, and with the parentheses in the CFquery
    with (#bureau_incode#). The results are always the same.
    I will indeed try to help with other stuff in the future. :)
    Thanks for trying to help!

  • Create VO with IN clause

    I need make a VO with IN clause like:
    SELECT Evento.CEDULA,
           Evento.IDEVENTO,
           Evento.IDPROYECTO,
           Evento.DETALLE,
           Evento.TOTALHORASNORMAL,
           Evento.TOTALHORASEXTRA,
           Evento.TOTALHORASESPECIAL
    FROM EVENTO Evento
    WHERE Evento.CEDULA IN (:p_persona_cedula)
    ORDER BY Evento.FECHAEVENTO,Evento.HORAINICIAL,Evento.HORAFINAL,Evento.CEDULASee Line: WHERE Evento.CEDULA IN (:p_persona_cedula)
    what type of bind variable use? if p_persona_cedula is String, I can only put a value and I can't put multiple values in "IN" clause
    Can I use any Array, List or Collection as Bind Variable Type?? How I can do this??

    Thanks a lot
    TYPE
    CREATE OR REPLACE TYPE SENTRY.varchar2_table AS TABLE OF varchar2(2000);
    FUNCTION
    CREATE OR REPLACE FUNCTION SENTRY.in_varchar2_list (p_in_list  IN  VARCHAR2)
      RETURN varchar2_table
    AS
      l_tab   varchar2_table := varchar2_table();
      l_text  VARCHAR2(32767) := p_in_list || ',';
      l_idx   number;
    BEGIN
      LOOP
        l_idx := INSTR(l_text, ',');
        EXIT WHEN NVL(l_idx, 0) = 0;
        l_tab.extend;
        l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
        l_text := SUBSTR(l_text, l_idx + 1);
      END LOOP;
      RETURN l_tab;
    END;
    VO
    SELECT Evento.CEDULA,
           Evento.IDEVENTO,
           Evento.IDPROYECTO
    FROM EVENTO Evento
    WHERE Evento.CEDULA MEMBER OF CAST (IN_VARCHAR2_LIST (:p_persona_cedula) AS varchar2_table)
    ORDER BY Evento.FECHAEVENTO,Evento.HORAINICIAL,Evento.HORAFINAL,Evento.CEDULAWhere :p_persona_cedula is a String like "123,456,789"
    It's just what I needed
    Thanks again

  • Error with When Clause SQL Loader

    I´'m trying to use WHEN clause in a control file, I'm following the documentation but it doesn't work still.
    This is my control file:
    LOAD DATA
    CHARACTERSET UTF8
    INTO TABLE DM08_CONDICIONADA
    WHEN (STATUS_DESC='A')
    APPEND
    REENABLE DISABLED_CONSTRAINTS
    FIELDS
    TERMINATED BY '|'
    "ID_COND" POSITION (1) INTEGER EXTERNAL ,
    "DESC_COND" CHAR,
    "STATUS_DESC" CHAR
    I have the follow error:
    SQL*Loader-350: Syntax error at line 26.
    Expecting "(", found keyword append.
    APPEND
    ^
    I have tried with
    WHEN STATUS_DESC='A'
    but the error is the same. Do you have any ideas why is that?? I'm working with oracle 9i.
    Greetings
    Oscar

    with:
    LOAD DATA
    CHARACTERSET UTF8
    INTO TABLE DM08_CONDICIONADA
    APPEND
    WHEN STATUS_DESC='A' --->with (STATUS_DESC='A') neither
    REENABLE DISABLED_CONSTRAINTS
    FIELDSTERMINATED BY '|'
    I have:
    SQL*Loader-350: Syntax error at line 27.
    Expecting "(", found keyword reenable.
    REENABLE DISABLED_CONSTRAINTS
    With:
    LOAD DATA
    CHARACTERSET UTF8
    INTO TABLE DM08_CONDICIONADA
    APPEND
    REENABLE DISABLED_CONSTRAINTS
    WHEN (STATUS_DESC ='A')
    i have:
    SQL*Loader-403: Referenced column STATUS_DESC not present in table DM08_CONDICIONADA.
    I´m using the documentation...
    -->full_fieldname or pos_spec-->operator--> char_string or Blanks --->
    but it doesn't tell me where the when clause goes... i'm probing too with the forum information but i don't know what happens.
    Thanks Jens

  • Select query with UNION clause in database adapter

    Friends,
    I have got a SQL query with two UNION clause withing it. like
    select a,b,c
    from a
    union
    select a,b,c
    from b
    The schema generated is like below in sequence
    <element>a</element>
    <element>b</element>
    <element>c</element>
    <element>a</element>
    <element>b</element>
    <element>c</element>
    So, the columns from different select queries joined with UNION clause are all appeared in schema instead of the distinct columns.
    Is there any way around to solve this issue ? or will need to with DB function/procedure.

    I think I know what you are saying but your example doesn't make sense, your SQL should produce something like
    I had to change a, b, c with elementA, elementB, elementC as a and b are reserved html tags.
    <elementA>DateA</elementA>
    <elementB>DataB</elementB>
    <elementC>DataC</elementC>
    ...What is the result of the query when you run it in SQLPlus? Is it what you expect?
    cheers
    James

  • Which two statements are true about WHERE and HAVING clause ?

    Which two statements are true about WHERE and HAVING clause ?
    1. WHERE clause can be used to restict rows only
    2.HAVING clause can be used to restrict groups only
    3.HAVING clause can be used to restrict groups and rows
    Plz help me in dis ques...which two will be correct...i think its 1 and 2...but not sure.

    863180 wrote:
    Plz help me in dis ques...which two will be correct...i think its 1 and 2...but not sure.If you are not sure then you do not fully understand HAVING.
    SY.

  • Create Materialized View with Compress clause

    Hi,
    Oracle 9i R2 has an option to use compress clause while creating table, materialized view or etc. Just wanted some help on tips to be followed during creating a materilized view with compress clause and refresh the same.do i need to follow any special procedures ??? Any help greatly appreciated.
    Thanks,
    Chak.

    I read in the book that while inserting user /+append+/ otherwise table with compress will fail. I am doing materialized view refresh with fast mode and data will be inserted as per logs residing at master site.. while inserting into materialized view, do i have to setup specially since fast refresh is going to insert data into existing materialized view.
    Thanks,

  • Why does final cut x not recognize the sharp PN- K321 monitor ( European version ) as output video monitor and premiere it? Working with two cinema display and PN- K321 and I can not preview the output video at 4K for DisplayPort, whereas with premie

    Why does final cut x not recognize the sharp PN- K321 monitor ( European version ) as output video monitor, and premiere yes?
    Working with two cinema display and PN- K321 and I can not preview the output video at 4K by DisplayPort, whereas with premiere and after effects I have no problems

    Look, you can build an HD DVD with an SD movie, just as you can build an SD DVD with an HD movie. This is not a bug, it is most likely user error. Apple will not be addressing it.
    Just start over, and ensure you are building an SD DVD by bringing up the inspector for the disc (click on the background in the Graphical tab).
    Make sure SD DVD is selected:
    (If you do the same thing on your ill fated project, you'll see that HD DVD is selected)
    Build your DVD and you'll be fine.
    Patrick
    P.S. You will need to google HD DVD and Blu-Ray if you want to understand the difference between the formats. The reason that DVDSP included HD DVD was that its format was similar to SD DVD's. Blu-Ray is something else entirely.

Maybe you are looking for