Newb question: SQL query on an imported table

Hi all. I'm a newb, that this issue will probably tell you!
But I am very interested to familiarize themselves with the Oracle environment.

I installed 10g Express.
I was able to set up a new user (schema) profile?

I created a new table, by importing an Excel file, saved as a CSV file. It has a PK.

When I log in as an administrator, I can see the table 'discovers' the content.
However, I can't run a SQL command with the new table.
It is said Table or view does not exist.

The table is called "Customers" and contains a column called "City" and I type City Select From Customers.

Like the Adminisistrator, I have "given" all the rights for the new table to my profile newly created (schema).
When I connect as long as this new person, I can't see the new table imported into the list of tables, yet alone to run an application or a SQL to it. What did I miss?

Any tips will be appreciated. Glyn gray...

Published by: user12501005 on February 7, 2010 11:26

Hello

You wrote:
The original table is still visible to the diagram of the system, but he reports yet again as saying that the table does not exist when I try SQL.
So is there a reason why a table imported is visible to the user DBA, but SQL does not exist?
The other imported tables, those the DBA can run SQL still aren't visible to other users (schemas).
The DBA has "tuned" EVERYTHING to the default HR schema.
When I connect like HR, I'm unable to find the given table and SQL reports that the table does not exist.

If I understand that you have created a Table in the schema of the SYSTEM, and you cannot question him by SQL.

For example, if you then create a table A in the diagram of SYSTEM, you can view the table A if you connect to the database
SYSTEM or any intended user he has the privilege to CHOOSE ANY TABLE.

If you are connected to a user (for example, HR), which does not have this privilege, you can not query the Table.

If you have a privilege to HR as follows:

connect system/
grant select on A to HR;

Then you can query the Table has to HR:

connect HR/
select * from system.A;

Hope this helps.
Best regards
Jean Valentine

Tags: Database

