PLSQL query

Oracle version 10.2.0.5
rules_table_temp
rule_id     queue_id     name     value
6     2     PRODUCT     ATM
6     2     CUSTOMER     BR
6     2     STATE     VA
rules_table     
rule_id     queue_id     name     value
4     1     PRODUCT     ATM
4     1     PRODUCT     ABC
4     1     PRODUCT     XYZ
4     1     STATE     AL
4     1     STATE     AZ
5     2     CUSTOMER     APPLE
5     2     CUSTOMER     AT&T
5     2     PRODUCT     ABC
5     2     STATE     VA
For every record in rules_table_temp , I need to check whether this record is already available in rules_table with same name and value. If not, then insert into rules_table else no insert.
For ex:
Name = product, value = ATM - is already available in rules_table .hence skip this record
Name=customer, value=BR – is not available. Hence insert into rules_table
Name =state, value=VA – is already available. Hence skip this record
the output should be as below
rules_table
rule_id     queue_id     name     value
4     1     PRODUCT     ATM
4     1     PRODUCT     ABC
4     1     PRODUCT     XYZ
4     1     STATE     AL
4     1     STATE     AZ
5     2     CUSTOMER     APPLE
5     2     CUSTOMER     AT&T
5     2     PRODUCT     ABC
5     2     STATE     VA
6     2     CUSTOMER     BR
Could you please suggest

