Release of SQL with the conditional basis

Hi guys,.

I have a NAICS_CODE table that contains two passes and data are as below

NAICS_CODE NAICS_DESC
321113 Mills
32111-sawmills and wood PreservationT
3211 sawmills and wood PreservationT
321 ManufacturingT wooden products
32 manufacturing


I run a sql query which will check if there is NAICS_CODE = 321113, then it will retrun

321113
32111
3211
12 s
32
Otherwise, it will return nothing


I framed a query like this

SELECT NCMI1. NAICS_CODE,
NCMI1. NAICS_DESC,
NCMI1. INHERIT_PROPS
OF NAICS_CODE NCMI1
WHERE (SELECT COUNT (1) OF NAICS_CODE WHERE NAICS_CODE = '321113') > = 1
AND)
NAICS_CODE = '321113'
OR NAICS_CODE = '32111'
OR NAICS_CODE = "3211.
OR NAICS_CODE = '321'
OR NAICS_CODE = '32')

ORDER BY Length (NAICS_CODE) DESC

I was wondering is there a better way to do this.

Please five any suggestion, thanks in advance

I am using oracle 11g
with testdata as (
select 321113 NAICS_CODE, 'Sawmills' NAICS_DESC from dual union all
select 32111, 'Sawmills and Wood PreservationT' from dual union all
select 3211, 'Sawmills and Wood PreservationT' from dual union all
select 321, 'Wood Product ManufacturingT' from dual union all
select 32, 'Manufacturing' from dual
)

select NAICS_CODE from testdata
start with NAICS_CODE = 321113
connect by nocycle
NAICS_CODE = prior substr(NAICS_CODE, 1, length(NAICS_CODE) - 1)

NAICS_CODE
321113
32111
3211
321
32 

Tags: Database