Similar Questions

  • pl - sql query with index by table errors

    Hello once again

    I'm stuck again with the following query

    I want to display the name of the Department, employee id name count and avg sal

    rec type is rendered
    (
    not a number (8.0).
    DNAME varchar2 (40),
    mgr_nm varchar2 (55),
    d_hc number (8.0).
    SAL number (8.2)
    );
    rec1 is the rec index table directory.
    Start
    for rec1 in)
    Select a1.dnm, a1.nm, b.did, b.hc, b.sal
    Of
    (
    Select d.department_id as did e1.first_name |' '|| E1.last_name like nm, d.department_name as dnm
    of hr.employees e1, hr.departments d
    where e1.department_id = d.department_id) a1.
    (
    Select d.department_id as did, count (e1.employee_id) as hc, avg (e1.salary) as sal
    of hr.employees e1, hr.departments d
    where e1.department_id = d.department_id
    D.department_id group) b
    where a1.did = b.did)
    loop
    dbms_output.put_line (REC1);
    end loop;
    end;
    /

    my error is

    ORA-00900: invalid SQL statement

    Help, please

    Thank you!!!

    Try this:

    begin
      for rec1 in ( select a1.dnm
                    ,      a1.nm
                    ,      b.did
                    ,      b.hc
                    ,      b.sal
                    from ( select d.department_id as did
                           ,      e1.first_name||' '||e1.last_name as nm
                           ,      d.department_name as dnm
                           from   hr.employees e1
                           ,      hr.departments d
                           where  e1.department_id=d.department_id
                         ) a1
                    ,    ( select d.department_id as did
                           ,      count(e1.employee_id) as hc
                           ,      avg(e1.salary)as sal
                           from   hr.employees e1
                           ,      hr.departments d
                           where  e1.department_id=d.department_id
                           group by d.department_id
                          ) b
                    where a1.did=b.did
                  )
      loop
        dbms_output.put_line(rec1.dnm||' - '||rec1.nm||' - '||rec1.did||' - '||rec1.hc||' - '||rec1.sal);
      end loop;
    end;
    /
    

    Edit
    Use code tags when you post for example, keep formatting and indenting.
    See: http://wiki.oracle.com/page/Oracle+Discussion+Forums+FAQ (scroll down a bit)

    Published by: hoek on November 24, 2009 16:01

  • newbie question: sql runs under sqlplus but does not compile in pl/sql?

    I have the following two tables, I have a SQL in pl/sql packages so I can use dbms_jobs to automate it however, I get the compile time error. It seems to me that pl/sql dislikes my sql that works well in sqlplus. Here is the error message and my test case?

    mdb_user@cmd > view the error
    PACKAGE BODY DATA_QUALITY_REPORT_P errors:

    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    10/1 PL/SQL: statement ignored
    13/42 PL/SQL: ORA-00942: table or view does not exist





    create the table S_ORG_EXT
    (
    accnt_type_cd varchar2 (100),
    cust_stat_cd varchar2 (100)
    )
    /

    insert into s_org_ext
    Select column_name, data_type for user_tab_columns where rownum < = 100
    /

    Select * from s_org_ext
    /


    create the table data_quality_report
    (
    RunId number not null,
    report_type number of non-null, - type of report as dup dup or not other measures
    org_level number not null, - organization level nsgn, sgn, shipto
    loc_level number of non-null, - local level by city, by country, by region, grand_total
    name varchar2 (100) not null,-the line output of the tot name.
    Value number not null, - line value of the tot.
    rundate date default sysdate
    )
    /

    create sequence data_quality_report_seq with 1000
    INCREMENT BY 1
    NOCACHE
    NOCYCLE
    /


    insert into data_quality_report
    Select data_quality_report_seq.nextval, 3, 99, 99, accnt_type_cd, cnt, sysdate from
    (
    Select accnt_type_cd, count cnt (*) of S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd by 2 desc order
    )
    /

    Select * from data_quality_report
    /



    truncate table data_quality_report

    CREATE or replace PACKAGE data_quality_report_p AS
    function pull_data return data_quality_report.runid%type;
    END data_quality_report_p;
    /


    create or replace package body data_quality_report_p as
    function pull_data return data_quality_report.runid%type is

    new_rid data_quality_report.runid%type;


    Start
    Select data_quality_report_seq.nextval in the double new_rid;

    insert into data_quality_report
    Select new_rid, 3, 999999, 999999, accnt_type_cd, cnt, sysdate from
    (
    Select accnt_type_cd, count cnt (*) of S_ORG_EXT where cust_stat_cd = 'VARCHAR2' group by accnt_type_cd by 2 desc order
    );


    Return new_rid;
    exception
    When no_data_found then
    DBMS_OUTPUT. Put_line ("NO_DATA_FOUND handles the exception.");
    while others then
    DBMS_OUTPUT. Put_line ("' handling ANOTHER exception.");


    end; -end pull_data

    end data_quality_report_p;
    /

    Hello

    Sorry, I was not clear about that.
    The owner of the package needs direct privileges (not only privileges through a role) to compile the code, whehter it is DEFINE AUTHID or AUTHID CURRENT_USER. Option (3) does not help in this case; my mistake.

    I usually create packages in the same schema tables they use, which was option (2) in my previous message. There may be good reasons why you can't do that; for example, the package may reference multiple schemas tables. In this case, grant the necessary privileges directly to the owner of the whole.

  • pl - sql query with indexes per table

    Hello again,

    I'm stuck with this query, I want to display the full name of all employees, using the HR schema table.

    DECLARE
    Employee_table_struct TYPE IS an ARRAY OF
    HR. Employees.first_name%type
    INDEX OF DIRECTORY;

    employee_table employee_table_struct;

    Employee_cursor CURSOR IS
    SELECT first_name
    OF hr.employees;


    v_row NUMBER: = 1;
    BEGIN

    OPEN employee_cursor;

    LOOP
    OUTPUT WHEN employee_cursor % NOTFOUND;

    DBMS_OUTPUT. Put_line (employee_table (v_row));

    -populated the next time the loop * /.
    v_row: = v_row + 1;
    END LOOP;

    CLOSE Employee_cursor;
    END;
    /

    Its gives me error saying:

    ORA-01403: no data found
    ORA-06512: at line 21

    Help, please
    Thank you

    Why not use a clear FOR the loop?
    It allows you to save saying stuff and it does the same thing, showing first_name for all employees:

    begin
      for rec in ( select first_name
                   from   hr.employees
                 )
      loop
        dbms_output.put_line(rec.first_name);
      end loop;
    end;
    /
    
  • LabVIEW sql query

    HI HI... I'm a student doing a project related to labview. My task is to create a vi, type a user name and password to continue the whole VI.

    As I am a newbie to SQL query language, can anyone help me this?... This isn't like the VI with password lock

    There is a connection of the user called button in my main façade... u by clicking on it, a pop-up window will come out asking you a user name and a password. If the user name and the password is correct, then you can proceed. The problem is that I'm stuck with database...
    Help me pls!

    with respect,

    Ray

    Hello

    You have two cases:

    (1) connect to the database with string (link a string of connection information), and then type something like this:
    Driver is SQL Native Client;. Server = IP. Add.re.SS; UID = username; PW = *** ; Database = MyDatabase (depends on your database)

    (2) use a UDL file (you can configure it to connect to your database, with specific format). Remember that the connection is successful with test button.

    There is a UDL file that you can edit here: C:\Program NIUninstaller Instruments\LabVIEW 2010\examples\database\Labview.udl

    Edit: The connection dropped, you can set the path to an mdb file, and I think you can give the path of your accdb file.

    Kind regards

  • What will happen to the SQL Query based object View (EmployeesVO)

    Schema used: HR

    1. I created a view through SQL Query view object object (Table Employees - EmployeesVO).
    2. Creates an entity of the Employees (EmployeesEO) table object.
    3. In the section EmployeesVO (View object) entity objects, I chose EmployeesEO (entity object).

    What will happen to the View SQL Query object based on (EmployeesVO) will it change to VO based on entities or still to be based query VO.

    It is there because you can still base your query based Vo EO according to Vo.

    After that you base your VO on EO you can now use 'Add the attribute of the entity' to base your attribute on the atrributes of EO. Or if you skilled enough you can manually change the XML to VO

  • Urgent need for sql query

    Hi all
    Sorry I can't speak English very well
    =======================
    I have a table that contains two columns
    table name: total_sal
    column name: hire_date
    column name: salary

    table syntax

    create table total_sal (hire_date date
    number (6.2)) of salary;
    _________________________________________
    Example of data in table format

    hire_date | salary
    01/01/2011 | 1000
    01/02/2011 | 2000
    01/05/2011 | 500
    01/09/2011 | 400


    I NEED a SQL QUERY to display the table, as in this example

    OF | TO|||||||||||| TOTALSALAY
    01/01/2011 | 01/02/2011 | 3000
    07/05/2011 | 01/09/2011 | 900
    |||||||||||||||||||||||||||||||||| 3900
    /* Formatted on 9/23/2011 10:14:40 AM (QP5 v5.149.1003.31008) */
    WITH t
            AS (SELECT TO_DATE ('1/1/2011', 'mm/dd/yyyy') hire_date, 1000 salary
                  FROM DUAL
                UNION
                SELECT TO_DATE ('2/1/2011', 'mm/dd/yyyy'), 2000 FROM DUAL
                UNION
                SELECT TO_DATE ('5/1/2011', 'mm/dd/yyyy'), 500 FROM DUAL
                UNION
                SELECT TO_DATE ('9/1/2011', 'mm/dd/yyyy'), 400 FROM DUAL)
    SELECT "From", "To", totalsalary
      FROM (SELECT hire_date "From",
                   LEAD (hire_date) OVER (ORDER BY hire_date) "To",
                   salary + LEAD (salary) OVER (ORDER BY hire_date) totalsalary,
                   ROW_NUMBER () OVER (ORDER BY hire_date) rn
              FROM t)
     WHERE MOD (rn, 2) = 1
    UNION ALL
    SELECT NULL, NULL, SUM (salary) FROM t
    
    From     To     TOTALSALARY
    1/1/2011     2/1/2011     3000
    5/1/2011     9/1/2011     900
              3900
    
  • Newbie question re: 'break' a path

    Hello... Sorry for the newbie question... I imported this vector image in Illustrator CS5:

    5-3-2012 10-42-59 PM.jpg

    I want to isolate each of the children, so I can use the live paint to color to each child a different color.

    I can do this:

    5-3-2012 10-48-56 PM.jpg

    But I want every child to be a different color. And it's all a way.

    Thank you.

    I find the tool knife difficult to control unless it is a straight line, but you can draw a path and with the selected path only, choose object > path > divide objects below. The image below shows a path that I draw pretty closely with the pencil tool. You can also correct and refine tracks selected by drawing the wire segments of them using the pencil tool and all in using it, holding that alt will smooth the path. To control how the pencil tool behave click twice on the tool in the tool box and it will display a window with options.

    However, in this case, most likely I'll do it in another way.

    First of all, copy the path and paste it at the front 5 times (for 5 children). While the path top of the stack is still selected, change the color of it with the color for the first child, and then using the pencil tool as described above, correct the path to limit it to the silhouette of the first child. The red line on the image below shows where I've drawn with the pencil tool to limit the upper path for the first child. Important during the correction of the paths with the pencil tool is to begin and end the segment based on the original path, or if you start or finish too far from the path, you will create a new path instead of correct that you selected. After correcting the path for the first child, you can select the following path and continue as it fix the paths for each child. Alternatively, instead of paste all roads at the beginning you can stick behind or in front after having corrected the path for each child. Also, except for children at the ends, he must correct the path for other children with both hands. The advantage of this method in the first (with dividing the items below) is that you can move and the path of each child space independently and the hands will look always complete.

  • Single SQL query for the analysis of the date of customs declaration under the table of Stock codes

    Dear all,


    Please tell us a single SQL query for the below,

    We have a Table of Stock as shown below,

    STOCK_TABLE

     

    ITEM_CODE

    (item code)

    BAT_NO

    (lot no.)

    TXN_CODE

    (transaction code)

    DOC_NO

    (number)

    BOE_DT

    (date of the customs declaration)

    I1

    B1

    I1

    I2

    I3

    B70

    I4

    B80

    I5

    B90

    T102

    1234

    JULY 2, 2015

    I6

    B100

    We have to find the date of customs declaration (i.e. the date when the items have come under this particular table) for items that are not attached to any document (that is, who have TXN_CODE, DOC_NO and BOE_DT fields with a NULL value).

    For each item in the table of actions, which is not attached to any document, the customs declaration date is calculated as follows.

    1. If (code section, lot number) combination is present under HISTORY_TABLE, the date of customs declaration will receive the UPDT_DT, the transaction code (TXN_CODE) is an IN or transactions (which can be analyzed from the TRANSACTIONS table).

    2. If (code section, lot number) combination is NOT currently at the HISTORY_TABLE (or) the transaction code respective to item - batch number combination code is an operation then customs declaration date will be the date of the document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD that contains the element of that particular lot.

  • If the case 1 and case 2 fails, our customs declaration date will be the last date of document (DOC_DT) that we receive from one of the 3 tables IN_TABLE_HEAD containing that particular item and the BAT_NO in expected results will be that corresponding to this document, as appropriate, to another NULL.

  • If the case 1 or case 2 is successful, the value of the last field (in the output expected, shown further below) BATCH_YN will be 'Y', because it fits the lot. Otherwise it will be 'n'.
  • HISTORY_TABLE

     

    ITEM_CODE

    BAT_NO

    TXN_CODE

    DOC_NO

    UPDT_DT

    I1

    B1

    T1

    1234

    JANUARY 3, 2015

    I1

    B20

    T20

    4567

    MARCH 3, 2015

    I1

    B30

    T30

    7890

    FEBRUARY 5, 2015

    I2

    B40

    T20

    1234

    JANUARY 1, 2015

    TRANSACTION

     

    TXN_CODE

    TXN_TYPE

    T1

    IN

    T20

    OFF

    T30

    ALL THE

    T50

    IN

    T80

    IN

    T90

    IN

    T60

    ALL THE

    T70

    ALL THE

    T40

    ALL THE

    IN_TABLE_HEAD_1

     

    H1_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H1ID1

    T1

    1234

    JANUARY 1, 2015

    H1ID2

    T70

    1234

    FEBRUARY 1, 2015

    IN_TABLE_ITEM_1

     

    I1_SYS_ID

    H1_SYS_ID

    (foreign key referencing H1_SYS_ID in IN_TABLE_HEAD_1)

    ITEM_CODE

    I1ID1

    H1ID1

    I1

    I1ID2

    H1ID1

    I100

    I1ID3

    H1ID2

    I3

    IN_TABLE_BATCH_1

     

    B1_SYS_ID

    TXN_CODE                DOC_NO

    (now in IN_TABLE_HEAD_1)

    BAT_NO

    B1ID1

    T1

    1234

    B1 / can be empty

    B1ID2

    T70

    1234

    B70

    IN_TABLE_HEAD_2

     

    H2_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H2ID1

    T30

    4567

    FEBRUARY 3, 2015

    H2ID2

    T60

    1234

    JANUARY 3, 2015

    IN_TABLE_ITEM_2

     

    I2_SYS_ID

    H2_SYS_ID

    (foreign key referencing H2_SYS_ID in IN_TABLE_HEAD_2)

    ITEM_CODE

    I2ID1

    H2ID1

    I1

    I2ID2

    H2ID1

    I200

    I2ID3

    H2ID2

    I2

    IN_TABLE_BATCH_2

     

    B2_SYS_ID

    I2_SYS_ID

    (foreign key referencing I2_SYS_ID in IN_TABLE_ITEM_2)

    BAT_NO

    B2ID1

    I2ID1

    B30 / null

    B2ID2

    I2ID2

    B90

    B2ID2

    I2ID3

    B60

    IN_TABLE_HEAD_3

     

    H3_SYS_ID

    (primary key)

    TXN_CODE

    DOC_NO

    DOC_DATE

    H3ID1

    T50

    1234

    JANUARY 2, 2015

    H3ID2

    T80

    1234

    JANUARY 3, 2015

    H3ID3

    T90

    1234

    JANUARY 4, 2015

    H3ID4

    T40

    1234

    AUGUST 5, 2015

    IN_TABLE_ITEM_3

     

    I3_SYS_ID

    H3_SYS_ID

    (foreign key referencing H3_SYS_ID in IN_TABLE_HEAD_3)

    ITEM_CODE

    BAT_NO

    I3ID1

    H31D1

    I2

    B50

    I3ID2

    H3ID2

    I4

    B40

    I3ID3

    H3ID3

    I4

    I3ID4

    H3ID4

    I6

    There is no IN_TABLE_BATCH_3

    Please find below the expected results.

    OUTPUT

     

    ITEM_CODE

    BAT_NO

    TXN_CODE

    DOC_NO

    BOE_DT

    BATCH_YN

    I1

    B1

    T1

    1234

    JANUARY 3, 2015

    THERE

    I1

    B30

    T30

    7890

    FEBRUARY 5, 2015

    N

    I2

    B60

    T60

    1234

    JANUARY 3, 2015

    N

    I3

    B70

    T70

    1234

    FEBRUARY 1, 2015

    THERE

    I4

    T90

    1234

    JANUARY 4, 2015

    N

    I6

    T40

    1234

    AUGUST 5, 2015

    N

    Controls database to create the tables above and insert the records.

    CREATE TABLE stock_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), boe_dt DATE );

    INSERT EN stock_table

       VALUES ('I1', 'B1', '', '', '');

    INSERT EN stock_table

       VALUES ('I1', '', '', '', '');

    INSERT IN stock_table

       VALUES ('I2', '', '', '', '');

    INSERT EN stock_table

       VALUES ('I3', 'B70', '', '', '');

    INSERT EN stock_table

       VALUES ('I4', 'B80', '', '', '');

    INSERT EN stock_table

       VALUES ('I5', 'B90', 'T102', '1234', '02-JUL-2015');

    INSERT EN stock_table

       VALUES ('I6', 'B100', '', '', '');

    SELECT *

    FROM stock_table




     

    CREATE TABLE history_table()item_code VARCHAR2()80),bat_no VARCHAR2()80),txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), updt_dt DATE );

    INSERT IN history_table

       VALUES ('I1', 'B1', 'T1', '1234', '03-JAN-2015');

    INSERT IN history_table

       VALUES ('I1', 'B20', 'T20', '4567', '03-MAR-2015');

    INSERT IN history_table

       VALUES ('I1', 'B30', 'T30', '7890', '05-FEB-2015');

    INSERT IN history_table

       VALUES ('I2', 'B40', 'T20', '1234', '01-JAN-2015');

    SELECT *

    FROM history_table




     

    CREATE TABLE transaction1()txn_code VARCHAR()80),txn_type VARCHAR()80));


    INSERT INTO transaction1

       VALUES ('T1', 'IN');


    INSERT INTO transaction1

       VALUES ('T20', 'OUT');

    INSERT INTO transaction1

       VALUES ('T30', 'ALL');

    INSERT INTO transaction1

       VALUES ('T40', 'ALL');

    INSERT INTO transaction1

       VALUES ('T50', 'IN');

    INSERT INTO transaction1

       VALUES ('T60', 'ALL');

    INSERT INTO transaction1

       VALUES ('T70', 'ALL');

    INSERT INTO transaction1

       VALUES ('T80', 'IN');

    INSERT INTO transaction1

       VALUES ('T90', 'IN');

    SELECT *

    FROM transaction1




     

    CREATE TABLE in_table_head_1()h1_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

    CREATE TABLE in_table_head_2()h2_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

    CREATE TABLE in_table_head_3()h3_sys_id VARCHAR2()80) PRIMARY KEY,txn_code VARCHAR2()80),

    doc_no VARCHAR2 (80), doc_dt DATE );

     

    INSERT IN in_table_head_1

       VALUES ('H1ID1', 'T1', '1234', '01-JAN-2015');

    INSERT IN in_table_head_1

       VALUES ('H1ID2', 'T70', '1234', '01-FEB-2015');

    INSERT IN in_table_head_2

       VALUES ('H2ID1', 'T30', '4567', '03-FEB-2015');

    INSERT IN in_table_head_2

       VALUES ('H2ID2', 'T60', '1234', '03-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID1', 'T50', '1234', '02-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID2', 'T80', '1234', '03-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID3', 'T90', '1234', '05-JAN-2015');

    INSERT IN in_table_head_3

       VALUES ('H3ID4', 'T40', '1234', '05-AUG-2015');




     

    CREATE TABLE in_table_item_1()i1_sys_id VARCHAR2()80) PRIMARY KEY,

    h1_sys_id VARCHAR2 (80) REFERENCES in_table_head_1()h1_sys_id),item_code VARCHAR2()80));

    CREATE TABLE in_table_item_2()i2_sys_id VARCHAR2()80) PRIMARY KEY,

    h2_sys_id VARCHAR2 (80) REFERENCES in_table_head_2()h2_sys_id),item_code VARCHAR2()80));

    CREATE TABLE in_table_item_3(i3_sys_id VARCHAR2(80) PRIMARY KEY,

    h3_sys_id VARCHAR2 (80) REFERENCES in_table_head_3()h3_sys_id),item_code VARCHAR2()80),

    bat_no VARCHAR2 (80));

     

    INSERT IN in_table_item_1

       VALUES ('I1ID1', 'H1ID1', 'I1');

    INSERT IN in_table_item_1

       VALUES ('I1ID2', 'H1ID1', 'I100');

    INSERT IN in_table_item_1

       VALUES ('I1ID3', 'H1ID2', 'I3');

    INSERT IN in_table_item_2

       VALUES ('I2ID1', 'H2ID1', 'I1');

    INSERT IN in_table_item_2

       VALUES ('I2ID2', 'H2ID1', 'I200');

    INSERT IN in_table_item_2

       VALUES ('I2ID3', 'H2ID2', 'I2');

    INSERT IN in_table_item_3

       VALUES ('I3ID1', 'H3ID1', 'I2','B50');

    INSERT IN in_table_item_3

       VALUES ('I3ID2', 'H3ID2', 'I4','B40');

    INSERT IN in_table_item_3

       VALUES ('I3ID3', 'H3ID3', 'I4','');

    INSERT IN in_table_item_3

       VALUES ('I3ID4', 'H3ID4', 'I6','');

    SELECT *

    FROM in_table_item_1

    SELECT *

    FROM in_table_item_2

    SELECT *

    FROM in_table_item_3




     

    CREATE TABLE in_table_batch_1()b1_sys_id VARCHAR2()80) PRIMARY KEY,

    txn_code VARCHAR2 (80), doc_no VARCHAR2 (80), bat_no VARCHAR2 (80));

    CREATE TABLE in_table_batch_2()b2_sys_id VARCHAR2()80) PRIMARY KEY,

    i2_sys_id VARCHAR2 (80) REFERENCES in_table_item_2()i2_sys_id),bat_no VARCHAR2()80));

     

    INSERT IN in_table_batch_1

       VALUES ('B1ID1', 'T1', '1234', 'B1');

    INSERT IN in_table_batch_1

       VALUES ('B1ID2', 'T70', '1234', 'B70');

    INSERT IN in_table_batch_2

       VALUES ('B2ID1', 'I2ID1', 'B30');

    INSERT IN in_table_batch_2

       VALUES ('B2ID2', 'I2ID2', 'B90');

    INSERT IN in_table_batch_2

       VALUES ('B2ID3', 'I2ID3', 'B60');

    Please advise a solution for the same.

    Thank you and best regards,

    Séverine Suresh

    very forced (question subfactoring used to allow easy testing/verification - could work with these test data only)

    with

    case_1 as

    (select s.item_code,

    s.bat_no,

    h.txn_code,

    h.doc_no,

    h.updt_dt boe_dt,

    cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.

    cases where h.txn_code is not null

    and h.doc_no is not null

    and h.updt_dt is not null

    then 'case 1' '.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, boe_dt

    of w_stock_table

    where bat_no is null

    or txn_code is null

    or doc_no is null

    or boe_dt is null

    ) s

    left outer join

    w_history_table h

    On s.item_code = h.item_code

    and s.bat_no = h.bat_no

    and exists (select null

    of w_transaction1

    where txn_code = nvl (s.txn_code, h.txn_code)

    and txn_type in ('IN', 'ALL')

    )

    ),

    case_2 as

    (select s.item_code,

    NVL (s.bat_no, h.bat_no) bat_no.

    NVL (s.txn_code, h.txn_code) txn_code.

    NVL (s.doc_no, h.doc_no) doc_no.

    NVL (s.boe_dt, h.updt_dt) updt_dt.

    cases where s.bat_no = h.bat_no then 'Y' else ' n end batch_yn.

    cases where h.txn_code is not null

    and h.doc_no is not null

    and h.updt_dt is not null

    then 'case 2'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, boe_dt

    of case_1

    where refers_to is null

    ) s

    left outer join

    w_history_table h

    On s.item_code = h.item_code

    and exists (select null

    of w_transaction1

    where txn_code = nvl (s.txn_code, h.txn_code)

    and txn_type in ('IN', 'ALL')

    )

    and not exists (select null

    of case_1

    where item_code = h.item_code

    and bat_no = h.bat_no

    and txn_code = h.txn_code

    and doc_no = h.doc_no

    and updt_dt = h.updt_dt

    )

    ),

    case_31 as

    (select s1.item_code,

    NVL (S1.bat_no, W1.bat_no) bat_no.

    NVL (S1.txn_code, W1.txn_code) txn_code.

    NVL (S1.doc_no, W1.doc_no) doc_no.

    NVL (S1.updt_dt, W1.doc_dt) updt_dt.

    cases where s1.bat_no = w1.bat_no then 'Y' else ' n end batch_yn.

    cases where w1.txn_code is not null

    and w1.doc_no is not null

    and w1.doc_dt is not null

    then "case 31'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s1

    left outer join

    (select i1.item_code, h1.txn_code, h1.doc_no, h1.doc_dt, b1.bat_no

    of w_in_table_item_1 i1

    inner join

    w_in_table_head_1 h1

    On i1.h1_sys_id = h1.h1_sys_id

    inner join

    w_in_table_batch_1 b1

    On h1.txn_code = b1.txn_code

    and h1.doc_no = b1.doc_no

    ) w1

    On s1.item_code = w1.item_code

    ),

    case_32 as

    (select s2.item_code,

    NVL (S2.bat_no, W2.bat_no) bat_no.

    NVL (S2.txn_code, W2.txn_code) txn_code.

    NVL (S2.doc_no, W2.doc_no) doc_no.

    NVL (S2.updt_dt, W2.doc_dt) updt_dt.

    cases where s2.bat_no = w2.bat_no then 'Y' else ' n end batch_yn.

    cases where w2.txn_code is not null

    and w2.doc_no is not null

    and w2.doc_dt is not null

    then "case 32'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s2

    left outer join

    (select i2.item_code, h2.txn_code, h2.doc_no, h2.doc_dt, b2.bat_no

    of w_in_table_item_2 i2

    inner join

    w_in_table_head_2 h2

    On i2.h2_sys_id = h2.h2_sys_id

    inner join

    w_in_table_batch_2 b2

    On i2.i2_sys_id = b2.i2_sys_id

    ) w2

    On s2.item_code = w2.item_code

    ),

    case_33 as

    (select s3.item_code,

    w3.bat_no,

    NVL (S3.txn_code, w3.txn_code) txn_code.

    NVL (S3.doc_no, w3.doc_no) doc_no.

    NVL (S3.updt_dt, w3.doc_dt) updt_dt.

    cases where s3.bat_no = w3.bat_no then 'Y' else ' n end batch_yn.

    cases where w3.txn_code is not null

    and w3.doc_no is not null

    and w3.doc_dt is not null

    then "case 33'.

    end refers_to

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn, refers_to

    of case_2

    where refers_to is null

    ) s3

    left outer join

    (select i3.item_code, h3.txn_code, h3.doc_no, h3.doc_dt, i3.bat_no

    of w_in_table_item_3 i3

    inner join

    w_in_table_head_3 h3

    On i3.h3_sys_id = h3.h3_sys_id

    ) w3

    On s3.item_code = w3.item_code

    )

    Select item_code, bat_no, txn_code, doc_no, boe_dt, batch_yn

    of case_1

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_2

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn,

    ROW_NUMBER() over (partition by item_code of updt_dt desc order) rn

    from (select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_31

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_32

    where refers_to is not null

    Union of all the

    Select item_code, bat_no, txn_code, doc_no, updt_dt, batch_yn

    of case_33

    where refers_to is not null

    )

    )

    where rn = 1

    ITEM_CODE BAT_NO TXN_CODE DOC_NO BOE_DT BATCH_YN
    I1 B1 T1 1234 JANUARY 3, 2015 THERE
    I1 B30 T30 7890 FEBRUARY 5, 2015 N
    I2 B60 T60 1234 JANUARY 3, 2015 N
    I3 B70 T70 1234 FEBRUARY 1, 2015 THERE
    I4 - T90 1234 JANUARY 5, 2015 N
    I6 - T40 1234 AUGUST 5, 2015 N

    Concerning

    Etbin

  • Tables and SQL query

    Hello

    I post this question for clarification. I have a report that is based on a SQL query area.

    Place automatically APEX sql in the tables, all THE results of a query if it is in a region of report? Or y at - it a step that the developer must do to retrieve the columns of the sql query in a table.

    I'm working with checkboxes, and I read up on top of the api APEX_APPLICATION. This part is still unclear.

    Your comments would be appreciated!

    Keisha

    Hi Keisha,

    You should have a read of: [http://download-uk.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/check_box.htm#CHDHFACG] that explains the use of checkboxes on the reports.

    I guess the 'picture' you refer to are APEX_APPLICATION. G_F01 up APEX_APPLICATION. Paintings of G_F50? If so, they are built when you submit the page and are based on elements with attributes of 'name' of 'f01' up to 'f50' in the HTML tags. You don't need to do anything beforehand to create these, which is done automatically for you by the Apex. But, notes, however, that only the checked boxes are presented with a page - so if your username is checked, say, 3 of the 10 boxes, table will contain only 3 points not 10 (with each element of the table that contains the attribute 'value' of a checkbox).

    Andy

  • merge 2 tables (from sql query)

    Ahoj!

    I have 4-sql queries, each with the same structure, but it is not possible to do in a single query. for example:
    Query 1: extension, County a-> table 1 report
    Query 2: extension, County b-> report table 2
    Query 3: extension, County-> report table 3 c
    Question 4: extension, County d-> report table 4

    the result in the apex is now, I have 4 different tables. is it possible to merge these 4 tables table 1 apex?
    extension, number a, b number, County c County d-> report table

    I use the standard sql-report, non-interactive.

    THX,
    Christian

    You can try something like this (not a not test it):

    SELECT A.EXTENSION, $A.COUNT, C.COUNT, B.COUNT, D.COUNT
    Of
    (SELECT the extension, County)
    A
    ) a
    ,
    (SELECT the extension, County)
    B
    ) b
    ,
    (SELECT the extension, County)
    C
    ) c
    ,
    (SELECT the extension, County)
    D
    ) d
    WHERE a.extension = b.extension
    AND b.extension = c.extension
    AND c.extension = d.extension

    Concerning
    Roel

  • SQL query to retrieve a single record for each employee of the following table?

    Hi all

    Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.

    CREATE TABLE xxc_contact)

    empnum NUMBER,

    alternatecontact VARCHAR2 (100),

    relationship VARCHAR2 (10),

    phtype VARCHAR2 (10),

    Phone NUMBER

    );

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)

    expected result:

    EmpNum AlternateContact Relationship PhType Phone       

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Thanks in advance.

    994122 wrote:

    Thank you all, that I got a result

    http://www.orafaq.com/Forum/m/620305/#msg_620305

    By Lalit Kumar B...

    Specifically, the two simple solutions provided were:

    1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).

    SQL > column alternatecontact format A20;

    SQL >

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))

    3 FROM xxc_contact one)

    4. WHEN r = 1

    /

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

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

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)

    3 WHERE phone = rn

    4.

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

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

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Kind regards

    Lalit

  • SQL query: number of occurrence of cellData more thann a column of tabl

    I used table contains the sequence of lines.
    INSERT INTO employee VALUES (105, 'Srinath','vijay','Aeronautics', 27, 33000); 
    INSERT INTO employee VALUES (105, 'Kumble','Anil','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Prabhakar','Manoj','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Srinath','Jawagal','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Jawagal','Srinath','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Mishra','Anil','Aeronautics', 27, 33000);
    INSERT INTO employee VALUES (105, 'Kumble','Prabhakar','Aeronautics', 27, 33000);
    Select first_name separate firstName, count (1) on firstNameCount (partition name) of the employee;
    and I got the following result.
    (Srinath 2, Kumble 2, Prabhakar 1, Jawagal 1, Mishra 1)

    Now I want to examine the second and third column the two and want to number of occurrence of data in the table in these two columns
    (Srinath 3,Kumble 2,Prabhakar 2,Jawagal 2,Mishra 1,vijay 1,Anil 2,Manoj 1)
    As Srinath just 3 times, kumble 2 times, Prabhakar 2 Jawagal 2 times, Mishra 1 time, 1 time vijay times, Anil 2 times and Maury 1 times.

    What will be my sql query?

    Try this

    select name, count(name) over(partition by name) cnt
      from (select first_name from employee union all select last_name from employee)
    
  • SQL query and question CFOUTPUT

    Hello

    I am trying to compare two tables in a database.  I need a few fields in a table of output, to compare a field between the two tables.  Users choose the tables.  I've written a SQL query that does what I need:

    < cfquery name = "getitems" datasource = "snapshot" >
    Select #endtable # .field9 #endtable # .field12, #endtable # .field4, #endtable # .field13, #endtable # .field2, #endtable # .field3, #starttable # .field3
    of #endtable #, #starttable #.
    "where #endtable # .field5 =' #form.field5 #"
    and #starttable # .field2 = #endtable # .field2
    < / cfquery >

    Problem is on the output.  You can see that I am selecting field3 in two tables.  I want also to two output field3 values.

    < cfoutput query = "getitems" >

    #field3 #.

    < / cfoutput >

    This gives me the value that was chosen as #endtable # .field3.

    How can I exit the other - .field3 of # #starttable?

    As mentioned, the table names are variable being passed in the query...  Thank you!

    Peter

    How can I exit the other - .field3 of # #starttable?

    Use an alias to give different names fields IE table.column AS unnom. Otherwise, cfquery do not know what field do you mean when you say "field3".

    Select #endtable # .field9, #endtable # .field12,.

    Be careful when using this type of sql. According to the source of your variables, this can pose a risk of sql injection.

  • SQL query question, how to improve it?

    Hello everyone, I want to create a query with result in the following output. Each first-person Department starts with the letter A and goes to the top like this:

    Name Department
    A Person1 3
    B Person2 3
    C channels3 3
    D Individu4 3
    Person10 E 3

    A 10 Person6
    Person7 10 B
    Person8 C 10

    An Individu4 13
    B Person9 13


    It must be a SQL query, unfortunately no PL/SQL

    I was able to create this query, but its lack. Department_id will be a variable, a person can choose a Department or several departments, so the request varies in size.

    Select department_id, chr (64 + rownum)
    from (select name, department_id
    employees
    where department_id = 3
    order of id_but, naam
    )
    Union
    Select department_id, chr (64 + rownum)
    from (select name, department_id
    employees
    where department_id = 10
    order of id_but, naam
    )
    Union
    Select department_id, chr (64 + rownum)
    from (select name, department_id
    employees
    where department_id = 13
    order of id_but, naam
    )
    order of id_but, naam



    The employees table has the following columns:
    ID, name, department_id

    Can someone help me with this query? Perhaps with the With clause?

    Hello

    You can use the analytic ROW_NUMBER function instead of ROWNUM. Like all analytical functions, ROW_NUMBER can do a calculation separated for each unique value in the PARTITION BY clause:

    select        chr ( 64
               + ROW_NUMBER () OVER ( PARTITION BY  department_id
                             ORDER BY        id_but
                             ,             naam
                           )
               )     AS r_num
    ,        name
    ,       department_id
    from       employees
    where       department_id     IN (3, 10, 13)
    order by  id_but
    ,       naam
    ;
    

    If you do this in SQL * Plus, you can save for the departemnts user input (if it is a list separated by commas as ' 3, 10, 13', or a single value as "99") in a substitution variable (let's call it deptartment_id_list) and use the following WHERE clause:

    where       department_id     IN (&department_id_list)
    

Maybe you are looking for

  • Can I change the list of genres?

    I want to restrict the kinds available with only a few available to select from.

  • What kind of file is this: 46fa66248075f8afb16aa495b4e95d

    I am trying to learn how to clean my pc as much as possible without doing damage LOL.  Can someone tell me what kind of file it is on the c: drive: (46fa66248075f8afb16aa495b4e95d), I searched the internet but nothing.  I guess this is something that

  • Sharing values between pages in NavigationPane

    Hello I'm trying the NavigationPane as well as 2 pages. In the first page, I collect certain values (via text fields, slider, etc.). After that the user fills all the values and click the 'calculate', the second page will be pushed on the screen to d

  • write for the use of google map in my application

    How to use Google maps instead of Blackberry maps in the development of blackberry applications. If you have an idea about this pls share with me.

  • Seeing flashes of power to Compaq CQ45 121TX

    Hello community, For the past 2 weeks, I observed that my Power LED starts to blink when the battery is fully charged and the AC is turned on. I checked the manual and it said that flashing LED power can occur only when the battery is low battery ind