rewrite of SQL...

Hi, please help me to improve write performance. most of the tables is common tables...

SELECT

ATLT. ATSY_ID,

TO_CHAR (ATLT. ATXR_DEST_ID, ' YYYY-MM-DD HH24:MI:SS. FF') AS ATLT_FROM_NAME,

TO_CHAR (ATXR. ATXR_SOURCE_ID, ' YYYY-MM-DD HH24:MI:SS. FF') AS ATLT_FROM_ADDR1,

ATLT. ATLD_ID,

'A' AS ATLT_TO_NAME,

ATLT. ATLT_TO_ADDR1,

ATLT. ATLT_TO_ADDR2,

ATLT. ATLT_TO_ADDR3,

ATLT. ATLT_TO_CITY,

ATLT. ATLT_TO_STATE,

ATLT. ATLT_TO_ZIP,

ATLT. ATLT_TO_CTRY_CD,

SBSB. SBSB_ID,

SBSB. SBSB_CK,

SBSB. GRGR_CK,

SBSB. SBSB_LAST_NAME,

SBSB. SBSB_FIRST_NAME,

SBSB. SBSB_MID_INIT,

ATTG. ATTG_CREATE_USUS,

ATLT. ATLT_SEQ_NO,

BLEI. BLEI_BILL_LEVEL AS BLEI_BILL_LEVEL,

MOR. BLBL_DUE_DT AS BLBL_DUE_DT,

BLDF. BLDF_GRACE_PER, MOR BLEI_CK,

MOR BLBL_END_DT.

MOR BLBL_DLNQ_DT.

Of

FC_CER_ATXR_ATTACH_U ATXR

JOIN FC_CER_ATLT_LETTER_D ATLT ON (ATXR. ATXR_DEST_ID = ATLT. ATXR_DEST_ID AND ATXR. ATSY_ID = ATLT. ATSY_ID AND ATLT. ATLD_ID IN ('CMC8LSA3', 'CMC8LB10', 'CMC8LB11', 'CMC8LB12', 'CMC8LB13') and ATXR. ATSY_ID = 'LB01' and ATLT. ATSY_ID = "LB01")

JOIN FC_CER_ATTG_TRIGGER ATTG ON (ATLT. ATXR_DEST_ID = ATTG. ATXR_DEST_ID AND ATLT. ATSY_ID = ATTG. ATSY_ID AND ATTG. ATSY_ID = 'LB01' AND ATLT. ATLT_SEQ_NO = ATTG. ATLT_SEQ_NO)

JOIN FC_CMC_BLBL_BILL_SUMM BOOP ON (MOR. ATXR_SOURCE_ID = ATXR. ATXR_SOURCE_ID) JOIN FC_CMC_BLEI_ENTY_INFO BLEI ON (MOR BLEI_CK = BLEI. BLEI_CK AND BLEI. BLEI_BILL_LEVEL ('I'))

JOIN FC_CMC_SBSB_SUBSC SBSB ON (BLEI. BLEI_BILL_LEVEL_CK = SBSB. SBSB_CK)

LEFT OUTER JOIN FC_CMC_BLDF_BL_DEFINE BLDF ON (BLDF. BLEI_CK = BLEI. BLEI_CK AND (MOR BLBL_DUE_DT BETWEEN BLDF. BLDF_EFF_DT AND BLDF. BLDF_TERM_DT))

LEFT OUTER JOIN FC_CMC_PMDD_DLNQ_DEF ON (PREMENSTRUAL DYSPHORIC DISORDER PREMENSTRUAL DYSPHORIC DISORDER. PMDD_PFX = BLDF. PMDD_PFX AND PREMENSTRUAL DYSPHORIC DISORDER. ATLD_ID = ATLT. ATLD_ID)

WHERE THERE IS NO

(SELECT 1 OF FC_CMC_SBWM_SB_MSG SBWM WHERE SBWM.) SBSB_CK = SBSB. SBSB_CK and SBWM. WMDS_SEQ_NO IN (30,31)

