Oracle query setting

Hello

We are generating SSRS reports based on Oracle DB as backend. We are using oracle 11.2.0.3. We have a request in oracle that is created on the view and lots of conditions. It takes more than 8 minutes to generate a report. What are the steps I should follow to refine the query to generate report in very less time. Can someone suggest me please.

Thank you

VI

Good to hear! The appearance to explain what now?

How long does it take?

[edit] Cartesian join are not always bad, however, they are usually a good candidate to look at on a long running (in my experience anyway) query [/ edit]

If the answer to the question, the brand is so

Tags: Database

Similar Questions

  • Question the use of Oracle query Variables

    Hello

    I am new to Oracle, I tried to extract the data from the Oracle database by using the following query which includes 1 variable SYSDATE_UTS, but when I try to execute the query I get an error. Please let me know what I am doing wrong and how I can fix.

    Error message
    -----
    ORA-06550: line 4, column 1:
    PLS-00428: an INTO clause in this SELECT statement
    -----

    Oracle query

    DECLARE SYSDATE_UTS NUMBER: = (sysdate-to_date('19700101','yyyymmdd')) * 86400;
    BEGIN

    SELECT
    INCIDENT_NUMBER,
    TO_DATE (to_char ((1/86400 * REPORTED_DATE) + to_date ('19700101', 'YYYYMMDD'), "jj/mm/aaaa hh24:mi:ss"), 'hh24:mi:ss dd/mm/yyyy') as REPORTED_DATE_TIME,
    GROUP_TRANSFERS
    LAST_MODIFIED_BY
    , to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * LAST_MODIFIED_DATE, "mm/dd/yyyy hh24:mi:ss"), 'hh24:mi:ss dd/mm/yyyy') as LAST_MODIFIED_DATE
    , (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) age
    CASE
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 0 AND 1, THEN ' 0 - 1 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 2 AND 4 and THEN 2-4 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 5 AND 9, THEN 5-9 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 10 AND 19, THEN 10-19 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) > 20 THEN ' Days 20 + ".
    ANOTHER "UNKNOWN".
    END AS AGE_GROUP
    OF IncidentDataBase
    and the STATE not in (4,5,6)
    and rownum < 10;
    END;

    If you run this query in sql * plus you can declare a sql * more variable, assign a numeric value according to 'now' and use in your application, i.e.

    SQL > variable NUMBER of SYSDATE_UTS;
    SQL > exec SYSDATE_UTS: = (sysdate-to_date('19700101','yyyymmdd')) * 86400;

    You would then call your request, referring to sql * more variable with a colon as SYSDATE_UTS prior to it (i.e.: SYSDATE_UTS)

    SELECT
    INCIDENT_NUMBER,
    TO_DATE (to_char ((1/86400 * REPORTED_DATE) + to_date ('19700101', 'YYYYMMDD'), "jj/mm/aaaa hh24:mi:ss"), 'hh24:mi:ss dd/mm/yyyy') as REPORTED_DATE_TIME,
    GROUP_TRANSFERS
    LAST_MODIFIED_BY
    , to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 * LAST_MODIFIED_DATE, "mm/dd/yyyy hh24:mi:ss"), 'hh24:mi:ss dd/mm/yyyy') as LAST_MODIFIED_DATE
    , (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 *: SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) age
    CASE
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 *: SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 0 AND 1, THEN ' 0 - 1 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 *: SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 2 AND 4 and THEN 2-4 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 *: SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 5 AND 9, THEN 5-9 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 *: SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) BETWEEN 10 AND 19, THEN 10-19 days
    WHEN (to_date (to_char (to_date ('01011970 ', 'ddmmyyyy') + 1/24/60/60 *: SYSDATE_UTS, ' mm/dd/yyyy'), ' mm/dd/yyyy'))-(to_date (to_char (+ to_date('19700101','yyyymmdd') + 1/86400 * REPORTED_DATE, ' mm/dd/yyyy'), ' mm/dd/yyyy')) > 20 THEN ' Days 20 + ".
    ANOTHER "UNKNOWN".
    END AS AGE_GROUP
    OF IncidentDataBase
    and the STATE not in (4,5,6)
    and rownum<>

    Table stores IncidentDataBase the "dates" in the number of seconds since the epoch unix?

  • How to put in Spanish, ESN CP1252, oracle character set WE8MSWIN1252

    Select * from NLS_DATABASE_PARAMETERS

    database character set is
    NLS_CHARACTERSET               AL32UTF8
    NLS_NCHAR_CHARACTERSET         AL16UTF16  
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  AMERICA
    Select * from NLS_INSTANCE_PARAMETERS;
    PARAMETER                         VALUE
    --------------------------------- ---------------------------------
    NLS_LANGUAGE                      SPANISH
    NLS_TERRITORY                     SPAIN
    How to put in Spanish, ESN CP1252, oracle character set WE8MSWIN1252

    Please suggest.

    Thank you in advance

    Is it really OK to convert AL32UTF8 WE8MSWIN1252?
    AL32UTF8 NLS_CHARACTERSET

    TO

    WE8MSWIN1252 NLS_CHARACTERSET

    Please suggest

  • MySQL to Oracle query

    Hello World ^^

    I just downloaded Oracle XE and migrated my database from MySQL to Oracle successfully.
    And I'm doing/reviewing my application now especially the query syntax.
    I am facing a problem, I have a request in the form below in MySQL and it works fine but when I tried it at the Oracle XE database, it cannot run :( So I'm asking for help here, I have already searched on the internet but had no luck.

    SELECT A.INVOICEDATE,
    *@Step1:=cast (adddate (A.INVOICEDATE, A.TERMOFPAYMENT) as date) AS STEP1, *.
    *@Step2:=if (@step1 > CURDATE (), A.TOTALAMOUNT, 0) AS STEP2, *.
    *@step3:=if (@step2 <>0,0,IF(DATEDIFF(CURDATE(),@step1) < = 30, A.TOTALAMOUNT, 0)) AS step 3,
    T_invoice FROM has
    WHERE A.STATUS = 'Open'

    I can conclude the problem is based on the variable declaration in Oracle, but I still can't understand.
    What I do in MySQL, it's that I want to fill the variable with the expression/logic so I can use 'than' variable more later in the other part of the query output syntax.
    I used variables to be filled by value due to I can't use / select ALIAS later in the other party.

    So please help to convert to Oracle query syntax. Thank you.

    Oracle and MySql are two different animals. You need to learn SQL and Oracle's PL/SQL.

    Your SQL

    SELECT A.INVOICEDATE,
    @step1:=cast(ADDDATE(A.INVOICEDATE,A.TERMOFPAYMENT) as date) AS STEP1,
    @step2:=IF(@step1>CURDATE(),A.TOTALAMOUNT,0) AS STEP2,
    @step3:=IF(@step20,0,IF(DATEDIFF(CURDATE(),@step1)<=30,A.TOTALAMOUNT,0)) AS STEP3,
    FROM t_invoice A
    WHERE A.STATUS='Open' 
    

    Can be writern as

    select invoicedate,
           step1,
           step2,
           case when step2 = 0
                then case when sysdate-step1 <=30 then A.TOTALAMOUNT else 0 end
           end AS step3
      from (
             select A.invoicedate,
                    A.invoicedate+A.termofpayment step1,
                    case when (A.invoicedate+A.termofpayment) > sysdate then A.totalamount else 0 end as step2,
               from t_invoice A
              where A.status = 'Open'
           )
    
  • Character set not supported: oracle-character-set-560

    Hello

    I created a page and his works fine. In a different database when I create a page occurs as error

    Character set not supported: oracle-character-set-560


    Thanks in advance,
    Roselyne

    Hello

    Check the thread... Unsupported character set: oracle-character-set-46?-pls help!

    It has the solution for this...

    Thank you
    Gerard

  • Behavior inconsistent performance Oracle query

    Consider the following query:

    SELECT * FROM ( SELECT ARRM.*, ROWNUM FROM CRS_ARRANGEMENTS ARRM WHERE CONCAT(ARRM.NBR_ARRANGEMENT, ARRM.TYP_PRODUCT_ARRANGEMENT) > CONCAT('0000000000000000', '0000') ORDER BY ARRM.NBR_ARRANGEMENT, ARRM.TYP_PRODUCT_ARRANGEMENT, ARRM.COD_CURRENCY) WHERE ROWNUM < 1000;

    This query is performed on a table that has 10 000 000 entries. While running the query Oracle SQL Developer or my application it takes 4 minutes to run! Unfortunately, it's also the behaviour within the application I am writing. Change the value of 1000 to 10 has no impact, which suggests that he made a full table scan.

    However when the squirrel running the query returns within a few milliseconds. How is that possible? Explain plan generated in squirrel gives:

    Explain plan in SQuirreL

    But a plan different explain is generated in Oracle SQL Developer, for the same query:

    Explain plan in Oracle SQL Developer

    No idea how this difference in behavior is possible? I can't understand it. I tried with JPA and raw JDBC. In the application, I need to parse through 10 000 000 records and this query is used for pagination, so 4 minutes of waiting is not an option (which would take 27 days).

    Note: I use the same Oracle jdbc driver into a squirrel and my application so it's not the source of the problem.

    I also posted this to other web sites, for example

    http://StackOverflow.com/questions/28896564/Oracle-inconsistent-performance-behaviour-of-query

    OK - I created a test (below) case and got the same exact results you did 'test' - a FFS using SQL index * more. I then tested with SQL Developer and got the same results. You are 100 billion sure that you did not have two databases somewhere with the same name?

    SQL> create table crs_arrangements
      2  (nbr_arrangement varchar2(16) not null,
      3   product_arrangement varchar2(4) not null,
      4   cod_currency varchar2(3) not null,
      5   filler1 number,
      6  filler2 number);                                             
    
    Table created.                                                    
    
    SQL> alter table crs_arrangements add constraint crs_pk primary key
      2  (nbr_arrangement, product_arrangement, cod_currency);        
    
    Table altered.                                                    
    
    REM generate some data
    
    SQL> select count(*) from crs_arrangements;          
    
      COUNT(*)
    ----------
      10000000                                           
    
    SQL> exec dbms_stats.gather_table_stats('HR', 'CRS_ARRANGEMENTS', cascade=>true);
    
    SQL> ed
    Wrote file afiedt.buf                                                        
    
      1  explain plan for
      2  SELECT * FROM
      3    ( SELECT ARRM.*, ROWNUM FROM CRS_ARRANGEMENTS ARRM
      4      WHERE CONCAT(ARRM.NBR_ARRANGEMENT, ARRM.PRODUCT_ARRANGEMENT) > CONCAT('
    0000000000000000', '0000')
      5* ORDER BY ARRM.NBR_ARRANGEMENT, ARRM.PRODUCT_ARRANGEMENT, ARRM.COD_CURRENCY)
    WHERE ROWNUM < 1000
    SQL> /                                                                       
    
    -------------------
    | Id  | Operation                      | Name             | Rows  | Bytes | Cost
    (%CPU)| Time     |
    --------------------------------------------------------------------------------
    -------------------
    |   0 | SELECT STATEMENT               |                  |   999 | 55944 |  112
    7   (0)| 00:00:14 |
    |*  1 |  COUNT STOPKEY                 |                  |       |       |
           |          |
    |   2 |   VIEW                         |                  |  1000 | 56000 |  112
    7   (0)| 00:00:14 |
    |   3 |    COUNT                       |                  |       |       |
           |          |
    |   4 |     TABLE ACCESS BY INDEX ROWID| CRS_ARRANGEMENTS |   500K|    17M|  112
    7   (0)| 00:00:14 |
    |*  5 |      INDEX FULL SCAN           | CRS_PK           |  1000 |       |   13
    0   (0)| 00:00:02 |      
    

    However, as noted earlier in this thread:

    alter session set NLS_SORT = FRENCH;
    
    |   0 | SELECT STATEMENT        |                  |   999 | 55944 |       | 202
    85   (1)| 00:04:04 |
    |*  1 |  COUNT STOPKEY          |                  |       |       |       |
            |          |
    |   2 |   VIEW                  |                  |   500K|    26M|       | 202
    85   (1)| 00:04:04 |
    |*  3 |    SORT ORDER BY STOPKEY|                  |   500K|    17M|    24M| 202
    85   (1)| 00:04:04 |
    |   4 |     COUNT               |                  |       |       |       |
            |          |
    |*  5 |      TABLE ACCESS FULL  | CRS_ARRANGEMENTS |   500K|    17M|       | 155
    48   (1)| 00:03:07 | 
    

    Can you check your preferences of SQL Developer under database-> NLS and ensure that sorting is set to BINARY? I wonder if either he is on something else in SQL Developer or maybe your by default, the database is not BINARY and squirrel is assigning BINARY when connecting.

  • Oracle query sort by case-sensitivity

    Hi all

    I use the oracle 11g database.

    My use case is that I have a table with the following values

    Name table - test

    product id     productsortdescription
    H58098        ACETAMIDOHYDROXYPHENYLTHIAZOLE
    043994         Alloy .MM.INTHICK
    

    My query is

    select * from test order by productsortdescription;
    

    This query gives the result as it is like

    product id productsortdescription

    H58098 ACETA

    product id productsortdescription

    H58098 ACETA

    produit id productsortdescription

    H58098 ACETA

    product id     productsortdescription

    H58098        ACETA

    product id     productsortdescription
    H58098        ACETAMIDOHYDROXYPHENYLTHIAZOLE
    043994         Alloy .MM.INTHICK
    

    MIDOHYDROXYPHENYLTHIAZOLE

    043994 alloy. MR. INTHICK

    but early output/outcome should be as below:

    product id productsortdescription

    043994Alloy. MR. INTHICK

    H58098 ACETAMIDOHYDROXYPHENYLTHIAZOLE

    like all and ACE in productsortdescription

    l is in a small suitcase to C.

    The NLS Session parameters are as follows

    SELECT * from NLS_SESSION_PARAMETERS;

    NLS_LANGUAGE AMERICAN

    NLS_TERRITORY AMERICA

    NLS_CURRENCY $

    NLS_ISO_CURRENCY AMERICA

    NLS_NUMERIC_CHARACTERS.,.

    NLS_CALENDAR GREGORIAN

    NLS_DATE_FORMAT DD-MON-RR

    NLS_DATE_LANGUAGE AMERICAN

    NLS_SORT BINARY

    NLS_TIME_FORMAT HH.MI. SSXFF AM

    NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM

    NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR

    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR

    NLS_DUAL_CURRENCY $

    BINARY NLS_COMP

    NLS_LENGTH_SEMANTICS BYTES

    NLS_NCHAR_CONV_EXCP FAKE

    Please, help me in this scenario.

    One option is to use the NLSSORT function. Most of the ASCII character set defines the sort lowercase before uppercase but EBCDIC kinds of lowercase before uppercase. So you can use

    with t as)

    Select the id "H58098", "ACETAMIDOHYDROXYPHENYLTHIAZOLE" union str double all the

    SELECT id, ' 043994 ',' alloy. Mr. INTHICK' double str

    )

    SELECT id, str

    t

    NLSSORT order (str, 'NLS_SORT = EBCDIC')
    ;

    ID STR

    ------ ------------------------------

    043994 alloy. MR. INTHICK

    H58098 ACETAMIDOHYDROXYPHENYLTHIAZOLE

    Of course, if your strings can contain non-alphanumeric characters, you should check that the sort of EBCDIC order is acceptable for them as well. To check this, you can use something like

    with t (str, ascii) as long as)

    Select chr(level+32), level + 32 double connect by level<=>

    )

    Select str, ascii from t by NLSSORT (str, 'NLS_SORT = EBCDIC')

    ;

    or simply do a search of the internet on EBCDIC. You can also substitute other kinds of language for EBCDIC and see if any of them meet your needs. See Appendix A of the Guide to support globalization for the list of valid values for NLS_SORT.

    You say that you are on 11g - if you want to say 11.2.x, then you can use the listagg function to get a more compact view of the sort order:

    with t (str, ascii) as long as)

    Select chr(level+32), level + 32 double connect by level<=>

    )

    Select listagg (str) in the Group (order by NLSSORT (str, 'NLS_SORT = EBCDIC')) as EBCDIC_order

    t

    ;

    EBCDIC_order


    ----------------------------------------------------------------------------------------------

    . <(+|&!$*);- %_="">?': #@'="abcdefghijklmnopqr~stuvwxyz[^]{ABCDEFGHI}JKLMNOPQR\STUVWXYZ0123456789

    Kind regards

    Bob

  • SQL query setting

    Hi all
    My env is: oracle 10 g 2 on RHEL4.0, Dell power edge 7 series.
    My Q? is
    is - the AWR report useful to see why the slow query exec?
    Initially this setting must be considered for adjustment for a particular query.
    Kind regards
    KK

    Many things come into play with regard to tuning.

    Initially this setting must be considered for adjustment for a particular query.

    I always start with the execution plan.
    These discussions could help you understand about what you can do:
    When your query takes too long: when your query takes too long...
    How to post a SQL tuning request: HOW TO: post a request for tuning SQL - model poster statement

    In addition, you need to explore the
    Oracle® Database Performance Tuning Guide: http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/toc.htm
    and do some research on this forum and http://asktom.oracle.com should give you more ideas.

  • How Oracle query space on versions

    Hey Geeks,

    I'm doing a spatial query to find the intersection of polygons.

    But the scenario is, for the new user there will be a new version under his name, then he creates features in bentley map and post in Oracle Server.

    Then I need to make the query to find those who intersect but only entities newly created version.

    SELECT c.RECORD_ID FROM VW_LYR_STES c, T_LYR_LND p WHERE c.case_id = 'ABCD019034. '

    AND SDO_RELATE (c.GEOM, p.GEOM, 'mask = anyinteract') = 'TRUE '.

    Any ideas on how to achieve this, queries on the particular version.

    Thanks in advance,

    Ken

    With Workspace Manager you shouldn't really be query the table LT - you should go through the view of high - T_LYR_STES in your case.  You can query the underlying table for the LT, but it's a bit nebulous art.  I use Workspace Manager for years and I've never asked the LT table directly if trying to debug some weird data scenarios.  In the normal course of events, you always pass by the view.

    If the user has not yet merged to the workspace, then you should go to this area of work and request here.  For example

    execute dbms_wm.goToWorkspace(');
    SELECT c.RECORD_ID
    FROM VW_LYR_STES c, T_LYR_LND p
    WHERE c.case_id = 'ABCD019034'
    AND SDO_RELATE(c.GEOM,p.GEOM,'mask=anyinteract') = 'TRUE';
    
  • Oracle query performance.

    In one of my oracle procedure, I make the following query.

    Select plate in amountA from Table1 where Bill_id = billId and CATEGORY = 'A ';

    Select plate in amountB from Table1 where Bill_id = billId and CATEGORY = 'B ';.

    Select plate in amountC from Table1 where Bill_id = billId and CATEGORY = 'C ';

    I want to improve this code block.  I want to make a single request and get the result.

    SELECT
    (Select sum(amount) into amountA from Table1 Where Bill_id=billId and CATEGORY='A') AS x1,
    (Select sum(amount) into amountB from Table1 Where Bill_id=billId and CATEGORY='B') AS x2,
    (Select sum(amount) into amountC from Table1 Where Bill_id=billId and CATEGORY='C') AS x3


    Can be a solution, but I not wish on it.


    Is there a better approach?

    Select sum (decode (category 'A', amount, 0))

    sum (decode(category,'B',amount,0))

    sum (decode(category,'C',amount,0))

    in amountA

    amountB

    amountC

    FROM table1

    where bill_id = billid

    and the category ('A', 'B', 'C');

  • Oracle/query program

    Hello

    I have an EMP table with User_Id, ENO, Org_ID and Dept_ID columns.

    Now, I would like to insert values into the table EMP using under conditions.

    Insert into EMP (user_seq.nextval,

    (select empno from employee where empno in (...) (empnumbers),

    (select org_id in organizations where nom_org = "XXXXXX"),

    (sélectionnez dept_id dans DEPT où dname dans ("MANAGER", "ANALYSTE", "VENDEUR")))

    Please provide to give me the query for the prescription above.

    Thank you.

    969952 wrote:

    No, not like that... Please take a look here...

    Select USERS_SEQUENCE. NEXTVAL, e.emp_id, o.org_id, d.div_id, d.div_code, d.div_dscr

    e users, office_codes o, d div

    where e.div_id = d.div_id

    and e.org_id = o.org_id

    and d.div_dscr ("management SERVICES",

    "cloud Services"

    "Production Support");

    O/P:

    {code}

    NEXTVAL EMP_ID ORG_ID DIV_ID DIV_CODE DIV_DSCR

    27704 00005688 1 1 CS Cloud Services

    27705 00007164 1 1 CS Cloud Services

    27706 00015970 1 1 CS Cloud Services

    27707 00007971 1 1 CS Cloud Services

    27713 00031832 1 2 MS Management Services

    27714 00026775 1 2 MS Management Services

    27715 00016297 1 2 MS Management Services

    27716 00029158 1 2 MS Management Services

    27726 99988547 1 3 PS Production support

    27727 00033034 1 3 PS Production support

    27728 00006303 1 3 PS Production support

    {code}

    2. select * groups;

    O/p:

    GROUP_ID GROUPNAME

    18                   CS

    14                   MS

    15                   PS

    Group_id is the primary key columns.

    Now we're getting somewhere!

    'Re missing you the groups table definition.

    so I'm going to "guess" (again).

    CREATE TABLE groups
       AS
       select 18 group_id, 'CS' group_name from dual union all
             select 14         , 'MS'            from dual union all
             select 15         , 'PS'            from dual ;
    

    We then take your query and result set:

    and a little more continue to massage the data in what you want (that is to say the END result):

    WITH div AS (
                      select 27704 nextval, '00005688' emp_id, 1 org_id, 1 div_id, 'CS' div_code, 'Cloud Services'       div_dscr from dual union all
                      select 27705        , '00007164'       , 1       , 1       , 'CS'         , 'Cloud Services'                from dual union all
                      select 27706        , '00015970'       , 1       , 1       , 'CS'         , 'Cloud Services'                from dual union all
                      select 27707        , '00007971'       , 1       , 1       , 'CS'         , 'Cloud Services'                from dual union all
                      select 27713        , '00031832'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27714        , '00026775'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27715        , '00016297'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27716        , '00029158'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27726        , '99988547'       , 1       , 3       , 'PS'         , 'Production Support'            from dual union all
                      select 27727        , '00033034'       , 1       , 3       , 'PS'         , 'Production Support'            from dual union all
                      select 27728        , '00006303'       , 1       , 3       , 'PS'         , 'Production Support'            from dual
                   )
             select *
               from div d,
                    groups g
              where d.div_code = g.group_name;
    

    NEXTVAL EMP_ID ORG_ID DIV_ID DI DIV_DSCR GROUP_ID GR

    ---------- -------- ---------- ---------- -- ------------------- ---------- --

    27704 00005688 1 1 CS Cloud Services 1 CS

    27705 00007164 1 1 CS Cloud Services 1 CS

    27706 00015970 1 1 CS Cloud Services 1 CS

    27707 00007971 1 1 CS Cloud Services 1 CS

    27713 00031832 1 2 MS 2 MS management services

    27714 00026775 1 2 MS 2 MS management services

    27715 00016297 1 2 MS 2 MS management services

    27716 00029158 1 2 MS 2 MS management services

    27726 99988547 1 3 PS Production Support 3 PS

    27727 00033034 1 3 PS Production Support 3 PS

    27728 00006303 1 3 PS Production Support 3 PS

    11 selected lines.

    Now, we just need to push in the table - I prefer MERGING at this point... I find the easiest to use syntax.

    Select * from groups;

    GROUP_ID GR

    ---------- --

    18 CS

    14 MS

    15 PS

    MERGE INTO groups old
       USING (
             WITH div AS (
                      select 27704 nextval, '00005688' emp_id, 1 org_id, 1 div_id, 'CS' div_code, 'Cloud Services'       div_dscr from dual union all
                      select 27705        , '00007164'       , 1       , 1       , 'CS'         , 'Cloud Services'                from dual union all
                      select 27706        , '00015970'       , 1       , 1       , 'CS'         , 'Cloud Services'                from dual union all
                      select 27707        , '00007971'       , 1       , 1       , 'CS'         , 'Cloud Services'                from dual union all
                      select 27713        , '00031832'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27714        , '00026775'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27715        , '00016297'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27716        , '00029158'       , 1       , 2       , 'MS'         , 'Management Services'           from dual union all
                      select 27726        , '99988547'       , 1       , 3       , 'PS'         , 'Production Support'            from dual union all
                      select 27727        , '00033034'       , 1       , 3       , 'PS'         , 'Production Support'            from dual union all
                      select 27728        , '00006303'       , 1       , 3       , 'PS'         , 'Production Support'            from dual
                   )
             select distinct d.div_id, g.group_id, g.group_name, g.rowid  growid
               from div d,
                    groups g
              where d.div_code = g.group_name
             ) new
          ON ( old.rowid = growid )
       WHEN MATCHED THEN UPDATE
          SET old.group_id = new.div_id;
    

    3 lines merged.

    GROUP_ID GR

    ---------- --

    1 CS

    2 MS

    3 PS

    It when you give us something to work with, we can generate results

  • Hierarchical Oracle query help needed - path between the crux of two brothers and sisters

    I want to find the path between two nodes of oracle hierarchical Table.

    Consider the following case-
    NodeId - ParentId
    =============
    1 > > > > > > 0
    2 > > > > > > 1
    3 > > > > > > 2
    4 > > > > > > 3
    5 > > > > > > 0
    6 > > > > > > 5
    Here I want to query the database table that if there is a path between nodes 3 and 5?
    The previous query you provided work upwards to the root node.

    Here is my expected result, 3-> 2-> 1-> 0-> 5

    Yet once if I have a query in the table to get the path between 1 and 3, I want to get out of the way - next
    1-> 2-> 3

    Therefore, the query works in both cases. Where ADI root can act as an intermediate or no node.

    Can you please guide me how I can get it?

    Thank you.

    Hello

    user13276471 wrote:
    I want to find the path between two nodes of oracle hierarchical Table.

    Consider the following case-
    NodeId - ParentId
    =============
    1 >>>>>> 0
    2 >>>>>> 1
    3 >>>>>> 2
    4 >>>>>> 3
    5 >>>>>> 0
    6 >>>>>> 5
    Here I want to query the database table that if there is a path between nodes 3 and 5?
    The previous query

    What application is this? If you're referering to another thread, then post a link, such as {message identifier: = 10769125}

    you provided work upwards to the root node.

    Here is my expected result, 3--> 2--> 1--> 0--> 5

    Yet once if I have a query in the table to get the path between 1 and 3, I want to get out of the way - next
    1--> 2--> 3

    Therefore, the query works in both cases. Where ADI root can act as an intermediate or no node.

    Can you please guide me how I can get it?

    I think you want something like this:

    WITH     bottom_up_from_src    AS
    (
         SELECT     nodeid
         ,     parentid
         FROM     table_x
         START WITH     nodeid      = :src_nodeid
         CONNECT BY     nodeid   = PRIOR parentid
    )
    ,     bottom_up_from_dst     AS
    (
         SELECT     *
         FROM     bottom_up_from_src
        UNION ALL
         SELECT     parentid     AS nodeid
         ,     nodeid          AS parentid
         FROM     table_x
         WHERE     nodeid     NOT IN (
                                          SELECT  nodeid
                                   FROM    bottom_up_from_src
                                      )
         START WITH     nodeid        = :dst_nodeid
         CONNECT BY     nodeid        = PRIOR parentid
    )
    SELECT      :src_nodeid || SYS_CONNECT_BY_PATH (parentid, '-->')     AS display_path
    FROM       bottom_up_from_dst
    WHERE       parentid     = :dst_nodeid
    START WITH  nodeid     = :src_nodeid
    CONNECT BY  nodeid     = PRIOR parentid
    ;
    

    This will show how you can get it from: src_nodeid at dst_nodeid, moving to the top or to the bottom of a hierarchy at a time step. This will work regardless of the fact that


    • : src_nodeid is the ancestor of the: dst_nodeid, or
    • : src_nodeid is a descendant of: dst_nodeid, or
    • both: src_nodeid and: dst_nodeid are the descendants of another node (e.g. 0).

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0). It is always important, but particularly so with CONNECT BY queries, because each version since Oracle 7 had significant improvements in this area.
    See the FAQ forum {message identifier: = 9360002}

  • Regarding the oracle character set change of EE8MSWIN1250 to AL32UTF8

    Hello

    Today I changed EE8MSWIN1250 in AL32UTF8 characters in oracle 10.2.0.1, who does not, here is the summary of the analysis please give me best suggestion how I can go a head with it.

    Database scan summary report

    Started on time: 2012-01-12 20:50:20
    Elapsed time: 2012-01-12 21:20:54

    Time to end started process ID
    ---------- -------------------- --------------------
    1 2012-01-12 20:54:39 2012-01-12 21:19:57
    2 2012-01-12 20:54:39 2012-01-12 21:20:20
    3 2012-01-12 20:54:39 2012-01-12 21:20:37
    4 2012-01-12 20:54:39 2012-01-12 21:19:57
    5 2012-01-12 20:54:41 2012-01-12 21:19:56
    6 2012-01-12 20:54:39 2012-01-12 21:20:43
    7 2012-01-12 20:54:40 2012-01-12 21:19:56
    8 2012-01-12 20:54:40 2012-01-12 21:19:57
    9 2012-01-12 20:54:41 2012-01-12 21:19:57
    10 2012-01-12 20:54:42 2012-01-12 21:19:56
    11 2012-01-12 20:54:41 2012-01-12 21:20:39
    12 2012-01-12 20:54:42 2012-01-12 21:19:57
    2012-01-13 12 20:54:41 2012-01-12 21:19:56
    14 2012-01-12 20:54:42 2012-01-12 21:19:57
    15 2012-01-12 20:54:40 2012-01-12 21:19:57
    16 2012-01-12 20:54:42 2012-01-12 21:19:56
    17 2012-01-12 20:54:40 2012-01-12 21:19:56
    18 2012-01-12 20:54:43 2012-01-12 21:19:56
    19 2012-01-12 20:54:40 2012-01-12 21:20:49
    2012-01-20 12 20:54:42 2012-01-12 21:20:52
    21 2012-01-12 20:54:40 2012-01-12 21:20:21
    22 2012-01-12 20:54:42 2012-01-12 21:19:57
    23 2012-01-12 20:54:40 2012-01-12 21:19:56
    24 2012-01-12 20:54:43 2012-01-12 21:19:56
    25 2012-01-12 20:54:41 2012-01-12 21:19:56
    26 the 2012-01-12 20:54:43 2012-01-12 21:19:57
    27 2012-01-12 20:54:41 2012-01-12 21:19:56
    28 2012-01-12 20:54:43 2012-01-12 21:19:57
    29 2012-01-12 20:54:42 2012-01-12 21:19:56
    30 2012-01-12 20:54:43 2012-01-12 21:19:57
    31 2012-01-12 20:54:43 2012-01-12 21:19:57
    32 the 2012-01-12 20:54:43 2012-01-12 21:19:57
    ---------- -------------------- --------------------

    [Size of the database]

    Tablespace used free total Expansion
    ------------------------- --------------- --------------- --------------- ---------------
    SYSTEM OF 693, M 50, 26, M 50, 720, 00M 1, 06M
    UNDOTBS1 59, 50M 1 150, 50M 1 210, 00M, 00K
    SYSAUX 438, 19M 11, 81M 450, 00M 8 M 62
    TEMP, 00K, 00K, 00K, K 00
    3 USERS, 13M 1, 00M, 88M 5, 00K
    EXAMPLE OF 77, 38M 22, M 63, 100, 00M 108, 00K
    PDESRV 2 771, 25 M 228, 75 M 3 000, 00 M 758, 03 M
    PDEVEGY 1 394, 06 M 105, 94 M 1 500, 00 M 3, 73 M
    PDEREN 1 270, M 63, 229, 38 M 1 500, 00 M 3, 89 M
    ------------------------- --------------- --------------- --------------- ---------------
    Total 6 707, 63 M 1 777, 38 M 8 485, 00 M 775, 42 M

    Most CLOB size is 3982807 bytes

    [Database scanning settings]

    Value of the parameter
    ------------------------------ ------------------------------------------------
    CSSCAN Version v2.1
    Instance name pdent
    Database Version 10.2.0.1.0
    Comprehensive analysis of database type
    Analyze the data TANK? YES
    Character set of database EE8MSWIN1250
    FROMCHAR EE8MSWIN1250
    TOCHAR AL32UTF8
    Analyze the NCHAR data? NO.
    Size of buffer extraction table 1024000
    Number of process 32
    Convertible data capture? NO.
    ------------------------------ ------------------------------------------------

    [Scanning summary]

    Some character in the data dictionary data are not convertible to the new character set
    Some type of character application data are not convertible to the new character set

    [Summary of the Data Conversion dictionary]

    Immutable data type Convertible truncation with loss
    --------------------- ---------------- ---------------- ---------------- ----------------
    VARCHAR2 5 888 961 19 608 0 0
    CHAR 1 097 0 0 0
    LONG 311 066 579 0 0
    25 204 1 901 0 1 CLOB
    VARRAY 22 366 0 0 0
    --------------------- ---------------- ---------------- ---------------- ----------------
    6 248 694 22 088 0 1-total
    Total in % 99 648 0,352% 0.000 0.000%

    The data dictionary cannot be migrated safely using the CSALTER script

    [Application summary of data Conversion]

    Immutable data type Convertible truncation with loss
    --------------------- ---------------- ---------------- ---------------- ----------------
    8 246 189 1 248 156 800 VARCHAR2 0
    CHAR 1 024 547 0 0 0
    LONG 18 639 30 0 0
    CLOB 615 152 7 410 0 0
    VARRAY 2 019 0 0 0
    --------------------- ---------------- ---------------- ---------------- ----------------
    Total 9 906 546 1 255 596 800 0
    Total 88 745 11 248 0.007 0.000% percentage

    [Cabriolet, truncated and distribution data with loss of Table]

    I stuck half as the summary is too long, I'm very new please help out me.

    Thanks and greetings
    Flo
    -------

    It seems that Data Dictionary has some convertible entries. you need to fix this all the objects individually as suggested in metalink Note 258904.1

    Application object has a truncation and entered convertible. For truncation entries, you must increase the size of the column of the completed columns as shown in the .err log file. For convertible entries, you must perform the export/import. Note 1283764.1

  • some doubts in the conversion of oracle query

    I have to convert the following query in ms access to oracle.

    INSERT INTO the Bill (Reffacture, InvoiceDesc)
    Select a_Invoices! [Ref provider] & "-" & Trim (a_Invoices! [invoice No.]) & "Q" & DatePart ("q", [invDate]) & "-" & DatePart("yyyy",[invDate]) & "SB" as Reffacture.
    Trim (a_Invoice_Desc! [Invoice line Description]) AS a Expr4
    Of a_Invoices a_Invoice_Desc INNER JOIN
    WE (a_Invoices. [Ref provider] is a_Invoice_Desc. [Ref provider])
    AND (a_Invoices. [Invoice No.] is a_Invoice_Desc. [Invoice No.)]
    WHERE (((a_Invoices. [<>ACK GL account]) »--- »)) ;

    for the quarter, I tried with select to_char (to_date ("PRVBTOT", "dd/mm/yy '"), 'Q') as quarterdate of "a_Invoices" - it worked, but how to combine all the

    Hello

    882431 wrote:
    Thanks for the input... I have another doubt based on the date

    I have a date stored in a field of type varchar, n'm copy in the date field

    For example: ' 18/4/2011 0:0:0.0' varchar field is, I tried with "' 2011/4/18 as yyyy/mm/dd ', I can add hh: mm: for the moment (I wasn't looking this), but there is one.0, can someone please tell me how shud convert it..." Sorry if asking a basic question, I already searched but to no avail.

    DATEs do not include fractions of a second. If you don't mind losing fractions of a second, you can simply remove them before pass the string to TO_DATE, like this

    TO_DATE ( REGEXP_REPLACE ( varchar2_column
                    , '\.[0-9]*$'
                    )
         , 'YYYY/MM/DD HH24:MI:SS'
         )
    

    REGEXP_REPLACE will remove the decimal point and any numbers after him. If the string does not contain a decimial, it is correct: REGEXP_REPLACE returns the immutable string in this case.

    If the fraction of a second is important, use a TIMESTAMP instead of a DATE column (and use the TO_TIMESTAMP instead of TO_DATE function).

  • simple oracle query does not not in cf9

    When running in oracle 10 g, this query returns correctly a line:

    WITH myResults AS

    (

    SELECT 1 AS MonNiveau, "someString" AS myData

    OF the double

    )

    SELECT *.

    OF myResults;

    Returns:

    MONNIVEAUMYDATA
    1someString

    When put inside a cfquery in a cf9 page, returns nothing.

    < cfset qryRan = "false" >

    < isDefined ('myQry.recordCount') cfif >

    < cfset qryRan = "true" >

    < / cfif >

    Qry: < cfoutput > #qryRan # < / cfoutput >

    Returns:

    Qry: false

    Yes, the query always had the name the value attribute

    It was certainly the oracle driver, I install v10.1 in parallel with 8.1, recreated my datasources and everything works fine now

    Thanks for the reply

Maybe you are looking for

  • Replacing the battery on Portege Z830 - 10H

    I have a Portege z830 - 10: 00 for a few months. It's battery has already lost 15% of capacity, and I think it is inevitable that the battery will be neet to replace sooner or later. You know, if I am able to replace the battery myself (as in the lar

  • 041wn for laptop HP 15: disabled code

    I forgot the password to powered and keep getting a disabled system code 84888896 Help!

  • 355 G2: password

    Enter the power on password administrator password - don't know system off code 60474922 Need code of the entry. Thank you

  • Transfer of iPhone 4s to Z5 Compact bookmarks

    Using Bridge Sony for Mac I've uploaded most of my content, but not of bookmarks or Notes. Can anyone help with this please? Peter

  • View and edit all keyframes in nested compositions

    I'm looking for a way to view and edit all the keyframes in nested compositions. I want to do because it will allow me to edit all events taking place at the same time, and it's a little embarrassing open each composition to edit keyframes. Is it pos