Similar Questions

  • Is it possible to rank with the condition of a group?

    Is it possible to rank with the condition of a group? for example, I have following dataset.
     
    RANK() OVER (partition BY PC.POLICY_NUMBER, PC.TRANSACTION_TYPE, COV_CHG_EFF_DATE order by PC.POLICY_NUMBER, COV_CHG_EFF_DATE, PC.TIMESTAMP_ENTERED) AS RNK,
    
    POLICY_NUMBER    TRANSACTION_TYPE  COV_CHG_EFF_DATE  TIMESTAMP_ENTERED                        Rank
    10531075PQ                           01           01/FEB/2009              15/SEP/2009 01:16:09.356663 AM       1
    10531075PQ                           01           01/FEB/2009              15/SEP/2009 01:16:09.387784 AM       2
    10531075PQ                           02           15/OCT/2009             16/OCT/2009 04:40:24.564928 PM       1
    10531075PQ                           02           15/OCT/2009             16/OCT/2009 04:40:24.678118 PM       2
    10531075PQ                           10           15/OCT/2009             16/OCT/2009 04:45:20.290117 PM       1
    10531075PQ                           10           15/OCT/2009             16/OCT/2009 04:40:29.088737 PM       2
    10531075PQ                           09           15/OCT/2009             16/OCT/2009 04:40:29.088737 PM       1 (expected 3)
    10531075PQ                           06           17/OCT/2009             17/OCT/2009 04:45:20.290117 PM       1
    10531075PQ                           07           17/OCT/2009             17/OCT/2009 04:40:29.088737 PM       1 (expected 2)
    I want to group founded by transaction ID. For ex, '09 'and '10' as a game and ' 06' one '07' as another set. Instead of the beginning rank, rank I want continue for any occurrence of the ' 09 'or ' 10'. In the example above, for the next line, I expect to grade 3 that there are transaction 2 '10' already exist for the same COV_CHG_EFF_DATE.

    09 10531075PQ October 15, 2009 October 16, 2009 04:40:29.088737 PM 1 (3 planned)

    I wonder if it's possible with the rank or another another analytic function. Not looking for exact labour code, I will appreciate if someone can give me idea/advice. Example of table and the test data, if someone wants to experience
     
    drop table PC_COVKEY_PD;
    
    create table PC_COVKEY_PD (
    POLICY_NUMBER varchar(30),
    TERM_IDENT varchar(3),
    COVERAGE_NUMBER varchar(3),
    TRANSACTION_TYPE varchar(3),
    COV_CHG_EFF_DATE date,
    TIMESTAMP_ENTERED timestamp
    );
    
    delete from PC_COVKEY_PD;
    
    commit;
    
    insert into PC_COVKEY_PD values ('10531075PQ', '021', '002', '01', to_date('01/FEB/2009','DD/MM/YYYY'), cast('15/SEP/2009 01:16:09.356663 AM' as timestamp));
    insert into PC_COVKEY_PD values ('10531075PQ', '021', '001', '01', to_date('01/FEB/2009','DD/MM/YYYY'), cast('15/SEP/2009 01:16:09.387784 AM' as timestamp));
    insert into PC_COVKEY_PD values ('10531075PQ', '021', '004', '02', to_date('15/OCT/2009','DD/MM/YYYY'), cast('16/OCT/2009 04:40:24.164928 PM' as timestamp));
    insert into PC_COVKEY_PD values ('10531075PQ', '021', '004', '02', to_date('15/OCT/2009','DD/MM/YYYY'), cast('16/OCT/2009 04:40:24.264928 PM' as timestamp));
    insert into PC_COVKEY_PD values ( '10531075PQ', '021', '005', '10', to_date('15/OCT/2009','DD/MM/YYYY'), cast('16/OCT/2009 04:40:24.364928 PM' as timestamp));
    insert into PC_COVKEY_PD values ('10531075PQ', '021', '002', '10', to_date('15/OCT/2009','DD/MM/YYYY'), cast('16/OCT/2009 04:40:24.464928 PM' as timestamp));
    insert into PC_COVKEY_PD values ( '10531075PQ', '021', '004', '09', to_date('15/OCT/2009','DD/MM/YYYY'), cast('16/OCT/2009 04:40:24.564928 PM' as timestamp));
    insert into PC_COVKEY_PD values ('10531075PQ', '021', '004', '06', to_date('22/NOV/2011','DD/MM/YYYY'), cast('17/OCT/2009 04:40:24.564928 PM' as timestamp));
    insert into PC_COVKEY_PD values ('10531075PQ', '021', '004', '07', to_date('22/NOV/2011','DD/MM/YYYY'), cast('17/OCT/2009 04:40:24.664928 PM' as timestamp));
    
    commit;
    
    SELECT POLICY_NUMBER,
           TERM_IDENT,
           COVERAGE_NUMBER,
           TRANSACTION_TYPE,
           COV_CHG_EFF_DATE,
           TIMESTAMP_ENTERED,
            RANK() OVER (partition BY PC.POLICY_NUMBER, PC.TERM_IDENT, PC.TRANSACTION_TYPE, PC.COV_CHG_EFF_DATE 
                    order by PC.POLICY_NUMBER, PC.TERM_IDENT, PC.COV_CHG_EFF_DATE, PC.TIMESTAMP_ENTERED) AS RNK
    FROM PC_COVKEY_PD PC
    ORDER BY PC.POLICY_NUMBER, PC.TERM_IDENT, PC.COV_CHG_EFF_DATE, PC.TIMESTAMP_ENTERED ;
    Published by: 966820 on October 30, 2012 19:26
  • Topics marked with the conditional tags still appear in the documentation

    Hi all

    I have a big problem with RoboHelp 7.

    I defined a new conditional tag (I have 2 together) and I mark the topics in the table of contents with relate to this tag conditional, right?

    When I generate the chm file, everything is OK. The headings marked with the conditional tag do not appear in the table of contents that I specified to exculde subjects marked with this conditional tag.

    When I generate documentation however, everything is still in the document even if I was clear that I don't want these subjects to appear.

    Can you please tell me what I'm doing wrong, or how can I properly so that I get my results?

    I am using Windows XP Pro and RoboHelp is updated with all service packs.

    Thank you

    Bogdan sailor

    Right-click a topic in the table of contents and select apply the tag build conditional. Check out the new / Multiple option.

    This screen displays.

    You can clearly see if the tag is applied to the table of contents or the subject. If it is applied on the subject, so it will be not when generating table of contents entry will be automatically deleted. If it is applied to the table of contents only, he is always in the build.

    See www.grainge.org for creating tips and RoboHelp

    @petergrainge

  • Problem with the conditional tags in printed output

    I write help files for different versions of our software - version 4 and 5 using Robohelp for HTML 5.0.2

    There is a large overlap of information between the two, so I use a help file joint with marked topics that are specific to version 4 or version 5.

    I went out and then use with 'NOT v4' or "NOT v5" as the conditional tags.

    It works fine in the HTML output. However, I encountered problems with the printed output.

    Ideally, I want the help file using the option "generate the single document" because it means that the document produced, without the single output field. However, when I do, the tags conditional build fail and I get a piecemeal result.

    If I generate the document by using the option 'generate individual documents' tags conditional build work, but I get the only field I want to avoid.

    Does anyone know how to get the conditional tags to work when the option "generate the single document" is selected?

    Pierre and HKabaker - thanks for your comments.

    I think I have the answer now.

    In the properties for the SSL Print dialog, the third screen is the dialogue of section layout. I had removed some sections in the right pane (for example, the default title page, glossary, and index) because I did not want them to appear in the final printed output. It seems that without these sections present conditional compilation tags do not work correctly when the document is released by using the option 'generate a single document ".

    I started again with a "blank" printing of SSL version. Conditional constructions using the "generate a single document" appear to work fine when I leave the dialog layout intact section.

    I can even do the conditional tags build an injustice because the option "generate a single document" (after that I made the changes in the dialog layout section) seems to be that some of the chapters in the table of contents and omitting others.

  • problem of deletion of a topic with the conditional formatting - please help

    I have a problem with the removal of the header of a repetitive frame in another extensible framework

    My frame HAND led the report and contains many Extensible frameworks. When a frame has no data, I want the frame empty to be deleted so I try to use a conditional formatting - (* or should I do something else?) *.

    one of my simplest subframes as shown in the DATA MODEL is:

    AERIAL PHOTO
    AP_MDD_KEY the key that connects all of the database

    G_AP_NO
    AP_NO is the number of aerial photography
    AP_MDD_KEY is the key field

    My method:
    -I click the summary in the DATA MODEL field and then click on the AERIAL photo
    -This creates a column of synthesis named AP_COUNT
    -update the summary I put:
    Count FUNCTION
    SOURCE Ap_no
    Reset to report

    -J' I then select the M_G_AP_NO_GRPFR and open the property palette
    -Select conditional formatting, and then select NEW
    -with the Exception of the Format of page I select AP_COUNT is equal O and check hide the object
    -J' I click on APPLY and then OK

    -J' I go to the live preview generator and it takes about 30 sec to answer. But when I create and browse through the PDF report, where the group is empty (no data), the headers are still there. Nothing has changed.

    So, can someone please tell me what I'm doing wrong? I have about 15 more of the repeat frames it that I must apply this to.

    Any help is appreciated

    Glenn

    Hello

    what I would try first:
    Will the group framework, to which you added the conditional formatting and open format-relaxation-code in PL/SQL Editor. Somewhere at the end will be something like ' RETURN: AP_COUNT = 0;
    To see the value during execution simply put a

    SRW.MESSAGE(-1, :AP_COUNT);
    

    in the front of the line «back» When you run the generator preview again, it would popup a window showing the real value of the AP_COUNT (just to be safe.

    Second to check:
    Is your group really enclosing framework the header? (Just to be safe, check navigator)

    I hope this helps.

  • How to use Bulk collect in dynamic SQL with the example below:

    My Question is

    Using of dynamic SQL with collection in bulkif we pass the name of the table as "to the parameter' function, I want to display those

    An array of column names without vowels (replace the vowels by spaces or remove vowels and display).

    Please explain for example.

    Thank you!!

    It's just a predefined type

    SQL> desc sys.OdciVarchar2List
     sys.OdciVarchar2List VARRAY(32767) OF VARCHAR2(4000)
    

    You can just as easily declare your own collection type (and you are probably better served declaring your own type of readability if nothing else)

    SQL> ed
    Wrote file afiedt.buf
    
      1  CREATE OR REPLACE
      2     PROCEDURE TBL_COLS_NO_VOWELS(
      3                                  p_owner VARCHAR2,
      4                                  p_tbl   VARCHAR2
      5                                 )
      6  IS
      7     TYPE vc2_tbl IS TABLE OF varchar2(4000);
      8     v_col_list vc2_tbl ;
      9  BEGIN
     10      EXECUTE IMMEDIATE 'SELECT COLUMN_NAME FROM DBA_TAB_COLUMNS WHERE OWNER = :1 AND TABLE_NAME = :2 ORDER BY COLUMN_ID'
     11         BULK COLLECT
     12         INTO v_col_list
     13        USING p_owner,
     14              p_tbl;
     15      FOR v_i IN 1..v_col_list.COUNT LOOP
     16        DBMS_OUTPUT.PUT_LINE(TRANSLATE(v_col_list(v_i),'1AEIOU','1'));
     17      END LOOP;
     18*  END;
    SQL> /
    
    Procedure created.
    
    SQL> exec tbl_cols_no_vowels( 'SCOTT', 'EMP' );
    MPN
    NM
    JB
    MGR
    HRDT
    SL
    CMM
    DPTN
    
    PL/SQL procedure successfully completed.
    

    Justin

  • The results of F1-QUERY-how to restrict or to SQL with the role of access to the data?

    Hello

    With the help of CC & B 2.3.1.

    I'm configuration of a Zone of F1-OF-QUERY to get and display customer information as level account; the filter criteria will be Geo val SP.

    With our application, we use access to accounts and groups access to the data on users roles to restrict access to sensitive accounts, such as VIP.

    What keywords should I use in the SQL statement to limit the results only for group accounts to which access is included in the Dar of the user?

    Example: If the user has DAR 'STANDARD', it won't see accounts with group access 'VIP '.

    I tried unsucessfully: USER: USER ID,: USER_ID.

    Unsucessfull example:

    Select dar_cd, user_id, expire_dt
    of ci_dar_usr
    Where user_id =: USER_ID
    and expire_dt > =: F1

    Thks,

    Fabien

    Hi, Fabien,

    If you are looking to determine the current user in the box,
    the keyword to use is: USERID

    You can check the zone of F1 "F1-FAVSCR" for its use.

  • Run the report to PL/SQL with the branch to another page

    I have an application which, at various times, I run a PL/SQL procedure to perform an action, and then we must run a report while also navigating away from the current page. The actions are performed on a button click.

    I tried several methods, but for the life of me cannot get the system to do the two things (ie. run the report and the direction to another page). I tried to put in page 0 (to be executed after the treatment on the click of a button) a branch with a request line to print the report, followed by a branch to the other page (also to run after the treatment on the button click) - and only the branch page 0 runs in fact. Also tried a branch to the other page only, with the print in the request parameter request - but only runs the report, do not create a branch to the other page.

    I also tried to put the call to run the report in the PL/SQL code, using utl_http.start_request (url), but that came with a "Bad Request" error. Also tried to use the owa_util.redirect_url call, but also no chance.

    I'm pulling my hair out at this time, especially because I am under pressure to get the system in very short time.

    Any suggestion would be appreciated.

    You can run queries report of their URL (f? p = & APP_ID.: 0: & SESSION.: PRINT_REPORT =)

    So one approach would be to
    The button click, call a JS function which

  • 1 use the Ondemand/recall process in order to perform the processing workflow (file selection box)
  • 2 open the report in a popup (from your IR page)
  • 3 redirect leaves the IR page to another page?
    ------
    Another approach:
  • 1. IR report submits the page
  • 2. in the PLSQL block, you do the treatment
  • 3. the branch redirects to a URL that would point to the report URL.
    OR
  • 3. do you have a JS onload which runs only when demand is demand for BUTTON and opens a page that points to the report.
    ------

    Still another way is to use htp.p in PLSQL block which made the treatment of workflow
    So your code PLSQL

    BEGIN
      --Do the workflow processing here
      --End workflow processing
      htp.p('');
    END;
    
  • Problem with the conditional formatting according to pivot

    Hi all

    OBIEE version 10.1.3.3.3
    I have a measurement with the following condition column

    Measure:
    -Case when DATE < VALUEOF ("CC_DATE") and the actual amount of another amount, then end

    Here CC_DATE is variable repository

    I created a column duplicated by the following condition

    Double column:
    BOX WHEN Date < VALUEOF("CC_DATE") then end if 0-1

    And try to use duplicate column in a measure of conditional formatting, however I do not succeed

    any suggestion to solve this problem?


    Thank you
    SMA

    SMA,

    Check the link below if you want to put in shape measures based on the intersection of the dimension. A variant of the above link.
    http://www.obinotes.com/2010/10/format-cellmeasure-value-based-on-row.html

    J
    -bifacts
    http://www.obinotes.com

  • OSB: fn - bea: execute - sql () with the sql statement ' INSERT INTO...» »

    Dear Experts,

    I need a clarification. Is it possible to use the fn - bea: function execute sql (Oracle Service Bus) to perform an insert operation in a database with the data extracted from the message of the Organization (i.e. $body/Info/username)? If it is possible which is the right syntax?
    Any suggestion is appreciated.

    Kind regards
    Mike

    Published by: ITDeveloper on November 19, 2009 2.55

    Published by: ITDeveloper on November 19, 2009 3.01

    Hi Mike,.

    Please refer to my post for the same question to the fn - bea: sql performance with 'Insert INTO' the sql statement

    Thank you best regards &,.

    Vivek

  • Creation of page template with the specified base style

    I have 4.3 Pages on my Mac mini OSX 10.8.5. I want to create a template for my documents with text in a particular font, but also with all the notes in the same font.

    I searched, found and tried all sorts of ways to ensure that all notes are created in my chosen font, but my attempts have failed. Any help or advice wll be gratefully received and acted.

    Michael,

    Pages ' 09 v4.3 will not allow a frame of reference custom before the creation of reference text. Set a reference to your specifications and then by creating two new character styles that proportionately adjust the exponent, and then the reference text non-exposant - could be saved in the model.

    In the new document, you insert notes and then apply those styles at least on the first note, because with the following notes, you could copy and paste the first note of the selected character style. He said...

  • Oracle dynamic SQL with the UNION operator

    Hello

    I have sql string contains two queries separated by the UNION operator. When I run by using DBMS_SQL, it becomes only the first SQL before the UNION operator.

    Can anyone correct how can I Sue UNION in DBMS_SQL?

    Thank you

    Sorry,

    I tested my code

                        BEGIN
                          FOR I IN (SELECT 1 A FROM DUAL UNION
                                  SELECT 2 A  FROM DUAL UNION
                                  SELECT 3 A  FROM DUAL) LOOP
                          DBMS_OUTPUT.PUT_LINE(I.A);
                         END LOOP;
                        END;
                        
    

    and copy this code and PASE to DBMS_SQL. PARSE (all other cases, "... and insert the INSERT STATEMENT but does not erase DBMS_OUTPUT.")

    Edited by: Quluzade Mr. Mahir on February 28, 2011 12:18

  • Need help with the condition join in SQL

    Hi all -

    I need to ask for help with this query:

    Create table user_tab_col_test (varchar2 (30) from table_name, column_name varchar2 (30), data_type varchar2 (30));

    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('Column2', 'table1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ("Column3", 'table1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('column4', 'table1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ("column1", "table2", 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column2', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', "Column3", 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column4', 'varchar2')
    Commit;

    Create table all_cons_columns_test (varchar2 (30) from table_name, column_name varchar2 (30), constraint_name varchar2 (30))

    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ("table1", "column1", "primary")
    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ("table1", "column1", "secondary")
    Commit;

    This is my query and the current result:

    Select u.table_name, u.column_name, c.constraint_name
    Of user_tab_col_test u
    Outer join all_cons_columns_test c left
    On (u.table_name = c.table_name
    AND U.COLUMN_NAME = C.COLUMN_NAME
    AND C.CONSTRAINT_NAME IN ('main'))
    order of U.table_name, U.COLUMN_NAME;

    TABLE_NAME COLUMN_NAME, CONSTRAINT_NAME
    ------------------ --------------------- ----------------------------
    Table1 primary Column1
    Table1 Column2
    Table 1 Column3
    Table2 Column1
    Table2 Column2


    Three questions:
    (1) I don't want to return results where table_name = "table1". I can't get this to work.
    (2) is my proper request and this is the best way to return my desired results? For example, I want all of the columns of user_tab_col_test and I want to only display the constraint_name from all_cons_columns_test argument if the argument constraint_name = 'primary '.
    (3) will be the synatx be the same if I need to join a third table to all_cons_columns_test?

    Any advice/suggestions are appreciated-
    John

    Published by: user703358 on January 11, 2013 20:57

    Published by: user703358 on January 11, 2013 21:48

    Hi, John,.

    user703358 wrote:
    Hi all -

    I need to ask for help with this query:

    Create table user_tab_col_test (varchar2 (30) from table_name, column_name varchar2 (30), data_type varchar2 (30));

    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('Column2', 'table1', 'varchar2')...

    Thanks for posting the CREATE TABLE and INSERT.
    It is more useful if you post the code that can be run without modification. You did not semicolons after INSERTION instructions.

    Three questions:
    (1) I don't want to return results where table_name = "table1". I can't get this to work.

    What have you tried? Post your best attempt.
    Here's one way:

    SELECT    u.table_name
    ,        u.column_name
    ,        c.constraint_name
    FROM             user_tab_col_test      u
    LEFT OUTER JOIN  all_cons_columns_test  c
                            ON    u.table_name     = c.table_name
                   AND   u.column_name     = c.column_name
                   AND   c.constraint_name IN ('primary')
    WHERE       u.table_name     = 'table1'          --  *****  NEW  *****
    ORDER BY  u.table_name
    ,            u.column_name
    ;
    

    You would not put this condition in the clause; who controls what is considered as a match between the tables, and "u LEFT OUTER JOIN c" means show all lines of u, even if they do not have a match in the c.

    (2) is my proper request and this is the best way to return my desired results? For example, I want all of the columns of user_tab_col_test and I want to only display the constraint_name from all_cons_columns_test argument if the argument constraint_name = 'primary '.

    Basically, this application is very well.
    It displays all the columns of user_tab_col_test; missing data_type. Just add u.data_type to the SELECT clause, or change the SELECT clause

    SELECT    u.*
    ,         c.constraint_name
    

    (3) will be the synatx be the same if I need to join a third table to all_cons_columns_test?

    Do you mean "" * add * one-third * column * to all_cons_columns_test '? "
    It depends on what results you want. Post new CREATE TABLE and INSERT and instructions the results you want new data.
    Most likely, the basic structure of what you've written will remain exactly the same.

  • SQL with the Table using nested

    Hello

    Please help how to do that thing

    I have a nested table of object type

    create or replace type a1 as an object

    (

    a number,

    b varchar2 (30),

    VARCHAR2 (30) region

    );

    create table a1 type a1_array s;

    declare

    v_a1 a1;

    v_a1_array a1_array:=a1_array();

    Start

    v_a1 = a1 (1, '1', 'AUS');

    v_a1_array. EXTEND;

    v_a1_array (1): = v_a1;

    v_a1 = a1 (2, '2', 'AUS');

    v_a1_array. EXTEND;

    v_a1_array (2): = v_a1;

    v_a1 = a1 (3, '3', 'NAM');

    v_a1_array. EXTEND;

    v_a1_array (3): = v_a1;

    end;

    Now, I v_a1_array have 3 row 2 with region AUS and the other with NAM region.

    SQL help can I get lines only "AUS" and look in the TABLE OF TYPE v_a1_array (using Where clause and functions (Table))

    Any help will be much appreciated. Please help. I have Oracle 11g

    Thank you

    I hope that you are looking for this.

    pretend like your excel temp (with clause)

    v_a2 - is a type of a1_array

    SQL > select * from v version $;

    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE Production 11.2.0.2.0
    AMT for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 - Production

    SQL > DROP TYPE a1_array;

    Type fell.

    SQL > DROP TYPE a1;

    Type fell.

    SQL > CREATE or REPLACE TYPE a1 AS OBJECT
    2 (a NUMBER, b VARCHAR2 (30), region VARCHAR2 (30));
    3.

    Type of creation.

    SQL > CREATE TYPE a1_array IS TABLE of a1;
    2.

    Type of creation.

    SQL > DECLARE
    v_a1 2 a1_array;
    3 v_a2 a1_array;
    4 BEGIN
    5 WITH temp
    6 AS (SELECT 1 a, 1 b, "AUS" AS region FROM DUAL
    7 UNION ALL
    8. SELECT 2 AS a, 2 b, "AUS" AS region FROM DUAL
    9 UNION ALL
    10. SELECT 3 a, b '3', 'NAM' AS region OF DOUBLE)
    11. SELECT a1 (x.a, x.b, x.region)
    In BULK 12 COLLECT IN v_a1
    Temp 13 x;
    14
    15 SELECT a1 (x.a, x.b, x.region)
    In BULK 16 COLLECT IN v_a2
    TABLE (v_a1) 17 x
    18 WHERE x.region = 'NAM ';
    19
    20
    21 FOR I IN 1... v_a2. COUNTY
    22 LOOP
    (23) DBMS_OUTPUT.put_line
    24 v_a2 (i) .a | '-' || v_a2 (i) .b | '-' || v_a2 (i) .region);
    25 END OF LOOP;
    26 END;
    27.
    3-3-NAM

    PL/SQL procedure successfully completed.

    SQL > spool off;

  • How to remove the project using sql with the proper sequence

    Hello

    Tried to delete the project failed with query according to the sequence shown below. But get error when running below final sql script (delete from epub_process where of the project = '?')

    SQL error: ORA-02292: integrity constraint (PUB.) PROC_HIST_ID_FK) violated - book of the foundling

    02292 00000 - 'constraint integrity (s.%s) violated - child notebook found. '

    * Cause: attempted to remove a parent key value that was a stranger

    dependence.

    * Action: remove dependencies first then the parent or disable the constraint.

    delete from avm_asset_lock where workspace_id in

    (select avm_devline id, whose name in)

    (select Workspace from epub_project where project = 'prj49024')) ;

    delete from EPUB_PR_HISTORY where project in

    (select project in epub_project where project = "prj49024");

    delete from epub_project where project = "prj49024";

    delete from EPUB_PROC_HISTORY where ID_processus in

    (select ID_processus from epub_process where of the project = "prj49024");

    delete from EPUB_PROC_TASKINFO where id in

    (select ID_processus from epub_process where of the project = "prj49024");

    delete from epub_taskinfo where ID_processus in

    (select ID_processus from epub_process where of the project = "prj49024");

    delete from EPUB_WORKFLOW_STRS where id in

    (select ID from EPUB_IND_WORKFLOW where ID_processus in)

    (select ID_processus from epub_process where of the project = 'prj49024')) ;

    delete from EPUB_IND_WORKFLOW where ID_processus in

    (select ID_processus from epub_process where of the project = "prj49024");

    Get the error when running this script

    remove the epub_process of the project where = "prj49024";

    Please let me know good sequence or how to avoid this mistake

    Thank you

    Sri

    Here are the steps:

    delete from EPUB_PR_HISTORY where project in ('prj213002', 'prj200001');

    delete from EPUB_PROC_HISTORY where ID_processus in

    (select ID_processus from the epub_process of the project where in ('prj213002', 'prj200001'));

    delete from EPUB_PROC_TASKINFO where id in

    (select ID_processus from the epub_process of the project where in ('prj213002', 'prj200001'));

    delete from EPUB_IND_WORKFLOW where ID_processus in

    (select ID_processus from the epub_process of the project where in ('prj213002', 'prj200001'));

    remove the epub_process of the project where in ('prj202001', 'prj213002');

    delete from avm_asset_lock where workspace_id in

    (select avm_devline id, whose name in)

    (sélectionnez project_id dans epub_project où project_id dans ('prj213002', 'prj213002'))) ;

    delete from epub_project where project in ('prj202001', 'prj213002');

    commit;

    Peace

    Shaik

Maybe you are looking for