AND TRUNC (TO_DATE (APRIL 26, 2014 05:14:35 "," MM/DD/YYYY HH24:MI:SS')) BETWEEN SBWM.)) SBWM_EFF_DT AND SBWM. SBWM_TERM_DT)

UNION ALL

SELECT

ATLT. ATSY_ID,

TO_CHAR (ATLT. ATXR_DEST_ID,'YYYY-MM-DD HH24:MI:SS. FF') AS ATLT_FROM_NAME,

TO_CHAR (ATXR. ATXR_SOURCE_ID,'YYYY-MM-DD HH24:MI:SS. FF') AS ATLT_FROM_ADDR1,

ATLT. ATLD_ID,

' AS ATLT_TO_NAME.

ATLT. ATLT_TO_ADDR1,

ATLT. ATLT_TO_ADDR2,

ATLT. ATLT_TO_ADDR3,

ATLT. ATLT_TO_CITY,

ATLT. ATLT_TO_STATE,

ATLT. ATLT_TO_ZIP,

ATLT. ATLT_TO_CTRY_CD,

SBSB. SBSB_ID,

SBSB. SBSB_CK,

SBSB. GRGR_CK,

SBSB. SBSB_LAST_NAME,

SBSB. SBSB_FIRST_NAME,

SBSB. SBSB_MID_INIT,

ATTG. ATTG_CREATE_USUS,

ATLT. ATLT_SEQ_NO,

BLEI. BLEI_BILL_LEVEL AS BLEI_BILL_LEVEL,

MOR. BLBL_DUE_DT AS BLBL_DUE_DT,

BLDF. BLDF_GRACE_PER, MOR BLEI_CK,

MOR BLBL_END_DT.

MOR BLBL_DLNQ_DT.

Of

FC_CER_ATXR_ATTACH_U ATXR JOIN FC_CER_ATLT_LETTER_D ON (ATXR ATLT. ATXR_DEST_ID = ATLT. ATXR_DEST_ID AND ATXR. ATSY_ID = ATLT. ATSY_ID AND ATLT. ATLD_ID IN ('CMC8LSA4', 'CMC8LSA3') and ATXR. ATSY_ID = 'LB01' AND ATLT. ATSY_ID = "LB01")

JOIN FC_CER_ATTG_TRIGGER ATTG ON (ATLT. ATXR_DEST_ID = ATTG. ATXR_DEST_ID AND ATLT. ATSY_ID = ATTG. ATSY_ID AND ATTG. ATSY_ID = 'LB01' AND ATLT. ATLT_SEQ_NO = ATTG. ATLT_SEQ_NO)

JOIN FC_CMC_SBSB_SUBSC SBSB ON (SBSB. ATXR_SOURCE_ID = ATXR. ATXR_SOURCE_ID) JOIN FC_CMC_BLEI_ENTY_INFO BLEI ON (BLEI. BLEI_BILL_LEVEL_CK = SBSB. SBSB_CK AND BLEI. BLEI_BILL_LEVEL ('I'))

JOIN FC_CMC_BLBL_BILL_SUMM BOOP ON (MOR BLBL_DUE_DT = (SELECT MAX (BLBL_DT. BLBL_DUE_DT) OF FC_CMC_BLBL_BILL_SUMM BLBL_DT WHERE BLBL_DT. BLEI_CK = MOR BLEI_CK) AND MOR. BLEI_CK = BLEI. BLEI_CK)

LEFT OUTER JOIN FC_CMC_BLDF_BL_DEFINE BLDF ON (BLDF. BLEI_CK = BLEI. BLEI_CK AND (MOR BLBL_DUE_DT BETWEEN BLDF. BLDF_EFF_DT AND BLDF. BLDF_TERM_DT)) LEFT PMDD FC_CMC_PMDD_DLNQ_DEF JOIN EXTERNAL ON (PREMENSTRUAL DYSPHORIC DISORDER. PMDD_PFX = BLDF. PMDD_PFX AND PREMENSTRUAL DYSPHORIC DISORDER. ATLD_ID = ATLT. ATLD_ID) - as part of the changes of UNHCR added 30/07/2013

WHERE

NOT EXIST

(SELECT 1 OF FC_CMC_SBWM_SB_MSG SBWM WHERE SBWM.) SBSB_CK = SBSB. SBSB_CK AND SBWM. IN WMDS_SEQ_NO (30,31) AND TRUNC (to_date (April 26, 2014 05:14:35 "," MM/DD/YYYY HH24:MI:SS')) ENTRE SBWM.)) SBWM_EFF_DT AND SBWM. SBWM_TERM_DT)

Maybe (at your own risk - maybe not fastest)

with

base_table as

(select / * + materialize * /)

atlt.atsy_id,

atlt.atxr_dest_id,

atxr.atxr_source_id,

atlt.atld_id,

atlt.atlt_to_addr1,

atlt.atlt_to_addr2,

atlt.atlt_to_addr3,

atlt.atlt_to_city,

atlt.atlt_to_state,

atlt.atlt_to_zip,

atlt.atlt_to_ctry_cd,

attG.attg_create_usus,

atlt.atlt_seq_no,

of fc_cer_atxr_attach_u atxr

Join

fc_cer_atlt_letter_d atlt

On atxr.atxr_dest_id = atlt.atxr_dest_id

and atxr.atsy_id = atlt.atsy_id

and atlt.atld_id ('CMC8LSA3', 'CMC8LB10', 'CMC8LB11', 'CMC8LB12', 'CMC8LB13', 'CMC8LSA4')

and atxr.atsy_id = 'LB01.

and atlt.atsy_id = 'LB01.

Join

fc_cer_attg_trigger attg

On atlt.atxr_dest_id = attg.atxr_dest_id

and atlt.atsy_id = attg.atsy_id

and attg.atsy_id = 'LB01.

and atlt.atlt_seq_no = attg.atlt_seq_no

),

unioned_tables as

(select bt.atlt.atsy_id,

BT.atxr_dest_id,

BT.atxr_source_id,

BT.atld_id,

"A' atlt_to_name,.

BT.tlt_to_addr1,

BT.atlt_to_addr2,

BT.atlt_to_addr3,

BT.atlt_to_city,

BT.atlt_to_state,

BT.atlt_to_zip,

BT.atlt_to_ctry_cd,

SBSB.sbsb_id,

SBSB.sbsb_ck,

SBSB.grgr_ck,

SBSB.sbsb_last_name,

SBSB.sbsb_first_name,

SBSB.sbsb_mid_init,

BT.attg_create_usus,

BT.atlt_seq_no,

Blei.blei_bill_level,

blbl.blbl_due_dt,

blbl.blei_ck,

blbl.blbl_end_dt,

blbl.blbl_dlnq_dt

of base_table bt

Join

fc_cmc_blbl_bill_summ Mor

On blbl.atxr_source_id = bt.atxr_source_id

and bt.atld_id in ('CMC8LSA3', 'CMC8LB10', 'CMC8LB11', 'CMC8LB12', 'CMC8LB13')

Join

fc_cmc_blei_enty_info blei

On blbl.blei_ck = blei.blei_ck

and blei.blei_bill_level = 'I '.

Join

fc_cmc_sbsb_subsc sbsb

On blei.blei_bill_level_ck = sbsb.sbsb_ck

Union of all the

Select bt.atsy_id,

BT.atxr_dest_id,

BT.atxr_source_id,

BT.atld_id,

AM' atlt_to_name,.

BT.atlt_to_addr1,

BT.atlt_to_addr2,

BT.atlt_to_addr3,

BT.atlt_to_city,

BT.atlt_to_state,

BT.atlt_to_zip,

SBSB.sbsb_id,

SBSB.sbsb_ck,

SBSB.grgr_ck,

SBSB.sbsb_last_name,

SBSB.sbsb_first_name,

SBSB.sbsb_mid_init,

BT.atlt_to_ctry_cd,

BT.attg_create_usus,

BT.atlt_seq_no,

Blei.blei_bill_level,

blbl.blbl_due_dt,

blbl.blei_ck,

blbl.blbl_end_dt,

blbl.blbl_dlnq_dt

of base_table bt

Join

fc_cmc_sbsb_subsc sbsb

On sbsb.atxr_source_id = bt.atxr_source_id

and bt.atld_id in ('CMC8LSA4', 'CMC8LSA3')

Join

fc_cmc_blei_enty_info blei

On blei.blei_bill_level_ck = sbsb.sbsb_ck

and blei.blei_bill_level = 'I '.

Join fc_cmc_blbl_bill_summ Boop

on blbl.blbl_due_dt = (select max (blbl_dt.blbl_due_dt)

of fc_cmc_blbl_bill_summ blbl_dt

where blbl_dt.blei_ck = blbl.blei_ck

)

and blbl.blei_ck = blei.blei_ck

)

Select ut.atsy_id,

TO_CHAR (hh24:mi:ss.ff ut.atxr_dest_id, 'yyyy-mm-dd') as atlt_from_name,

TO_CHAR (hh24:mi:ss.ff ut.atxr_source_id, 'yyyy-mm-dd') as atlt_from_addr1,

UT.atld_id,

UT.atlt_to_name,

UT.atlt_to_addr1,

UT.atlt_to_addr2,

UT.atlt_to_addr3,

UT.atlt_to_city,

UT.atlt_to_state,

UT.atlt_to_zip,

UT.sbsb_id,

UT.sbsb_ck,

UT.grgr_ck,

UT.sbsb_last_name,

UT.sbsb_first_name,

UT.sbsb_mid_init,

UT.atlt_to_ctry_cd,

UT.attg_create_usus,

UT.atlt_seq_no,

UT.blei_bill_level,

UT.blbl_due_dt,

bldf.bldf_grace_per,

UT.blei_ck,

UT.blbl_end_dt,

UT.blbl_dlnq_dt

to unioned_tables ut

left outer join

fc_cmc_bldf_bl_define bldf

On bldf.blei_ck = ut.blei_ck

and ut.blbl_due_dt between bldf.bldf_eff_dt and bldf.bldf_term_dt

left outer join

premenstrual dysphoric disorder fc_cmc_pmdd_dlnq_def

On pmdd.pmdd_pfx = bldf.pmdd_pfx

and pmdd.atld_id = ut.atld_id

If not exists (select null

of fc_cmc_sbwm_sb_msg

where sbsb_ck = ut.sbsb_ck

and wmds_seq_no in (30,31)

and the date '' 2014-04-26 between sbwm_eff_dt and sbwm_term_dt

)

Concerning

Etbin

Tags: Database

Similar Questions

  • Rewrite the sql query

    Hello

    I need to rewrite this SQL query to give the same result, but a way more resorcefull.
    Probably using aggregation, but I'm not sure.
    Can someone give me a head start.
    desc resource_bundles
    
    Name          Null     Type                
    ------------- -------- ------------------- 
    LOCALE        NOT NULL CHAR(5)             
    BUNDLE_NAME   NOT NULL VARCHAR2(32)        
    RESOURCE_NAME NOT NULL VARCHAR2(64)        
    VALUE_STRING           VARCHAR2(2048 CHAR) 
    
    select a.bundle_name,a.resource_name, a.value_string as Czech,(select b.value_string 
                                             from resource_bundles b 
                                             where b.bundle_name = a.bundle_name
                                             and b.resource_name = a.resource_name
                                             and b.locale = 'en_US'
                                            )as English,
                                             (select c.value_string 
                                             from resource_bundles c 
                                             where c.bundle_name = a.bundle_name
                                             and c.resource_name = a.resource_name
                                             and c.locale = 'ru_RU'
                                             ) as Russian,
                                             (select d.value_string 
                                             from resource_bundles d 
                                             where d.bundle_name = a.bundle_name
                                             and d.resource_name = a.resource_name
                                             and d.locale = 'it_IT'
                                            ) as Italian
    from resource_bundles a
    where a.locale = 'cs_CZ';
    Thank you

    Published by: BluShadow on April 15, 2011 12:20
    addition of {noformat}
    {noformat} tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    Hello

    Here's one way:

    SELECT       bundle_name, resource_name
    ,       MIN (CASE WHEN locale = 'cs_CZ' THEN value_string END)     AS czech
    ,       MIN (CASE WHEN locale = 'en_US' THEN value_string END)     AS english
    ,       MIN (CASE WHEN locale = 'ru_RU' THEN value_string END)     AS russian
    ,       MIN (CASE WHEN locale = 'it_IT' THEN value_string END)     AS italian
    FROM       resouce_bundles
    GROUP BY  bundle_name, resource_name
    HAVING       COUNT (CASE WHEN locale = 'cs_CZ' THEN 1 END)     > 0
    

    If you would care to view the information that Centinul mentioned, then I could test it.

    Published by: Frank Kulash, April 17, 2011 15:08
    Removed extra "(" in 'HAVING COUNT ((...)'.

  • How to rewrite the sql statement?

    Hello my query goes like this:

    Select a, b, c
    from (select 5A, b null, null double c
    Union of all the
    Select null, 4, the double null
    Union of all the
    Select 10, 3, double null) test_tab;

    and I want to get the result

    5 null null
    null null 4
    10 null null
    3 null null

    How can I rewrite the query without changing the structure of a table?

    Kind regards
    Igor

    Hello

    A way

    select a, null b, null c from test_tab where a is not null
    union all
    select null, b, null from test_tab where b is not null
    union all
    select null, null, c from test_tab where c is not null
    

    Concerning
    Anurag

  • rewrite the sql code

    Hi all

    I use below statement in my merge request:

    SELECT ROWNUM FROM dual CONNECT BY LEVEL SHIFT_TYPE < = 2

    I wonder do not double table. Can we get the result that above query gets hitting does not double table because the double table doesn't it belong to our schema.

    Kind regards

    Amrit

    Requirement of the strange

    Try the below one:

    with x as
    (
    select 'a' from  where rownum <= 1
    )
    select rownum shift_type
    from x
    connect by level <=5
    
  • Rewriting SQL.

    I have table I need to a query SELECT as below

    SELECT * FROM TB WHERE MS = 23 AND TG = 1023 AND EVENT_TIME IN (SELECT MAX (EVENT_TIME) FROM TB WHERE MS = 23 AND TG =1023)

    UNION ALL

    SELECT * FROM TB WHERE MS = 34 AND TG =1020 AND EVENT_TIME IN (SELECT MAX (EVENT_TIME) FROM TB WHERE MS = 34 AND TG =1020)

    UNION ALL

    SELECT * FROM TB WHERE MS =45 AND TG =4444 AND EVENT_TIME IN (SELECT MAX (EVENT_TIME) OF TB WHERE MS =45 AND TG =4444)

    UNION ALL

    ....

    ....

    only to the list below:

    MSGE
    231023
    341020
    454444
    5645545
    7745355
    78435
    98345553
    45345553

    Is it possible to rewrite the SQL in a way to make me just a SELECT clause? I don't want to use several UNION SELECT clauses.

    Thank you!!

    Bugs

    Always better to share create table statement with sample data and the business logic for the output you want, this will help us help you. Here is a way.

    select ms,tg,dt from (
    select ms,tg,dt, max(dt) over(partition by ms,tg order by dt desc) max_dt from
    (
    select ms,tg,dt from tb where (ms,tg) in ( (23,1023),(34,1020),(45,4444))
    )
    ) where dt = max_dt
    
  • Any good book on SQLs rewriting for adjustment purposes?

    Is there a good book explaining how to rewrite Oracle SQLs in an optimal way?

    It's so, where to start...
    In addition to the resources above, all or part of the books below would contribute significantly in their way to this knowledge:

    [Dan Tow: SQL Tuning | http://www.amazon.com/SQL-Tuning-Dan-Tow/dp/0596005733/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1241014515&sr=8-1]
    [Jonathan Lewis: basic principles-based optimizer costs | http://www.amazon.com/SQL-Tuning-Dan-Tow/dp/0596005733/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1241014515&sr=8-1]
    [Tom Kyte: effective Oracle by Design | http://www.amazon.com/Effective-Oracle-Design-Osborne-ORACLE/dp/0072230657/ref=sr_1_5?ie=UTF8&s=books&qid=1241015035&sr=1-5]
    [Christian Antognini: Troubleshooting Oracle Performance | http://www.amazon.com/Effective-Oracle-Design-Osborne-ORACLE/dp/0072230657/ref=sr_1_5?ie=UTF8&s=books&qid=1241015035&sr=1-5]

  • Help in to convert CASE to DECODE in 11g sql

    11 GR 2, Windows.

    Can someone help me rewrite under sql CASE statement to DECODE?
    SELECT INVOICE_ID,sum(TOTAL_EXCL_VAT),LEVEL2 as descr,
    sum(case when instr(LEVEL2,'Internet')>0 then SUM_QUANTITY else 0 end) as KB  --- >> Here
    from rator_cdr.INVOICE_DETAIL_LINE 
    WHERE INVOICE_ID ='000000000000000000' and CALLER='0000000000' and LEVEL1='Gesprekskosten' 
    group by LEVEL2,INVOICE_ID;
    Thank you

    Why would you want to replace the much more expressive syntax of CASES with a DECODING?

    If you are really determined

    DECODE( instr( level2, 'Internet' ), 0, 0, sum_quantity )
    

    I would strongly prefer the option CASE, however.

    Justin

  • Retrieve and display a result set using the dynamic sql?

    Hi all

    How would display a result set in Oracle using the dynamic SQL? Reason being, the table where I'd retrieve and display the result set is a GLOBAL TEMP TABLE created in a stored procedure. If I try to use the loop as usual, the compiler complains that the table does not exist. This makes sense because the compiler does not recognize the table because it is created dynamically. Here is an example:

    create or replace PROCEDURE maketemptab IS
    sql_stmt VARCHAR2 (500);
    OutputString VARCHAR2 (50);

    BEGIN
    -create temporary table
    sql_stmt: = ' CREATE of TABLE TEMPORARY GLOBAL globtemptab (id NUMBER, col1 VARCHAR2 (50))';
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... created table ');

    -Insert a row into the temporary table
    sql_stmt: = "INSERT INTO globtemptab values (1, 'some data of a test')';"
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... inserted row ');

    -Insert a row into the temporary table
    sql_stmt: = ' INSERT INTO globtemptab values (2, "some more test data");
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... inserted row ');

    -Select the row on temporary table
    sql_stmt: = 'SELECT col1 FROM globtemptab WHERE id = 1';
    EXECUTE IMMEDIATE sql_stmt INTO outputstring;
    dbms_output.put_line ('... selected line: ' | outputstring);

    -drop temporary table
    sql_stmt: = 'DROP TABLE globtemptab;
    EXECUTE IMMEDIATE sql_stmt;
    dbms_output.put_line ('... moved table ');

    -display the result set
    for tabdata loop (select col1 from globtemptab)
    dbms_output.put_line ('... test of recovered data are' | tabdata.col1)
    end loop;
    end;


    In short, how to rewrite the SQL below the comment "to display the result set" using the dynamic sql?

    Thank you
    Amedeo.

    Hello

    Try this:

    CREATE OR REPLACE PROCEDURE maketemptab IS
       sql_stmt     VARCHAR2(500);
       outputstring VARCHAR2(50);
       v_cursor     SYS_REFCURSOR;
       v_col1       VARCHAR2(30);
    BEGIN
       -- create temp table
       sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE globtemptab(id NUMBER, col1 VARCHAR2(50))';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...table created');
    
       -- insert row into temp table
       sql_stmt := 'INSERT INTO globtemptab values (1, ''some test data'')';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...row inserted');
    
       -- insert row into temp table
       sql_stmt := 'INSERT INTO globtemptab values (2, ''some more test data'')';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...row inserted');
    
       -- select row from temp table
       sql_stmt := 'SELECT col1 FROM globtemptab WHERE id=1';
       EXECUTE IMMEDIATE sql_stmt
          INTO outputstring;
       dbms_output.put_line('...row selected: ' || outputstring);
    
       OPEN v_cursor FOR 'SELECT col1 FROM globtemptab';
    
       LOOP
          FETCH v_cursor
             INTO v_col1;
          EXIT WHEN v_cursor%NOTFOUND;
          dbms_output.put_line('...test data retrieved is' || v_col1);
       END LOOP;
       CLOSE v_cursor;
    
       -- drop temp table
       sql_stmt := 'DROP TABLE globtemptab';
       EXECUTE IMMEDIATE sql_stmt;
       dbms_output.put_line('...table dropped');
    END;
    /
    

    Kind regards

  • Database error-2147217865 Toolikit LV

    Hello.

    Curetly I'm familiar with LV Database Toolkit version 2014.

    In our company we use database on a remote server, so our COMPUTER technician installed on my computer Oracle and sets DSN. Now, in LV, I am able to create the connection and list all the tables in the database, but when I try to display the information in column I get this error:

    "Error-2147217865 occurred at NI_Database_API.lvlib:Conn Execute.vi-> NI_Database_API.lvlibColumns.vi B tools list-> Untitled 1".

    In the possible reasons, it is said that the table does not exist in the database, but this is nonsense. is there something I'm missing? Something in the DSN parameter or...?

    Below is the screenshot of my code and this error message.

    Thank you

    Error: ORA-00942: table or view does not exist

    You tried to execute a SQL statement which makes reference to a table or view that either did not exist, you do not have access, or who belong to another schema, and you didn't refer to the table by the schema name.

    There are the options to resolve the Oracle error:

    Option #1

    If this error occurs because the table or view does not exist, you must create the table or view. You can check whether the table exists in Oracle by running the following SQL statement:

    SELECT *.
    Of object
    WHERE object_type IN ('TABLE', 'SEE')
    AND object_name = 'OBJECT_NAME ';

    For example, if you are looking a Suppliers table, you would run:

    SELECT *.
    Of object
    WHERE object_type IN ('TABLE', 'SEE')
    AND object_name = "SUPPLIERS";

    Option #2

    If this error occurs because you do not have access to the table or view, you will need to have the owner of the table/view, or a DBA grant privileges to this object.

    Option #3

    If this error occurs because the table/view belongs to another schema, and you did not refer to the table by the schema name, you will need to rewrite your SQL to insert the schema name.

    For example, you may have executed the following SQL statement:

    SELECT *.
    Providers;
    The suppliers table belong you, but on the contrary, it is owned by an app called schema, you could set your SQL as follows:

    SELECT *.
    OF app.suppliers;
    If you don't know what schema from table/view belongs to the providers, you can run SQL following namely:

    SELECT master
    Of object
    WHERE object_type IN ('TABLE', 'SEE')
    AND object_name = "SUPPLIERS";
    This will return the name of the schema owner of the suppliers table.

    Source: https://www.techonthenet.com/Oracle/errors/ora00942.php

  • Check the consequential digital beaches / coasts/next

    Hello.

    I have the classic table with the lines:

    Range1 - 1-3, 99

    Range2 - 4 - 6.99

    Range3 - 7-10

    Are there any known SQL, built-in Oracle, do anything... to check that they are correlative, adjacent or following one after the other?

    In the example above, the validation is true, and if the first value in Range2 was 4.5, validation must be false.

    Thank you. Concerning

    It looks like you want is to use the analytical function LEAD()

    The analytical LAG and LEAD functions you data before lines / following lines in a specific line.

    Be sure to read up on all of the analysis of functions in Oracle provide free manual so that you know what is available.

    Analytic Functions

    He returned to the student to rewrite the SQL code using the analytical function LAG() as an exercise.

    It is as an exercise for the student to understand the rest.

    with sample_range (range#, range_begin, range_end) as (
      select 1, 1, 3.99 from dual union all
      select 2, 4, 6.99 from dual union all
      select 3, 7, 10.00 from dual union all
      select 4, 10.01, 10.99 from dual union all
      select 5, 10.8, 11.95 from dual
    )
    select range#, range_begin, range_end
      ,range_end + 0.01 next_range_desired
      ,lead(range_begin,1) over (order by range#) next_range_actual
    from sample_range
    

    PS-

    A CREATE TABLE and INSERT statements would have been nice.

    Re: 2. How can I ask a question in the forums?

    Post edited by: MikeKutz
    Add more verbiage for explanation of answer

  • Extract XML Value returns nothing

    Hi, I have a table where I put an XMLTYPE column called XML_RESPONSE and a CLOB called XML_RESPONSE_CLOB with the same XML content each.

    One of the values of records in the two columns look like this:

    <? xml version = "1.0" encoding = "UTF - 8"? >< s : Envelope xmlns:S = » http://schemas.xmlsoap.org/soap/envelope/ « >< Body >< ns2:StampCFDBytesResponse xmlns:ns2 = » http://impl.Controllers.massive.Fe.STO.com/ "xmlns:ns3 = » http://exception.Fe.STO.com/ "><stampedDocument>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPGNmZGk6Q29tcHJvYmFudGUgdmVyc2lvbj0iMy4yIiBmb2xpbz0Cinb2IubXgvVGltYnJlRmlzY2FsRGlnaXRhbCBodHRwOi8vd3d3LnNhdC5nb2IubXgvVGltYnJlRmlzY2FsRGlnaXRhbC9UaW1icmVGaXNjYWxEaWdpdGFsLnhzZCIgeG1sbnM6dGZkPSJodHRwOi8vd3d3LnNhdC5nb2IubXgvVGltYnJlRmlzY2FsRGlnaXRhbCIvPgogICAgPC9jZmRpOkNvbXBsZW1lbnRvPgo8L2NmZGk6Q29tcHJvYmFudGU+</stampedDocument></ns2:StampCFDBytesResponse></S:Body></S:Envelope>

    I am trying to extract the base64 code, that is inside the < stampedDocument > element.

    If I use this code, the procedure runs, but returns nothing:

    Select apex_web_service.parse_xml (XML_RESPONSE, "/ / envelope/body/stampedDocument")

    in v_stamped from f_cfdi_timbrados where id_cfdi_timbrado = 1002;

    If I use the following the procedure returns an error:

    Select apex_web_service.parse_xml (XML_RESPONSE, '//Envelope/Body/stampedDocument/stampedDocument ()')

    Select apex_web_service.parse_xml (XML_RESPONSE, '//S:Envelope/S:Body/stampedDocument/stampedDocument ()')

    Select apex_web_service.parse_xml (XML_RESPONSE, ' / / s: Envelope / Body / stampedDocument')

    in v_stamped from f_cfdi_timbrados where id_cfdi_timbrado = 1002;

    06503 00000 - "PL/SQL: function returned no value."

    * Cause: A call to the PL/SQL function completed, but no RETURN statement has been

    executed.

    * Action: Function to rewrite PL/SQL, ensuring that it always returns

    a value of the appropriate type.

    I also tried with the ExtractValue function and retunrs null or an error.

    SELECT id_cfdi_timbrado,

    EXTRACTVALUE (e.xml_response, ' / envelope/body/stampedDocument ')

    'CFDI_BASE_64 '.

    OF e f_cfdi_timbrados

    WHERE id_cfdi_timbrado = 1002;

    Please notify. It's my first experience of XML parsing and it seems that I am lost.

    Francisco

    The error message provides the clue that you need.  If you were to search on this error message, you will see he's trying to tell you that you are missing a RETURN statement at the end of your function.  Something like

    RETURN v_stamped;

    That would resolve the issue causing the error ORA.

    Regarding the second question, that you will encounter, your clips are not correctly name space which is part of the XML.  For extractValue, there is a third parm

    EXTRACTVALUE

    If your query would look like

    EXTRACTVALUE (e.xml_response, ' / s: Envelope/Body / ns2:stampedDocument ',' xmlns:S = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2 = "http://impl.controllers.massive.fe.sto.com/"')

    I leave you to you of apex_web_service.parse_xml of research

    That said, depending on your version of Oracle, extractValue might be obsolete and you will have to go in a different direction.

    Here are a few tips to post on the forums

    Re: 2. How can I ask a question in the forums?

  • ORA-28132: the MERGE syntax IN does not support security policy

    Hello

    With the help of Oracle 11 g R2.

    I have the following problem:

    If the user attempts to perform a MERGE INTO statement on a table (T1), it receives the error ORA-28132: The MERGE IN syntax does not support security policy.

    Is there a way I can solve this problem by giving the user more rights on this specific table, T1? Or I need to rewrite the SQL code using UPDATE and INSERT instead MERGER?

    I can't grant POLICE ACCESS TAX-FREE, it would be too powerful privilege...

    Please advise,

    M.R.

    You may need to recreate the political VPD:

    Note:

    In previous versions of Oracle database, when you created a strategy Oracle virtual private database on an application that included the MERGE INTO statement, the MERGE INTO declaration could be avoided with a ORA-28132: Merge into syntax does not support security policies error, due to the presence of the virtual private database policy. From Oracle Database 11 g Release 2 (11.2.0.2), you can create policies on applications that include MERGE INTO operations. To do this, in the DBMS_RLS . ADD_POLICY statement_types parameter, include the INSERT , UPDATE , and DELETE statements, or simply omit statement_types setting altogether. Refer to the Oracle Database Security Guide for more information on the application of the strategies on specific types of SQL statement.

    FUSION

  • Handle the error to the deletion

    Hello

    I have a few 50 Delete simple SQL queries, such as
    BEGIN
    DECLARE
    DELETE FROM where x=1;
    DELETE FROM where x=2;
    DELETE FROM where x=3;
    .....
    exception when others
    then
    dbms_output.put_line(sqlcode);
    raise;
    
    END;
    now on the script error is culling but it is incorect:(je veux afficher l'erreur dans laquelle supprimer c'était, mais scipt besoin d'aller à la fin!)

    Any help please!

    Thank you!
    ID.

    Edited by: 1D10T on 10 April 2013 01:06

    Edited by: 1D10T on 10 April 2013 01:06

    Edited by: 1D10T on 10 April 2013 01:07

    Edited by: 1D10T on 10 April 2013 01:07

    Not if you want the rest of the SQL statement to succeed.

    You could, of course, rewrite the SQL statement to update the individual lines in a PL/SQL loop and catch exceptions in this loop. It will be slower. And involve more code. So, it is not recommended.

    And you should never write a handler exceptions as simply calls dbms_output. There is no guarantee that anyone will ever see dbms_output so it should never be invoked.

    Justin

  • Creation of a "null schema?

    We have a database of vendor 11g where records are distributed between two patterns - ACTIVE patterns and an ARCHIVE. Each object has a corresponding object both of ASSETS and patterns of ARCHIVE.

    The seller also has a third scheme where each object is simply a UNION ALL operation of schema objects associated with ASSETS and ARCHIVES. In the sake of the example, I'll call this schema COMBO.

    Over the years, we have created queries and reports that reference ARCHIVES and the COMBO patterns and which worked very well.

    The seller has set up a secondary database for us that we can use when the primary database is currently offline for the application of patches/updates / etc. The problem is this secondary database has only the scheme ASSETS and records. The seller will write no records of ARCHIVE to it.

    In short:
    Primary DB: patterns of ASSETS, ARCHIVE and COMBO
    Secondary DB: only the ACTIVE schema.

    This is probably wishful thinking, but is it possible to implement the schemes of ARCHIVE and missing COMBO on the DB side such that we will not have to rewrite our SQL to take account of the absence of a scheme of ARCHIVE when we move reports database backup?

    Of course, no record will be returned from the diagram ARCHIVE virtual, but I'd love for intact SQL to run without error.

    Thank you!

    You can certainly generate an export of diagrams ARCHIVE and active COMBO, excluding data from the database and import the metadata into the secondary database. Who will create the schema, create the tables, create views, etc., but will not import any data.

    Of course, if the seller changes one of these tables (adding or dropping a column), you will need to apply the same changes to your secondary database.

    Justin

  • Filter LIKE ANY

    Hi, I want to rewrite the sql filter condition:
    where col1 like '% a' or like '% b' col1 col1 like '%c %' or col1 like '

    in a simpler format in the same way Teradata allows:
    where col1 like everyone (would be "% a % b ',' ', '%c %',')

    What is the equivalent syntax in Oracle? REGEXP_LIKE can be used?
    An example of work please?

    Same, simpler format for:
    where col1 like '% a' not and not like 'b %' col1 and col1 and col1 like '%c %' not like '


    Thank you
    Srinivas - y.

    ysri wrote:
    Now, what is the equivalent NOT as one for any of these?

    NOT regexp_like(col1,'(a$)|(^b)|(c)|(^d$)')
    

    Also, if I want to match the strings as *'A.B.C.%. OF *.
    where *'. ' * is true simply in the source string, how do I do the regular expression?

    Escape you with backslash:

    regexp_like(col1,'^A\.B\.C\..*\.D$')
    

    Now, back to your original case. Keep in mind, to:

    where col1 like '% a' or like '% b' col1 col1 like '%c %' or col1 like '

    like '% b' Col1 and col1 as would be "will use the index (assuming that col1 is indexed) as:"

    REGEXP_LIKE (col1,'(a$) |) () ^ b) | (c) | (^d$)')

    will not.

    SY.

Maybe you are looking for

  • No option to import for SD card or iPhone

    All of sudden app of my photos stop showing the button "import" when I plug my iPhone or insert a SD card into my computer. Any ideas? Image capture can see my photos, however.

  • I can't access the address at the top of the screen bar

    When I look at my home page, Mozilla, Yahoo or something else, I see the toolbar file, etc. and a bar with the homepage listed under the toolbar, but I can't access the address bar I use to type in a Web site. is today

  • Help with extended warranty

    My dad just bought me a Satellite U400 earlier this month, with her an extended international warranty from 1 to 2 years. I registered my cell phone today, on March 23. I entered your contract number when asked, but there was a message saying that th

  • Several instances of VI in separate threads

    Hello I am trying to run two instances of the same VI (with separate sequence contexts) in two separate threads. These two instances are called from two separate sequences, using a new thread for each sequence. The problem is that the instance of the

  • I would like to upgrade to Windows 7

    is it possible to go directly from vista to windows 7?