Sql query on many child tables

I have an SQL database with many linkesd tables.
If I do:
SELECT [CaseNumber]<o:p></o:p>
,[CenterCode]<o:p></o:p>
,[Outcome]<o:p></o:p>
it will give me all numbers.  However, for example, all outcome verbatium definitions are in a table Outcome Def. same goes for the field CenterCode
How can I write the SQL command to give me the [caseNumber], [CenterCode] description which is in another table and [Outcome] description which is on another table.
Many Thanks,
Raul
Raul Rego

Hello Raul,
you have to join all required tables via there relation (Primary key/foreign key); see
Join Fundamentals
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • How to write sql query with many parameter in ireport

    hai,
    i'm a new user in ireport.how to write sql query with many parameters in ireport's report query?i already know to create a parameter like(select * from payment where entity=$P{entity}.
    but i don't know to create query if more than 1 parameter.i also have parameter such as
    $P{entity},$P{id},$P{ic}.please help me for this.
    thanks

    You are in the wrong place. The ireport support forum may be found here
    http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=showcat&catid=9

  • Give me the sql query which calculte the table size in oracle 10g ecc 6.0

    Hi expert,
    Please  give me the sql query which calculte the table size in oracle 10g ecc 6.0.
    Regards

    Orkun Gedik wrote:
    select segment_name, sum(bytes)/(1024*1024) from dba_segments where segment_name = '<TABLE_NAME>' group by segment_name;
    Hi,
    This delivers possibly wrong data in MCOD installations.
    Depending on Oracle Version and Patchlevel dba_segments does not always have the correct data,
    at any time esp. for indexes right after being rebuild parallel (Even in DB02 because it is using USER_SEGMENTS).
    Takes a day to get the data back in line (never found out, who did the correction at night, could be RSCOLL00 ?).
    Use above statement with "OWNER = " in WHERE for MCOD or connect as schema owner and use USER_SEGMENTS.
    Use with
    segment_name LIKE '<TABLE_NAME>%'
    if you like to see the related indexes as well.
    For partitioned objects, a join from dba_tables / dba_indexes to dba_tab_partitions/dba_ind_partitions to dba_segments
    might be needed, esp. for hash partitioned tables, depending on how they have been created ( partition names SYS_xxxx).
    Volker

  • Loading an Oracle SQL query into an MSSQL table

    I have a select query on an Oracle table. I want to load this data into an MSSQL table.
    Problem is that I cannot create an interim table on the Oracle database (lack of privelages)
    Is there a way to load an Oracle query into the MSSQL table without an interim table?
    Many thanks
    Z

    Yes,
    1) Create an ODI procedure
    2) Create a step inside
    3) at source tab put the oracle query
    4) at target tab put the sql insert code
    Refer to the oracle returned values like "#column_name_from_oracle_query"
    Make sense?
    Cezar Santos
    [www.odiexperts.com]

  • XML Query filtering by child table column

    Hello,
    If anyone can help with this one... it would be nice. I need to make the output of an query to be in the format of XML, but the problem is that the initial filtering needs to be done in the child table.
    Example:
    CREATE TABLE PRIMARY(
    ID NUMBER(19,0),
    CODE_PRIMARY VARCHAR2(32));
    CREATE TABLE SECONDARY(
    ID NUMBER(19,0),
    IDPRIMARY(19,0),
    CODE_SECONDARY VARCHAR2(32));
    INSERT INTO PRIMARY(ID,CODE_PRIMARY)
    VALUES (1,'A');
    INSERT INTO PRIMARY(ID,CODE_PRIMARY)
    VALUES (2,'B');
    INSERT INTO SECONDARY(ID,IDPRIMARY,CODE_SECONDARY)
    VALUES (1,1,'C');
    INSERT INTO SECONDARY(ID,IDPRIMARY,CODE_SECONDARY)
    VALUES (2,1,'D');
    INSERT INTO SECONDARY(ID,IDPRIMARY,CODE_SECONDARY)
    VALUES (3,2,'E');
    Now what we need is to build an XML tree like the following, INNER JOINING PRIMARY and SECONDARY tables with this condition in the where clause -> WHERE SECONDARY.CODE IN ('C','D')
    <result>
    <record>
    <id>1</id>
    <code>A</code>
    <childs>
    <child>
    <id>1</id>
    <idprimary>1</idprimary>
    <codesecondary>C</codesecondary>
    </child>
    <child>
    <id>2</id>
    <idprimary>1</idprimary>
    <codesecondary>D</codesecondary>
    </child>
    </childs>
    </record>
    </result>
    In this example only one record is returned since we only have one record in PRIMARY table that has a child having codesecondary=C or D. The ideia is to get many records... but I think that this is enough for the sake of the example. And the solution is the same.
    Thanks in advance!
    GM

    Found the answer. Used distinct keyword instead of grouping the output table columns. This way XMLAgg didn't broke up the result:
    SELECT
    XMLElement("Processos",
    XmlAgg(XMLElement("Processo",
    XMLForest(T.ID as "Id",T.CODIGO as "Codigo",T.DESCRICAO as "Descricao"),
    XMLElement("Funcionalidades",
    SELECT
    XMLAgg(
    XMLElement("Funcionalidade",F2.ID)
    FROM TWBASEDB.LISTA_UNICA_FUNCIONALIDADE F2
    WHERE F2.ID_processo=T.ID
    and f2.ACTIVIDADE IN ('1_ACTC1','1_ACTC2','1_ACTC3','2_ACTC1')
    from
    select distinct P.ID,P.CODIGO,p.DESCRICAO
    FROM TWBASEDB.LISTA_UNICA_PROCESSOS P
    INNER JOIN TWBASEDB.LISTA_UNICA_FUNCIONALIDADE F ON P.ID=F.ID_PROCESSO
    WHERE ACTIVIDADE IN ('1_ACTC1','1_ACTC2','1_ACTC3','2_ACTC1')
    order by p.id
    ) T

  • How to know how many child tables are present for a parent table

    hi all,
    i created a table USERS in db user pavan (pavan.users (id primary key) ).
    and child tables are may be in the same user pavan or in other users of database also.
    for the other users i given relative grant permissions to access this USERS table and maintain relation to it.
    now, my requirement is how to check the number of references to pavan.users.id
    how many tables are dependent on it.
    thanks in advance.
    regards
    pavan

    Try this
    select a.owner,
           a.constraint_name,
           a.column_name,
           a.table_name,
           c.table_name Referenced_table,
           d.column_name referenced_column
    from
            all_cons_columns a,
            all_constraints b,
            all_constraints c,
            all_cons_columns d
    where a.table_name=b.table_name
    and a.constraint_name=b.constraint_name       
    and b.constraint_type='R'
    and b.r_constraint_name=c.constraint_name
    and c.constraint_name=d.constraint_name
    and a.owner='PAVAN'
    and c.table_name='USERS'
    and d.column_name='ID'

  • Neea a sql query for inverting the table

    Hi,
    I am facing the problem in forming a SQL statement in oracle 10g
    Table structure:
    user field1 field2 field3 field4 field5 field6 .......
    one 11 12 13 14 15 16
    two 21 22 23 24 25 26
    three 31 32 33 34 35 36
    i want a SQL query where the out put is
    field1 11 21 31
    field2 12 22 32
    field3 13 23 33
    field4 14 24 34
    Regards,
    Balu CH

    check this Forums page
    <http://forums.oracle.com/forums/search.jspa?threadID=&q=Rows+to+Columns&objID=f75&dateRange=last90days&userID=&numResults=15>
    will help u.
    Rgds
    Sudar

  • Store SQL query results in db table

    Hi,
    I have a SQL query that produces a report table.
    Is it possible to automatically store the query results (or the report table) as a db table - without interrupting the current report building proces?
    Thanks,
    Dave
    Message was edited by:
    Dave Judge

    Hi Dave,
    You can also insert records into an existing table:
    INSERT INTO TABLEB (colA, colB, colC, etc) SELECT valA, valB, valC, etc FROM VIEWA WHERE etc etc
    This can be done during a page process that runs "Before Header" and you can base your report on the TABLEB. Obviously, you will need to maintain that table to ensure that it is only truncated where necessary, that one user doesn't try to access another user's data on that table and that each time your page is loaded it doesn't try to repopulate the table when you don't need it to.
    Another possiblity is to use a collection - which is user session based
    Andy

  • Using SQL query on user defined table

    Hi all,
    i'am currently working on a project which use user defined table and i would like to know if sap allow us to do insertion/deletion/update on those table using sql query or if we have to use the DI only?
    thanks
    Best regards,

    Hi,
    Definitely you can insert in UDT. You can update but you cant change the Code field after added the rest of the field
    can be updated. You cant delete in UDT but you cant delete anytime in SQL Management Studio.
    THanks.
    CLint

  • App-V Reporting: SQL query for Excel Pivot Table to display App Usage (H/M/S)

    I recently posted this in the Gallery.  If anyone has any modifications or enhancements please feel free to contribute!  One thing that I'd like to be able to add to it is the ability to only display information for applications/packages that are
    still published, so if anyone can figure out a crafty way to do it...  Thanks!
    http://gallery.technet.microsoft.com/App-V-Reporting-SQL-query-6695d3c3

    I recently posted this in the Gallery.  If anyone has any modifications or enhancements please feel free to contribute!  One thing that I'd like to be able to add to it is the ability to only display information for applications/packages that are
    still published, so if anyone can figure out a crafty way to do it...  Thanks!
    http://gallery.technet.microsoft.com/App-V-Reporting-SQL-query-6695d3c3

  • Tuning of SQL query in PO base tables

    Hi all,
    Is there any way to optimize the below query as its taking too many hours to exectute when I pass the dates parameters for long period like eg. 6months to 1 year. Am I missing something...?
    SELECT poh.org_id,
    rcvt.organization_id,
    mcat.segment1,
         pov.vendor_name,
         poh.vendor_id,
         rcvt.transaction_type,
         rcvt.primary_quantity,
    poh.rate,
    pol.unit_price,     
         NULL,
    pvs.attribute8,
    pvs.address_line1,
         pvs.address_line2,
         pvs.city,
         pvs.state,
         pvs.zip,
         pvs.country
    FROM rcv_transactions rcvt,
    mtl_item_categories icat,
    po_line_locations_all poll,
    po_lines_all pol,
    mtl_system_items_b msi,
    po_headers_all poh,
    po_vendors pov,
    mtl_categories_b mcat,
    po_vendor_sites_all      pvs,
    mtl_categories_b mcatedi
    WHERE pov.vendor_id = poh.vendor_id
    AND poh.po_header_id = pol.po_header_id
    AND msi.inventory_item_id = pol.item_id
    AND pov.vendor_id = pvs.vendor_id
    AND pvs.vendor_site_id = poh.vendor_site_id
    AND msi.organization_id = 117
    AND mcatedi.category_id = pol.category_id
    AND poll.po_line_id = pol.po_line_id
    AND icat.organization_id = msi.organization_id +0
    AND icat.inventory_item_id = msi.inventory_item_id +0
    AND icat.category_set_id = 1
    AND icat.category_id = mcat.category_id
    AND rcvt.po_line_location_id = poll.line_location_id
    AND rcvt.transaction_date BETWEEN p_Start_Date AND p_End_Date
    AND ((rcvt.transaction_type = 'RETURN TO VENDOR') OR (rcvt.transaction_type = 'RECEIVE' ))
    AND ((rcvt.transaction_type = 'RECEIVE') OR (rcvt.transaction_type = 'RETURN TO VENDOR')
    AND nvl(rcvt.reason_id, 110) IN
    SELECT reason_id
    FROM mtl_transaction_reasons
    WHERE disable_date IS NULL AND reason_id NOT IN(20 , 21 , 22 , 23, 24 , 25 , 26 ,27 , 28 , 29 , 50 , 51 , 52 , 53 , 54 , 55 ,100 ,102, 103, 122 ,123 , 124)
    Thank you all in advance....

    This is the explain I have in my instance. Looks like there is a different in indexes.
    I have no full table scan on any table in the SQL I sent you. There are the changes I have made:
    Removing the table --, mtl_categories_b mcatedi. It is not necessary to link the categories to PO lines unless you are entering POs without items. That I think you are not (looks like) as you are looking at the transactions line Receive and Retrun to vendor so I assumed these inventory purchases where you are using item. Hence removed that.
    One more possibility is that you are reciving the expense POs also (accruing on receipt for expese purchases). If you want to add that table and condition (AND mcatedi.category_id = pol.category_id) add that and test.
    Mistakenly commented out AND pvs.vendor_site_id = poh.vendor_site_id. You can add that back.
    Added this where condition:
    AND rcvt.organization_id = msi.organization_id
    Reason: You are receiving into organization where the item is assigned to. If you remove this where condition it will do full table scan on the tables you mentioned along with the po_vendors_all. This is what making all the difference.
    Remaining all is your SQL only.
    SQL
    ====================================
    SELECT poh.org_id, rcvt.organization_id, mcat.segment1, pov.vendor_name, poh.vendor_id
    , rcvt.transaction_type, rcvt.primary_quantity, poh.rate, pol.unit_price, NULL, pvs.attribute8
    , pvs.address_line1, pvs.address_line2, pvs.city, pvs.state, pvs.zip, pvs.country
    FROM po_headers_all poh
    , po_lines_all pol
    , po_line_locations_all poll
    , po_vendors pov
    , po_vendor_sites_all pvs
    , rcv_transactions rcvt
    , mtl_system_items_b msi
    , mtl_item_categories icat
    , mtl_categories_b mcat
    , mtl_categories_b mcatedi
    WHERE poh.po_header_id = pol.po_header_id
    AND pol.po_line_id = poll.po_line_id
    AND poh.vendor_id = pov.vendor_id
    AND pov.vendor_id = pvs.vendor_id
    AND pol.item_id = msi.inventory_item_id
    AND rcvt.organization_id = msi.organization_id
    AND pvs.vendor_site_id = poh.vendor_site_id
    AND msi.organization_id = 117
    AND mcatedi.category_id = pol.category_id
    AND msi.organization_id = icat.organization_id
    AND msi.inventory_item_id = icat.inventory_item_id
    AND icat.category_set_id = 1
    AND icat.category_id = mcat.category_id
    AND rcvt.po_line_location_id = poll.line_location_id
    AND trunc(rcvt.transaction_date) BETWEEN ('01-JAN-2008') AND ('31-MAR-2008')
    AND ((rcvt.transaction_type = 'RETURN TO VENDOR') OR (rcvt.transaction_type = 'RECEIVE'))
    AND ( (rcvt.transaction_type = 'RECEIVE')
    OR (rcvt.transaction_type = 'RETURN TO VENDOR')
    AND NVL (rcvt.reason_id, 110) IN (
    SELECT reason_id
    FROM mtl_transaction_reasons
    WHERE disable_date IS NULL
    AND reason_id NOT IN
    (20
    , 21
    , 22
    , 23
    , 24
    , 25
    , 26
    , 27
    , 28
    , 29
    , 50
    , 51
    , 52
    , 53
    , 54
    , 55
    , 100
    , 102
    , 103
    , 122
    , 123
    , 124
    ==================
    Plan
    ======================
    SELECT STATEMENT CHOOSECost: 388 Bytes: 306 Cardinality: 1                                                             
         30 FILTER                                                        
              26 NESTED LOOPS Cost: 388 Bytes: 306 Cardinality: 1                                                   
                   24 NESTED LOOPS Cost: 388 Bytes: 302 Cardinality: 1                                              
                        21 NESTED LOOPS Cost: 387 Bytes: 290 Cardinality: 1                                         
                             18 NESTED LOOPS Cost: 385 Bytes: 150 Cardinality: 1                                    
                                  15 NESTED LOOPS Cost: 384 Bytes: 122 Cardinality: 1                               
                                       12 NESTED LOOPS Cost: 383 Bytes: 91 Cardinality: 1                          
                                            10 NESTED LOOPS Cost: 381 Bytes: 73 Cardinality: 1                     
                                                 8 NESTED LOOPS Cost: 380 Bytes: 64 Cardinality: 1                
                                                      5 NESTED LOOPS Cost: 379 Bytes: 41 Cardinality: 1           
                                                           2 TABLE ACCESS BY INDEX ROWID PO.RCV_TRANSACTIONS Cost: 378 Bytes: 31 Cardinality: 1      
                                                                1 INDEX RANGE SCAN NON-UNIQUE PO.RCV_TRANSACTIONS_N22 Cost: 11 Cardinality: 3,490
                                                           4 TABLE ACCESS BY INDEX ROWID PO.PO_LINE_LOCATIONS_ALL Cost: 1 Bytes: 10 Cardinality: 1      
                                                                3 INDEX UNIQUE SCAN UNIQUE PO.PO_LINE_LOCATIONS_U1 Cardinality: 1
                                                      7 TABLE ACCESS BY INDEX ROWID PO.PO_LINES_ALL Cost: 1 Bytes: 23 Cardinality: 1           
                                                           6 INDEX UNIQUE SCAN UNIQUE PO.PO_LINES_U1 Cardinality: 1      
                                                 9 INDEX UNIQUE SCAN UNIQUE INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Bytes: 9 Cardinality: 1                
                                            11 INDEX RANGE SCAN UNIQUE INV.MTL_ITEM_CATEGORIES_U1 Cost: 2 Bytes: 18 Cardinality: 1                     
                                       14 TABLE ACCESS BY INDEX ROWID PO.PO_HEADERS_ALL Cost: 1 Bytes: 31 Cardinality: 1                          
                                            13 INDEX UNIQUE SCAN UNIQUE PO.PO_HEADERS_U1 Cardinality: 1                     
                                  17 TABLE ACCESS BY INDEX ROWID PO.PO_VENDORS Cost: 1 Bytes: 28 Cardinality: 1                               
                                       16 INDEX UNIQUE SCAN UNIQUE PO.PO_VENDORS_U1 Cardinality: 1                          
                             20 TABLE ACCESS BY INDEX ROWID PO.PO_VENDOR_SITES_ALL Cost: 2 Bytes: 140 Cardinality: 1                                    
                                  19 INDEX RANGE SCAN UNIQUE PO.PO_VENDOR_SITES_U1 Cost: 1 Cardinality: 1                               
                        23 TABLE ACCESS BY INDEX ROWID INV.MTL_CATEGORIES_B Cost: 1 Bytes: 12 Cardinality: 1                                         
                             22 INDEX UNIQUE SCAN UNIQUE INV.MTL_CATEGORIES_B_U1 Cardinality: 1                                    
                   25 INDEX UNIQUE SCAN UNIQUE INV.MTL_CATEGORIES_B_U1 Bytes: 4 Cardinality: 1                                              
              29 FILTER                                                   
                   28 TABLE ACCESS BY INDEX ROWID INV.MTL_TRANSACTION_REASONS Cost: 1 Bytes: 4 Cardinality: 1                                              
                        27 INDEX UNIQUE SCAN UNIQUE INV.MTL_TRANSACTION_REASONS_U1 Cardinality: 1                                         
    Thanks
    Nagamohan

  • SQL Query - Report on multiple table

    Hi Experts
    Firstly, I am an amateur at generating SQL Queries!
    I am trying to create a Report of All Invoices/Credit Notes generated in a date range combined with all open Sales Orders.
    This is my attempt - I am getting all Sales Orders but only want to have Open Sales Orders.
    SELECT T0.[DocNum], T0.[DocType], T0.[cardcode] AS 'Cust. ID', T0.[cardName] AS 'Customer', T0.[TransId], T0.[TaxDate] AS 'Date', T1.[SlpName] AS 'AC Mgr', (T0.[DocTotal] -T0.[VatSum]) AS'NETT', T0.[DocStatus],T0.[U_BusCategory] AS 'Business Cat.', T0.[U_TERM] AS 'TERM', T2.OpprId, T2.Name
    FROM [dbo].[OINV]  T0 INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode 
    LEFT OUTER JOIN OOPR T2 ON T0.U_RTNo = T2.DocNum
    WHERE CONVERT(nchar(8), T0.DocDate, 112) >= '[%0]'  AND CONVERT(nchar(8), T0.DocDate, 112) <= '[%1]'
    UNION
    SELECT T0.[DocNum], T0.[DocType], T0.[cardcode], T0.[cardName], T0.[TransId], T0.[TaxDate] AS 'Date', T1.[SlpName] AS 'AC Mgr', -(T0.[DocTotal] -T0.[VatSum]) AS'NETT', T0.[DocStatus],T0.[U_BusCategory],T0.[U_TERM] AS 'TERM', T2.OpprId AS 'Oppr. ID.', T2.Name AS 'Oppr. Name'
    FROM [dbo].[ORIN]  T0 INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
    LEFT OUTER JOIN OOPR T2 ON T0.U_RTNo = T2.DocNum
    WHERE CONVERT(nchar(8), T0.DocDate, 112) >= '[%0]'  AND CONVERT(nchar(8), T0.DocDate, 112) <= '[%1]'
    UNION
    SELECT T0.[DocNum], T0.[DocType], T0.[CardCode], T0.[CardName], T0.[TransId], T0.[TaxDate], T1.[SlpName], (T0.[DocTotal]-T0.[VatSum]), T0.[DocStatus], T0.[U_BusCategory], T0.[U_TERM], T2.OpprId AS 'Oppr. ID.', T2.Name AS 'Oppr. Name'
    FROM ORDR T0  INNER JOIN OSLP T1 ON T0.SlpCode = T1.SlpCode
    LEFT OUTER JOIN OOPR T2 ON T0.U_RTNo = T2.DocNum
    WHERE CONVERT(nchar(8), T0.DocDate, 112) >= '[%0]'  AND CONVERT(nchar(8), T0.DocDate, 112) <= '[%1]' 
    Any help would be much appreciated
    Derek

    Dear Mr Vard,
    The field in the ORDR table that will tell you if the document is closed or open is the DocStatus.
    C = Closed and O = Open
    You could add another where clause:
    where t0.DocStatus = 'c'
    to the last query you added (the one referring to the ORDR table).
    Please, let me know if this helps you.
    Marcella Rivi
    SAP Business One Forums Team

  • Parse SQL query and extract source tables and columns

    Hello,
    I have a set of SQL queries and I have to extract the source tables and columns from them.
    For example:
    Let's imagine that we have two tables
    CREATE TABLE T1 (col1 number, col2 number, col3 number)
    CREATE TABLE T2 (col1 number, col2 number, col3 number)
    We have the following query:
    SELECT
    T1.col1,
    T1.col2 + T1.col3 as field2
    FROM T1 INNER JOIN T2 ON T1.col2=T2.col2
    WHERE T2.col1 = 1
    So, as a result I would like to have:
    Order Table Column
    1 T1 col1
    2 T1 col2
    2 T1 col3
    Optionally, I would like to have a list of all dependency columns (columns used in "ON", "WHERE" and "GROUP BY" clauses:
    Table Column
    T1 col2
    T2 col1
    T2 col2
    I have tried different approaches but without any success. Any help is appreciated. Thank you in advance.
    Best regards,
    Beroetz

    I have a set of SQL queries and I have to extract the source tables and columns from them. In a recent db version you can use Re: sql injection question for this.

  • Help with SQL Query Involving Three Database Tables

    Hi,
    My SQL is very rusty since I have not touched it in over one year.
    I was given an SQL question in a job interview and I am curious to know the right answer.
    This was a pre-prepared written test and the interviewer did not know the answer.
    There are three database tables: STUDENTS, COURSES and STUDENT_COURSES
    Table STUDENTS has STUDENT_ID and STUDENT_NAME columns.
    Table COURSES has COURSE_ID and COURSE_DESCRIPTION columns.
    Table STUDENT_COURSES has columns STUDENT_ID and COURSE_ID.
    Provide a query that returns all the students that are enrolled in all the courses.
    Thanks,
    Avi.

    It is probably good to say that this task may be solved such way, if database normalized and there are references
    Basically here just is a variant of your solution
    DROP TABLE student_course;
    DROP TABLE student;
    DROP TABLE course;
    CREATE TABLE student
    (student_id NUMBER(9) PRIMARY KEY,
    student_name VARCHAR2(30));
    CREATE TABLE course
    (course_id NUMBER(9) PRIMARY KEY,
    dscr VARCHAR2(100));
    CREATE TABLE student_course
    (student_id NUMBER(9),
    course_id NUMBER(9));
    ALTER TABLE student_course
    ADD CONSTRAINT pk_st_crs PRIMARY KEY
    (student_id, course_id);
    ALTER TABLE student_course
    ADD CONSTRAINT fk_student
      FOREIGN KEY (student_id)
      REFERENCES student(student_id);
    ALTER TABLE student_course
    ADD CONSTRAINT fk_course
      FOREIGN KEY (course_id)
      REFERENCES course(course_id);
    INSERT INTO student
         VALUES (1, 'NAME1');
    INSERT INTO student
         VALUES (2, 'NAME2');
    INSERT INTO student
         VALUES (3, 'NAME3');
    INSERT INTO course
         VALUES (101, 'Desc 1');
    INSERT INTO course
         VALUES (102, 'Desc 2');
    INSERT INTO course
         VALUES (103, 'Desc 3');
    INSERT INTO student_course
         VALUES (1, 101);
    INSERT INTO student_course
         VALUES (1, 102);
    INSERT INTO student_course
         VALUES (2, 101);
    INSERT INTO student_course
         VALUES (2, 103);
    INSERT INTO student_course
         VALUES (3, 101);
    INSERT INTO student_course
         VALUES (3, 102);
    INSERT INTO student_course
         VALUES (3, 103);
    COMMIT ;
    WITH st_crs_cnt AS
         (SELECT   student_id,
                   COUNT (*) tot
              FROM student_course
          GROUP BY student_id)
    SELECT sc.student_id,
           sc.tot
      FROM st_crs_cnt sc
      WHERE sc.tot = (SELECT COUNT (*) FROM course);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to insert a sql query statement in the table

    I have a stored procedure which has different insert,update statements on different tables. I am writing a trigger on these tables such that when the record is updated or inserted in these tables a trigger should fire and should write the old value,new value and the query (insert or update) that caused the trigger to fire in the seperate table. Is there any way to find out the exact query statement that fired the trigger?

    Rather than inventing your own demi-donkeyed solution I recommend you consider using Oracle's Fine-Grained Auditing which does precisely this.
    Cheers, APC

Maybe you are looking for

  • Media Encoder CS6 won't uprez alpha channels

    I have been trying to convert some files i created in both animation codec and AVID codec with alpha from 720p to 1080i/p but if i have the alpha set to rende, it creates a file with the video blown out and edges aliased. Same files if i turn the alp

  • How to select from multiple output tables in the SAP Data Source

    Hi, We're using the SAP Data Source to display SAP data in our portal from the Bapi: BAPI_INFORECORD_GETLIST. When defining the Bapi Meta Data we can select data from one of the two output tables (INFORECORD_GENERAL and INFORECORD_PURCHORG). But we w

  • Performance problem counting ocurrences

    Hi, I have an infocube with 5 characteristics (region,company,distribution center, route, customer) and 3 key figures, I have set one of this KF to average ( values different to 0), i am loading data from 16 months and 70 weeks. In my query i have se

  • Strange box on my images in Photoshop

    Hi I'm getting this box appearing in Photoshop when working on my images. Does anyone know what would cause this?

  • Various newbie questions!

    How do I tell if I am connected to WiFi or on Verizon data?  Is there another symbols selection page that I am missing to use the ^ character?  And perhaps the most frustrating of all, I can not "tap" the video icon to start/stop taking a video.  Tha