your insert statements are not correct
and my query working fine ( just missed a brace at the end)
drop table rules_table;
drop table rules_table_temp;
CREATE TABLE "RULES_TABLE"
( "RULE_ID" NUMBER,
"QUEUE_ID" NUMBER,
"NAME" VARCHAR2(20 BYTE),
"VALUE" VARCHAR2(200 BYTE)
insert into rules_table values(4,1,'PRODUCT','ATM');
insert into rules_table values(4,1,'PRODUCT','ABC');
insert into rules_table values(4,1,'PRODUCT','XYZ');
insert into rules_table values(4,1,'STATE','AL');
insert into rules_table values(4,1,'STATE','AZ');
insert into rules_table values(5,2,'CUSTOMER','APPLE');
insert into rules_table values(5,2,'CUSTOMER','ATT');
insert into rules_table values(5,2,'PRODUCT','ABC');
insert into rules_table values(5,2,'STATE','VA');
create table rules_table_temp as select * from rules_table where 1=2;
insert into rules_table_temp values(6,2,'PRODUCT','ATM');
insert into rules_table_temp values(6,2,'CUSTOMER','BR');
insert into rules_table_temp values(6,2,'STATE','VA');
commit;
insert into rules_table (select * from rules_table_temp r
where not exists ( select * from rules_table where name= r.name and value= r.value));

Similar Messages

  • Need Plsql query

    hi
    I need oracle plsql query for this concept , which itemcode present in four month
    Eliminate less than 4 month itemcode
    Itemcode month id
    1000 144
    1000 148
    1000 152
    1000 156
    so on
    ---------- eliminate this types of items
    2000 144
    3000 148
    3000 156
    Note : please dont use Procedures

    785143 wrote:
    hi
    I need oracle plsql query for this concept , which itemcode present in four month
    Eliminate less than 4 month itemcode
    Itemcode month id
    1000 144
    1000 148
    1000 152
    1000 156
    so on
    ---------- eliminate this types of items
    2000 144
    3000 148
    3000 156
    Note : please dont use ProceduresAre you saying that the same itemcode has to be related to 4 (or more) different months?
    Here's one way to do that:
    WITH     got_cnt          AS
         SELECT     itemcode
         ,     month_id
         ,     COUNT (DISTINCT month_id) OVER (PARTITION BY  itemcode)     AS cnt
         FROM     table_x
    SELECT     itemcode
    ,     month_id
    FROM     got_cnt
    WHERE     cnt     >= 4
    ;If you mean something else (such as all the monthids have to be in a series, with a difference of 4 between successive monthids), then explain more clearly.

  • How to link a non-linkable query and a plsql query in the datamodel

    Hi,
    I am creating a matrix group....
    Where in I get my
    1) Column values from a non-linkable query - Period (Jan, Feb....)
    2) Row values from a plsql query (ref cursor). Group is also from this query
    3) Cross product is on the above two queries.
    4) Cell info comes from a plsql query (refcursor).
    I created a group link from the cross product group (3) to the cell info query (4)
    I prepared the layout and executed the report... I am getting redundant data....
    The reason being the (4) and (1) are not linked properly.
    From google, About non-linkable queries column.... I understood that to link two non-linkable queries, we need to create a group link and then add a where clause in the child query referring the parent query column.
    But my case is a non-linkable query (which is a parent ) and a plsql query which is the cell.
    Any help...?
    Thanks in advance.
    KK

    Hello Sam,
    >
    I was wondering if you could have any link or examples to show how to make a form with report and an insert form in the same page, these two forms are related to the same table. Our customer wants a user can add new row to the table in a form and see all of rows created by this user in a report, this report should provide edit link as well. the problem is: whenever I inserted a new row or edit a row or delete a row, and submitted, and return to this page, all of hidden items lost their values, so report is blank, and some display only items also lost their values. Could anyone give me suggestions?
    >
    This will help:
    http://www.grassroots-oracle.com/2011/09/apex-tutorial-form-report-sharing-same.html
    Hope it helps!
    Regards,
    Kiran

  • Simple - plsql query

    I am new to plsql and want to do following in plsql code:
    code start select max(col1) from table1;
    -- and save the max value in variable VAR1
    select COL1, case COL2 when VAR1 THEN 'VALUE ONE'
    ELSE 'VALUE ELSE'
    END
    from table1
    -- I want to see the o/p of second select on the screen
    code ends how can i write the above plsql code.

    No, its not working... see the below..
    create table test5 as select owner, object_name, subobject_name, object_type from all_objects;
    create unique index test5_i5 on test5 (owner, object_name, subobject_name, object_type);
    select * from test5 where owner like 'SCOTT' AND OBJECT_NAME LIKE 'EMP';
    INDEX RANGE SCAN| TEST5_I5 | 4 | 248 | 1 (0)| 00:00:01 |
    but when i use
    select * from test5 where UPPER(OWNER) LIKE 'SCOTT%' AND UPPER(OBJECT_NAME) LIKE 'EMP%';
    TABLE ACCESS FULL| TEST5 | 3 | 186 | 65 (5)| 00:00:01 |
    i know it goes to full scan, i want to know is there any other way to make index used .. without using functional based indx...
    the reason is user can search any one of the column data and data is mixed case in table columns and/or conditions specified in query..
    .. any help...
    not sure how to use 'NLS_SORT=BINARY_CI' on multicolumn index and enable index used in search operation.. ANY OTHER WAY OF DOING THIS...
    requirements is
    mixed (lower,upper) data stored in db columns and mixed case data searched, 5 columns specified in where condition, data may be provided in search conditon to one or two or to all 5 columns in mixed case... matching records need to be returned.. suggest a good way of doing this... thnx

  • Plsql query converts numeric value or currency(rupees) to English words

    Hi,
    I Need a plsql procedure/function query that converts numeric value or currency(rupees) to English words.
    Please help .that is very very important and urgent for me.
    Thanks in advance.
    Regards,
    Karthik T

    that is very very important and urgent for me. Then help yourself by looking on all over internet :
    http://www.google.nl/search?hl=nl&q=oracle+numeric+word&meta=
    Or by using the search feature against the forum :
    http://forums.oracle.com/forums/search.jspa?threadID=&q=%2Bnumber+%2Bword&objID=f75&dateRange=all&userID=&numResults=15
    That would be faster.
    Nicolas.

  • Exists clause in plsql query

    HI I see that by the use of exists clause while joining
    1) oralce provides a better execution plan ... and 2) it eliminates duplicates automatically
    but my question is how to access the columns of the inner tables in the select clause ?
    EG:
    select a.sno, b.course_name
    from a,b
    where a.cid=b.cid
    ----------------------in the below query How do i access b.course_name in the select clause? similarly even if it contains more tables nested, i should be able to access the column of the inner tables from the select clause . How to do this . hope i am clear
    select a.sno from a where exists ( select 1 from b where b.cid=a.cid)

    You cannot access columns from tables in an EXISTS (or NOT EXISTS) clause outside of that clause. You can only select data from tables (and other objects) that you are actually selecting from.
    Justin

  • Plsql query to find out the concurrent programs attaching a plsql package

    I want to find all the concurrent programs attaching a particular package. Please provide me with the appropriate query to get that.

    Hello,
    1- First thing: we are talking about a SQL query (and not a PL/SQL query).
    2- I would like to add an additional filter to the query of shazi as the query should show only PL/SQL packages
    SELECT
    fcp.CONCURRENT_PROGRAM_ID
    ,fcp.concurrent_program_name
    , fcpt.user_concurrent_program_name
    , DECODE(fe.execution_method_code
    , 'I', 'PL/SQL'
    ,'P', 'Reports'
    ,'C', 'SQL Loader'
    ,'Q', 'SQL Plus'
    ,'K', 'Java'
    ,'H', 'OS executable'
    ,'B' , 'Req. Set Stage'
    ) EXECUTION_METHOD
    ,UPPER(EXECUTION_FILE_NAME) PACKAGE_BODY
    from
    fnd_concurrent_programs_tl fcpt
    , fnd_executables fe
    ,fnd_concurrent_programs fcp
    where 1=1
    --and fcpt.concurrent_program_id = fcr.concurrent_program_id
    and fe.executable_id = fcp.executable_id
    and fcpt.concurrent_program_id = fcp.concurrent_program_id
    and fe.execution_method_code = 'I' /* here's the additional filter */
    --and fcpt.user_concurrent_program_name = :P_USER_CONC_PROGRAM_NAME
    --fcp.concurrent_program_name = :P_CONC_PROGRAM_NAME /* using this filter would use an index */
    Lalaina

  • ORA-00904 ON A PLSQL QUERY RETURNING SQL QUERY ( NOT ALWAYS )

    Running a classic report , we sometimes face the error :
    <pre>failed to parse SQL query:
    ORA-00904: : invalid identifier
    Even when using the same parameters, sometimes the report runs and some others we get the error.
    The report is called by a url from a different page
    f?p=&APP_ID.:500:&APP_SESSION.:FLOW_EXCEL_OUTPUT_R&P503_RUN_REGION_ID._el:NO::P500_RUN_RG,P500_RG11_FILTER1:1,&P503_FILTER1.
    THE EVNVIRONMENT IS THE FOLLOWING
    ORACLE DATABASE 11g      Enterprise Edition Release 11.2.0.2.0 -64bit
    Apex                     Application Express 4.1.0.00.32
    In the apex on the same workspace we have 2 copies of the same application having different schema.
    We did not face this problem in Oracle 10g

    hello,
    I send you the function. rs_check_limit .
    In one case when i tried to debug in order to understand the error, the function was not fired.
    FUNCTION rs_check_limit ( p_trade_date_from date
    , p_trade_date_to date, p_session_id number , p_user_id varchar2
    , p_pct_sum_prcp_cd number
    ,p_rs_list_exclude varchar2 default ' '
    return rs_check_limit_tb PIPELINED
    is
    v_data rs_check_limit_tp :=rs_check_limit_tp ( null, null,null, null,null, null,null, null,null, null );
    CURSOR exec_trades_prcp_cur (vc_risk_date_from date
    , vc_risk_date_to date
    , vc_rs_list_exclude varchar2
    is
    select PRCP_CD
    , clr_sys_cd
    , clr_acc_cd
    ,avg( exec_trades_value_mkt ) avg_exec_trades_prcp
    ,SUM( exec_trades_value_mkt ) sum_exec_trades_prcp
    from
    select trd_dt, PRCP_CD , clr_sys_cd
    , clr_acc_cd , sum ( exec_trades_value_mkt ) exec_trades_value_mkt
    from
    select lst_cmpt_dt trd_dt , PRCP_CD , clr_sys_cd
    , clr_acc_cd
    ,SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where 1=1
    and lst_cmpt_dt > vc_risk_date_from -1
    and lst_cmpt_dt <= vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by lst_cmpt_dt , PRCP_CD , clr_sys_cd
    , clr_acc_cd
    UNION ALL
    select trunc ( apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt,- 1) ) trd_dt , PRCP_CD , clr_sys_cd
    , clr_acc_cd, SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where trd_dt = apx_rs_risk_info.get_d_n_cur ( lst_cmpt_dt , 2 )
    and lst_cmpt_dt > apx_rs_risk_info.get_d_n_cur (vc_risk_date_from ,1 )-1
    and lst_cmpt_dt < vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt , -1 ) ,PRCP_CD , clr_sys_cd
    , clr_acc_cd
    group by trd_dt, PRCP_CD , clr_sys_cd
    , clr_acc_cd
    group by PRCP_CD , clr_sys_cd
    , clr_acc_cd
    CURSOR exec_trades_all_cur (vc_risk_date_from date
    , vc_risk_date_to date
    , vc_rs_list_exclude varchar2)
    is
    select SUM( exec_trades_value_mkt ) sum_exec_trades_all -- óõíïëéêÞ çìåñÞóéá áîßá óõíáëëáãùí áãïñÜò
    , avg( exec_trades_value_mkt ) avg_exec_trades_all
    from
    select trd_dt, sum( exec_trades_value_mkt ) exec_trades_value_mkt
    from
    --gia  T : T, T-1 ,  T-2
    select lst_cmpt_dt trd_dt , SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where 1=1
    and lst_cmpt_dt > vc_risk_date_from -1
    and lst_cmpt_dt <= vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by lst_cmpt_dt
    union all
    --gia  T EPIPLEON: T-3
    select apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt,-1) trd_dt , SUM (BUYS_VALUE+ SELLS_VALUE) exec_trades_value_mkt
    from rs_mm_rsk_lmts_dtls
    where trd_dt = apx_rs_risk_info.get_d_n_cur ( trunc ( lst_cmpt_dt ) , +2 )
    and lst_cmpt_dt > apx_rs_risk_info.get_d_n_cur (vc_risk_date_from ,1 )-1
    and lst_cmpt_dt < vc_risk_date_to
    and instr( vc_rs_list_exclude, TRIM(clr_acc_cd)|| '.')= 0
    group by apx_rs_risk_info.get_d_n_cur (lst_cmpt_dt , -1 )
    group by trd_dt
    exec_trades_prcp_row exec_trades_prcp_cur%rowtype;
    exec_trades_all_row exec_trades_all_cur%rowtype;
    i number := 0;
    tmp varchar2(4) := null;
    procedure feed_table is
    BEGIN
    v_data.prcp_cd := exec_trades_prcp_row.prcp_cd;
    v_data.clr_sys_cd := exec_trades_prcp_row.clr_sys_cd;
    v_data.clr_acc_cd := trim(exec_trades_prcp_row.clr_acc_cd);
    v_data.member_id := RS_GET_PRCP_MEMBER_ID(exec_trades_prcp_row.prcp_cd);
    v_data.member_dsc := RS_GET_PRCP_DSC(exec_trades_prcp_row.prcp_cd);
    v_data.sumTRADES_VALUE_PRCP_CD_T := round( exec_trades_prcp_row.sum_exec_trades_prcp,2);
    v_data.mkt_sumTRADES_VALUE_PRCP_CD_T := round( exec_trades_all_row.sum_exec_trades_all,2) ;
    v_data.avgTRADES_VALUE_PRCP_CD_T := round( exec_trades_prcp_row.avg_exec_trades_prcp,2);
    v_data.mkt_avgTRADES_VALUE_PRCP_CD_T := round( exec_trades_all_row.avg_exec_trades_all,2) ;
    v_data.pct_sum_prcp_cd := round( 100* exec_trades_prcp_row.sum_exec_trades_prcp
    / exec_trades_all_row.sum_exec_trades_all , 2);
    end ;
    begin
    exec_trades_all_row := null;
    open exec_trades_all_cur (vc_risk_date_from => p_trade_date_from
    , vc_risk_date_to => p_trade_date_to
    ,vc_rs_list_exclude => NVL(p_rs_list_exclude ,'.' )
    fetch exec_trades_all_cur INTO exec_trades_all_row;
    close exec_trades_all_cur;
    for exec_trades_prcp_rec in exec_trades_prcp_cur (vc_risk_date_from => p_trade_date_from
    , vc_risk_date_to => p_trade_date_to
    ,vc_rs_list_exclude => NVL(p_rs_list_exclude ,'.' )
    loop
    exec_trades_prcp_row := exec_trades_prcp_rec;
    if exec_trades_all_row.sum_exec_trades_all <> 0 then
    if 100* exec_trades_prcp_row.sum_exec_trades_prcp
    / exec_trades_all_row.sum_exec_trades_all >= p_pct_sum_prcp_cd then
    i := i+1;
    v_data :=rs_check_limit_tp ( null, null,null, null,null, null,null, null,null, null );
    feed_table;
    pipe row ( v_data );
    end if;
    end if;
    end loop;
    end;
    I send you the dll for the type
    CREATE OR REPLACE
    TYPE rs_check_limit_tp as object
    prcp_cd varchar2(10)
    , member_id varchar2(4)
    , member_dsc varchar2(120)
    , clr_sys_cd varchar2(4)
    , clr_acc_cd varchar2(6)
    , avgTRADES_VALUE_PRCP_CD_T number
    , mkt_avgTRADES_VALUE_PRCP_CD_T number
    , sumTRADES_VALUE_PRCP_CD_T number
    , mkt_sumTRADES_VALUE_PRCP_CD_T number
    , pct_sum_prcp_cd number
    and the table dll
    CREATE TABLE rs_mm_rsk_lmts_dtls
    (trd_dt DATE NOT NULL,
    prcp_cd VARCHAR2(10 BYTE) NOT NULL,
    clr_sys_cd CHAR(4 BYTE),
    clr_acc_cd CHAR(10 BYTE),
    sec_isin_cd VARCHAR2(12 BYTE) NOT NULL,
    buys NUMBER(19,0),
    sells NUMBER(19,0),
    buys_value NUMBER(19,6),
    sells_value NUMBER(19,6),
    abs_b_minus_s NUMBER(19,2),
    rsk_prc NUMBER(13,6),
    net_value NUMBER(19,2) NOT NULL,
    sr NUMBER(19,2) NOT NULL,
    mm NUMBER(19,2) NOT NULL,
    lst_cmpt_dt DATE,
    usr_id VARCHAR2(8 BYTE) NOT NULL,
    cmt VARCHAR2(64 BYTE),
    chg_dt DATE,
    gr_b NUMBER(19,2) NOT NULL,
    gr_s NUMBER(19,2) NOT NULL)
    Thank you
    Tonia

  • PLSQL Query modification

    Following query is returning the records as below:
    SELECT
      A.CHEQUE_CODE AS COL1, 
      A.ACC_ADD_REF AS COL2
    FROM CTSCHEQUEBOOK A, BRANCHES B, CTSCHEQUEBOOK_DESIGN C
    WHERE A.COMP_CODE = 1
    AND A.COMP_CODE = B.COMP_CODE
    AND A.BRANCH_CODE = B.BRANCH_CODE
    AND A.COMP_CODE = C.COMP_CODE
    AND A.CHEQUE_CODE = C.CODE
    ORDER BY 1
    COL1 COL2
    1     01616005034001
    1     01616005034001
    1     01616005128001
    2     01616005197001
    2     01616005197001
    3      01616005144001
    3     01616005144001
    3     01616005144001I want to display the records like only in column but group on COL1:
    1
    01616005034001
    01616005034001
    01616005128001
    2
    01616005197001
    01616005197001
    3
    01616005144001
    01616005144001
    01616005144001How can I do this with my query?

    I tried your query :
    WITH DATA AS
      (SELECT TO_CHAR(A.CHEQUE_CODE) AS COL1,
        A.ACC_ADD_REF       AS COL2
      FROM CTSCHEQUEBOOK A,
        BRANCHES B,
        CTSCHEQUEBOOK_DESIGN C
      WHERE A.COMP_CODE = 1
      AND A.COMP_CODE   = B.COMP_CODE
      AND A.BRANCH_CODE = B.BRANCH_CODE
      AND A.COMP_CODE   = C.COMP_CODE
      AND A.CHEQUE_CODE = C.CODE
      ORDER BY 1
    SELECT (
      CASE
        WHEN RN IS NULL
        THEN COL1
        ELSE COL2
      END) COL1
    FROM
      (SELECT ROWNUM RN,
        COL1,
        COL2,
        COUNT(COL2)
      FROM DATA
      GROUP BY CUBE(ROWNUM),
        COL1,
        COL2
      );But it is repeating values like following:
    1
    01616005034001
    01616005034001
    01616005034001
    01616005034001
    01616005034001
    1
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    01616005128001
    2
    01616005197001
    01616005197001
    3
    01616005089001
    3
    01616005144001
    01616005144001
    01616005144001

  • PlSql query required

    Hello All,
    I have one requirement like below. I've written a StoredProcedure which has i/p parameter as segment_id
    I have two tables T1 and T2
    T1--> line_id,ssection_id,cat_id
    T2--> parent_id,child_id, segment1,segment2,segment3
    parent_id is equivalent to ssection_id and child_id is equivalent to cat_id. I've made a inner join with thise condition.
    Now, what I need to achieve is, depending upon the segment_id i/p parameter i need to check teh data of table T2. for example say, segment_id is segment1 then i have to check the data in segment1 column and if it is N then I should fetch the line_id from table T1.
    SELECT lines.line_id
    BULK COLLECT INTO line_ids
    FROM T1 lines inner join T2 iv
    ON LINES.SSECTION_ID = iv.Parent_id
    AND lines.cat_id = iv.child_id
    WHERE
    Here I need to write the condition that I've explained above. Please forgive me if it is a lame question to ask as I'm very much new to Oracle world. Please let me know if you need any further information. Thanks in advance.
    Regards,
    Subhadeep

    I figured out the query, Thanks a lot for your help.
    AND 'N' = CASE i/pparameter segment
    WHEN 'segment1' THEN
    iv.segment1
    WHEN 'segment2' THEN
    iv.segment2
    WHEN 'segment3' THEN
    iv.segment3
    END ;
    the whole query looks like this.
    SELECT lines.line_id
    BULK COLLECT INTO line_ids
    FROM T1 lines , T2 iv
    WHERE lines.deal_site_id = p_deal_site_id -- i/p parameter
    AND LINES.SSECTION_ID = iv.Parent_id
    AND lines.cat_id = iv.child_id
    AND 'N' = CASE p_segment_id -- segment i/p parameter
    WHEN 'segment1' THEN
    iv.segment1
    WHEN 'segment2' THEN
    iv.segment2
    WHEN 'segment3' THEN
    iv.segment3
    END ;
    Hope it helps some one who is facing similar problem.
    Regards,
    Subhadeep

  • Plsql query to list cases that have failed to create listing records

    i would like to create a query as follows
    Give me all docket_num (whose batch_id's are =11051) from Import_case table
    which do not have listing records on Listing_Table (either they don't exist at all
    or if the do; the create_date in the Listing table is null OR cretae_date on Lsting table not = record_process_date on Import_case table.
    -------- x ---------------
    Import_case Table
    ==============
    1. import_case_id number(38) primary key
    2. batch_id number
    3. record_processed_date date
    4. docket_num varchar2(17)
    case_master Table
    =================
    1. case_master_id number(38) primary key
    2. docket_num varchar2(17)
    Listing Table
    ==========
    1. Listing_id number(38) primary key
    2. case_master_id number(38)
    3. created_date timestamp(6)
    note: case_master table is a link between Import_case Table and Listing table
    where docket_num on import_case table = docket_num on case_master
    and case_master_id on case_master = case_master_id on Listing Table
    Please reply at your earliest. Thanking you. Arvind Modi.

    I have used following query, which gives me list of docket numbers on Import case Table; which don't have Listing records on Listing Table.
    ========================================================
    select
    ic.import_case_id as "IMP_CASE_ID",
    ic.batch_id as "B_ID",
    ic.docket_num as "DOCKET#",
    ic.insert_timestamp as "INS_DT",
    ic.record_processed_timestamp as "REC_PROCESS_DT",
    ic.next_date as "NEXT DT"
    from daoimp.import_case ic
    -- ** insert Batch id ** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    where ic.batch_id=11051
    -- ** insert Batch id ** <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    minus
    select
    t.import_case_id as "IMP_CASE_ID",
    t.batch_id as "B_ID",
    t.docket_num as "DOCKET#",
    t.insert_timestamp as "INS_DT",
    t.record_processed_timestamp as "REC_PROCESS_DT",
    t.next_date as "NEXT DT"
    from daoimp.import_case t,
    case_master cm,
    listing l
    -- ** insert Batch id ** >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    where t.batch_id=11051
    -- ** insert Batch id ** <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    and
    t.docket_num = cm.docket_num
    and
    cm.case_master_id = l.case_master_id
    ==================================================
    The above query gives correct docket_numbers on Import_case table, but it also needs to include Docket numbers on Import_case Table
    whose Listing records in Listing table contain NULL value in created_date
    OR create_date on Listing table not equal record_process_date on Import_case Table.
    ---- x ----
    Here is the actual request and above is my interpretation of it.
    The goal of the task here is to create a tool. The tool can be run to check for missing listing records that were not created during the import process. When run, the tools returns a result set of records (docket_numbers) from the import case table that although processed on a particular date i.e., (record_process_date) do not have a matching listing record i.e., ( a listing record with a create_date equal to the record_process_date).
    The ONLY VARIABLE PARAMETER NEEDED in this tool is the Batch ID for the import case table.
    ---- x ---
    I am working on some other queries using inner join or outer join or not exists, but no success so far.
    Please call me at my phone number or reply on my e-mail, if you like; so that I can clarify any issues.

  • Plsql query please help out

    Hi ,
    I have table with columns
    item,product,class1,class2,item_path,category
    How can I query the table to find out
    same item_path with differnt categories.I want to update those rows.
    Thanks.

    If you're just trying to identify the paths with more than one category then something like...
    select item_path, count(category) cnt
    from mytable
    group by item_path
    having count(category) > 1may do it.

  • One SQL/PLSQL query out of several does not work

    I have a report with search filters and most of the search fields are text fields. I have no problem searching by these fields until i add in a select list to search by. Once i apply the select list filter(:P21_COUNTY), it displays the correct information but then all the text fields stop displaying the correct info. Does it work differently if using a select list vs. other field types? Thanks, Deanna
    There is a sample app on apex.oracle.com
    Workspace:DEANNA2
    Username:[email protected]
    Password:Dclipse03
    Page 21
    Login:[email protected]
    Password:Dclipse03

    Looks like a Application express Question
    Post it [Here | http://forums.oracle.com/forums/forum.jspa?forumID=137]
    SS

  • Generate Query in PLSQL to return Well Formed XML with Multiple records

    Hi there
    This is very urgent. I am trying to create a PLSQL query that should retrieve all records from oracle database table "tbl_Emp" in a well formed xml format. The format is given below
    *<Employees xmlns="http://App.Schemas.Employees" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">*
    *<Employee>*
    *<First_Name></First_Name>*
    *<Last_Name></Last_Name>*
    *</Employee>*
    *<Employee>*
    *<First_Name></First_Name>*
    *<Last_Name></Last_Name>*
    *</Employee>*
    *</Employees>*
    To retrieve data in above format, I have been trying to create a query for long time as below
    SELECT XMLElement("Employees",
    XMLAttributes('http://App.Schemas.Employees' AS "xmlns",
    *'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"),*
    XMLElement("Employee", XMLForest(First_Name, Last_Name)))
    AS "RESULT"
    FROM tbl_Emp;
    But it does not give me the required output. It creates <Employees> tag with each individual record which I don't need. I need <Employees> tag to be the root tag and <Employee> tag to repeat and wrap each individual record. Please help me in this as this is very urgent. Thanks.

    Hi,
    Please remember that nothing is "urgent" here, and repeating that it is will likely produce the opposite effect.
    If you need a quick answer, provide all necessary details in the first place :
    - db version
    - test case with sample data and DDL
    That being said, this one's easy, you have to aggregate using XMLAgg :
    SELECT XMLElement("Employees"
           , XMLAttributes(
               'http://App.Schemas.Employees' AS "xmlns"
             , 'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi"
           , XMLAgg(
               XMLElement("Employee"
               , XMLForest(
                   e.first_name as "First_Name"
                 , e.last_name  as "Last_Name"
           ) AS "RESULT"
    FROM hr.employees e
    ;

  • Help on converting query with case into decode

    Hi Can anyone help me to revise my plsql query? Below is a portion og the procedure I am changing to meet Oracle 8i.
    SELECT SUM(NVL(CASE WHEN (weeks='wk1' ) THEN qty END, 0)) wk1,
    SUM(NVL(CASE WHEN (weeks='wk2' ) THEN qty END, 0)) wk2,
    SUM(NVL(CASE WHEN (weeks='wk3' ) THEN qty END, 0)) wk3,
    SUM(NVL(CASE WHEN (weeks='wk4' ) THEN qty END, 0)) wk4
    FROM TABLE1
    Thanks in advance.

    pls try this....(code not tested as no create table etc provided).
    select dt
    from (select decode(is_tbd,
    'yes',
    decode(is_tbd_order,
    'no',
    'tbd',
    decode(sign(ex_fac_date - (v_asofdate + 131)),
    1,
    'tbd',
    null),
    decode(sign(ex_fac_date - (v_asofdate + 131)),
    1,
    'tbd',
    null)),
    null) dt
    from dual
    union all
    select decode(sign(ex_fac_date - (v_asofdate - 1)),
    1,
    decode(sign(ex_fac_date - (v_asofdate + 5)),
    0,
    decode(is_tbd, 'no', 'wk1', null),
    null),
    null)
    from dual
    union all
    select decode(sign(ex_fac_date - (v_asofdate + 6)),
    1,
    decode(sign(ex_fac_date - (v_asofdate + 12)),
    0,
    decode(is_tbd, 'no', 'wk2', null),
    null),
    null)
    from dual
    select decode(sign(ex_fac_date - (v_asofdate + 13)),
    1,
    decode(sign(ex_fac_date - (v_asofdate + 19)),
    0,
    decode(is_tbd, 'no', 'wk3', null),
    null),
    null)
    from dual
    union all
    select decode(sign(ex_fac_date - (v_asofdate - 1)),
    0,
    decode(is_tbd, 'no', 'past_due', null),
    null)
    from dual
    where dt is not null
    Regards

Maybe you are looking for

  • Interactive ALV ?

    Hi experts, In my interactive ALV report I want to give different color to selected rows in my alv. How to proceed with that in interactive alv? Thanks, Sakthi C

  • Two Apple IDs, one iCloud ID, will it work?

    Two Apple IDs, one iCloud ID, will it work? In my house we have two iPhones and one Mac.  My husband and I have two separate Mac accounts, separate  iTunes accounts and one common Mobile Me account we use to synch Calendar and Address book between ou

  • Why charger saying not supported when it is a genuine apple charger

    Why charger saying not supported when it is a genuine apple charger

  • Incoming payments in crystal reports

    Hi all, I'm trying to recreate the incoming payments screen in crystal reports.  Does anyone know what dates are used to generate the overdue days column?  I thought it was JDT1.RefDate and {ORCT.DocDueDate}, but I was wrong. Thanks for any help give

  • Different appearance of same file

    Can anyone explain why the same PDF file viewed in Reader 8.1.2 on XPSP3 on two different laptops should look so different? I've posted side-by-side screenshots of an example at http://www.pixentral.com/show.php?picture=1oi6hYvQnhYXKGvG5GN7TiYgzURZ T