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

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?

  • Profiles of the Oracle Certification program

    In the instructions for application for a Certview account, he says:

    "In the form below, presents the data as it appears in your Pearson view profiles and program Certification Oracle."

    What is a profile of Oracle Certification program?

    I passed 10 Oracle exams given by Prometric. I've never taken a class Oracle nor I took all reviews of the PERSON. Prometric still has an account of my exams, which I can access. Oracle has an account of these reviews so somewhere?

    Kevin Tyson, OCP

    Kevin Tyson wrote:
    In the instructions for application for a Certview account, he says:

    "In the form below, presents the data as it appears in your Pearson view profiles and program Certification Oracle."

    What is a profile of Oracle Certification program?

    I passed 10 Oracle exams given by Prometric. I've never taken a class Oracle nor I took all reviews of the PERSON. Prometric still has an account of my exams, which I can access. Oracle has an account of these reviews so somewhere?

    Kevin Tyson, OCP

    Ofcos, VIEW will get your profile testid and review of Prometric. Don't forget that u must provide the test id, such as SPXXXXXXX / SRXXXXXX, while you are creating a VIEW Oracle account.

  • 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'
           )
    
  • SEO Oracle Forms program units from a library

    Hello
    IM using Oracle Forms 10.1.2.0.2. I stated a procedure in several forms that runs a query and then enables or disables certain elements according to the number of occurrences of the query. The procedure is always the same and it is something like this:

    PROCEDURE QUERY (prBlock IN VARCHAR2, prQuery IN VARCHAR2) IS
    BEGIN

    SET_BLOCK_PROPERTY (prBlock, ONETIME_WHERE, prQuery);
    GO_BLOCK (prBlock);
    EXECUTE_QUERY();

    ENABLE_ITEMS (GET_BLOCK_PROPERTY (prBlock, QUERY_HITS) > 0, prBlock);
    REQUEST TO END;

    Problem is that I want to add this procedure in a library, but I can't find a way to call ENABLE_ITEMS so that each shape activates / deactivates their items appropriate. Is it possible to call a procedure declared in a unit of program forms in a library?

    Thank you.

    Try this

    create an ENABLE_ITEMS() with the same parameters of the library, your code can be

    Start
    null;
    end;
    the procedure should be exactly in the parameters and types that each of them to each shape

    you compile the library
    then attach to the form

    When the library call a procedure forms program units have preference and turn the shape program unit and the ENABLE_ITEMS() of the library is never called

  • 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');

  • 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 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

  • 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

  • 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}

  • How to call button form oracle concurrent program

    Hi all

    I'm working on forms of Oracle 10 g and Oracle Applications: 12.1.2
    already, I have created a simultaneous program (GRN report) and that with Receipt_number and org_id as parameters and the output format is. PDF. Its working fine.

    Whenever customers need the report, they have to give the values of name and then correct setting program simultaneous then refresh, then clicking on the button view exit they see the output.

    Now what I want is from the button of form (named as print report) is it possible to call this concurrent program and when the button is clicked, it will ask to the parameter values after giving all the parameter values and clicking on the SUBMIT/go button it must give the same output (.pdf) as simultaneous program.

    can someone tell me how to get this.

    Thank you

    Kind regards
    Guru

    Hi guru
    You can set up the format of output with the report itself :)
    As a system administrator, change the output format of program competing in "pdf" format Then the click of a button will appear automatically the output .pdf

    Kind regards

    REDA

  • 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

  • Need to improve the performance of oracle query

    Hello
    Currently I wrote the request to get the maximun of XYZ company like this salary

    Select the salary of)
    Select the salary of the employee
    where the company = "XYZ".
    salary desc order)
    where rownum < 2;

    I thought to replace the same with the following query

    Select max (salary)
    the employee
    where the company = "XYZ";

    That one will be faster? can you provide some statistical data. It will be good if you share an oracle for this documentation.

    Thank you
    Khaldi

    Well, that's your requests, your data contained in your database, on your hardware... Anything that can have an impact. So who better to check if there is no difference in performance than yourself?

    Enable SQL tracing, run the statements, then analyze trace (with the help of tkprof or similar) files and look at the differences.

Maybe you are looking for

  • Problem of typing in Firefox!

    Only in Firefox, everything works fine: when I type anything, it starts at the beginning of the keyboard and goes in order: for example if you look at the standard keyboard layout: starts to 1234.then = qwe... and finally,. / and return to 123. Pleas

  • Error message with gobbledygook window at startup - Mac

    For the last 6 months or more, at startup to keep get this window error message when I start my iMac. A gibberish in it: "Bookmark88" (then symbols/gibberish).Below this line: "ApplicationsThunderbird.app" (and then the symbols/gibberish).Below this

  • Satellite Pro P100-327: memory card reader does not read the Memory Stick Duo

    I just received a P100-327aShop http://UK.computers.Toshiba-Europe.com/cgi-bin/ToshibaCSG/JSP/productPage.do?service=UK&PRODUCT_ID=121991&Toshib = true)According to this page, is supposed to have "1 x 5-in-1 Bridge Media slot (supports SD Card, Memor

  • Letters on the keyboard?

    Many of the features of the BDP-S380 blueray player requires that the owner enter text - for example, to make a new channel in Pandora. How do you type letters on the keyboard of the remote control for these models? BTW, the keyboard model is RMT-B10

  • Windows 2008 server services will be automatically collapsed.

    Windows 2008 server services will be automatically collapsed. Here is the system errores. Log name: SystemSource: Service Control ManagerDate: 11/4/2011 11:27:45Event ID: 7034Task category: noLevel: errorKeywords: ClassicUser: n/aComputer: L230SRV10.