Transpose Tables Using SQL

Hi Guys
I am having a bit of a delimma and am wondering if there is someone out there that could suggest how i could write a SQL statement that would alow me to return data in a certain way,
I have data as follows...
FIrst problemi is the Date in the LogDate COlumn is of Text Type not Date..
Second problem is i need to take this data and transform it to look like the table below
RCDID     EmployeeID     LogDate     LogTime     TerminalID     InOut
41     1      07/23/2006     20:45:02     iGuard#      IN
42     1      07/23/2006     20:46:17     iGuard#      OUT
43     1      07/23/2006     20:48:08     iGuard#      IN
44     1      07/23/2006     20:48:18     iGuard#      OUT
45     1      07/23/2006     20:48:24     iGuard#      IN
46     1      07/23/2006     20:48:30     iGuard#      OUT
47     1      07/23/2006     20:48:36     iGuard#      IN
48     1      07/23/2006     20:48:41     iGuard#      OUT
50     1      07/23/2006     20:49:57     iGuard#      IN
51     1      07/23/2006     20:50:14     iGuard#      OUT
52     1      07/23/2006     20:59:34     iGuard#      IN
53     1      07/23/2006     20:59:40     iGuard#      OUT
Employee ID     Date     In     Out     In      Out     TotalTimeIn
1     23/07/2006     20:35     20:36     20:38     20:39     00:02
Basicaly i need to transpose it..
If anyone has the sql or knows the sql on how to do this i would be very greatful

I have an example too. I don't think George will come back but I've already built it :)
CREATE TABLE TESTING (RCDID NUMBER, EMPLOYEE_ID NUMBER, LOG_DATE DATE, LOG_TIME CHAR(8), TERMINALID VARCHAR2(15), INOUT CHAR(3));
INSERT INTO TESTING VALUES (41, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:45:02', 'iGuard#', 'IN');
INSERT INTO TESTING VALUES (42, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:46:17', 'iGuard#', 'OUT');
INSERT INTO TESTING VALUES (43, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:48:08', 'iGuard#', 'IN');
INSERT INTO TESTING VALUES (44, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:48:18', 'iGuard#', 'OUT');
INSERT INTO TESTING VALUES (45, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:48:24', 'iGuard#', 'IN');
INSERT INTO TESTING VALUES (46, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:48:30', 'iGuard#', 'OUT');
INSERT INTO TESTING VALUES (47, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:48:36', 'iGuard#', 'IN');
INSERT INTO TESTING VALUES (48, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:48:41', 'iGuard#', 'OUT');
INSERT INTO TESTING VALUES (50, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:49:57', 'iGuard#', 'IN');
INSERT INTO TESTING VALUES (51, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:50:14', 'iGuard#', 'OUT');
INSERT INTO TESTING VALUES (52, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:59:34', 'iGuard#', 'IN');
INSERT INTO TESTING VALUES (53, 1, TO_DATE('07/23/2006', 'MM/DD/YYYY'), '20:59:40', 'iGuard#', 'OUT');
create or replace view v_testing as select rcdid, EMPLOYEE_ID employeeid,
to_date(to_char(log_date, 'mm/dd/yyyy')||' '||log_time, 'mm/dd/yyyy hh24:mi:ss') logdate, TERMINALID, INOUT
from TESTING;
select EmployeeID, trunc(login) row_date, login, logout from
(select EmployeeID, LogDate login, lead(LogDate) over (partition by EmployeeID
order by LogDate) logout, inout
from v_testing where InOut in ('IN', 'OUT'))
where inout='IN' order by EmployeeID, login, logout;

Similar Messages

  • Load XML File into temporary tables using sql loader

    Hi All,
    I have an XML file as below. I need to insert the contents into a temporary staging table using sql loader. Please advice how I need to do that.
    For example Portfolios should go into a seperate table, and all the tags inside it should be populated in the columns of the table.
    Family should go into a seperate table and all the tags inside it should be populated in the columns of the table.
    Similarly offer, Products etc.
    - <ABSProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    - <ProductSalesHierachy>
    - <Portfolios>
    - <Portfolio productCode="P1">
      <Attribute name="CatalogProductName" value="Access" />
      <Attribute name="Status" value="Active" />
      </Portfolio>
    - <Portfolio productCode="P2">
      <Attribute name="CatalogProductName" value="Data" />
      <Attribute name="Status" value="Active" />
      </Portfolio>
    - <Portfolio productCode="P3">
      <Attribute name="CatalogProductName" value="Voice" />
      <Attribute name="Status" value="Active" />
      </Portfolio>
    - <Portfolio productCode="P4">
      <Attribute name="CatalogProductName" value="Wireless" />
      <Attribute name="Status" value="Active" />
      </Portfolio>
      </Portfolios>
    - <Families>
    - <Family productCode="F1">
      <Attribute name="CatalogProductName" value="Internet Access Services" />
      <Attribute name="Status" value="Active" />
    - <ParentHierarchy>
      <Item productCode="P1" modelType="Portfolio" />
      </ParentHierarchy>
      </Family>
    - <Family productCode="F2">
      <Attribute name="CatalogProductName" value="Local Access Services" />
      <Attribute name="Status" value="Active" />
    - <ParentHierarchy>
      <Item productCode="P2" modelType="Portfolio" />
      </ParentHierarchy>
      </Family>
      </Families>
    - <SubFamilies>
    - <SubFamily productCode="SF1">
      <Attribute name="CatalogProductName" value="Business Internet service" />
      <Attribute name="Status" value="Active" />
    - <ParentHierarchy>
      <Item productCode="F1" modelType="Family" />
      </ParentHierarchy>
      </SubFamily>
      </SubFamilies>
    - <ProductRefs>
    - <ProductRef productCode="WSP1" modelType="Wireline Sales Product">
      <ActiveFlag>Y</ActiveFlag>
    - <ProductHierarchy>
      <SalesHierarchy family="F1" subFamily="SF1" portfolio="P1" primary="Y" />
      <SalesHierarchy family="F2" portfolio="P2" primary="N" />
      <FinancialHierarchy quotaBucket="Voice" strategicProdCategory="Local Voice" />
      </ProductHierarchy>
      </ProductRef>
    - <ProductRef productCode="MSP2" modelType="Handset">
      <ActiveFlag>Y</ActiveFlag>
    - <ProductHierarchy>
      <SalesHierarchy portfolio="P4" primary="Y" />
      </ProductHierarchy>
      </ProductRef>
      </ProductRefs>
      </ProductSalesHierachy>
    - <Offers>
    - <Offer productCode="ABN">
      <OfferName>ABN</OfferName>
      <OfferDescription>ABN Description</OfferDescription>
    - <Segments>
      <Segment>SCG</Segment>
      <Segment>PCG</Segment>
      </Segments>
      <OfferUpdateDate>2009-11-20</OfferUpdateDate>
      <ActiveFlag>Y</ActiveFlag>
      </Offer>
    - <Offer productCode="OneNet">
      <OfferName>OneNet</OfferName>
      <OfferDescription>OneNet Description</OfferDescription>
    - <Segments>
      <Segment>SCG</Segment>
      <Segment>PCG</Segment>
      <Segment>PCG2</Segment>
      </Segments>
      <OfferUpdateDate>2009-11-20</OfferUpdateDate>
      <ActiveFlag>Y</ActiveFlag>
      </Offer>
      </Offers>
    - <Products>
    - <Product productCode="WSP1" modelType="Wireline Sales Product">
      <ProductName>AT&T High Speed Internet</ProductName>
      <ProductDescription>High Speed Internet</ProductDescription>
      <LegacyCoProdIndicator>SBC</LegacyCoProdIndicator>
      <RevenueCBLCode>1234B</RevenueCBLCode>
      <VolumeCBLCode>4567A</VolumeCBLCode>
      <SAARTServiceIDCode>S1234</SAARTServiceIDCode>
      <MarginPercentRequired>Y</MarginPercentRequired>
      <PercentIntl>%234</PercentIntl>
      <UOM>Each</UOM>
      <PriceType>OneTime</PriceType>
      <ProductStatus>Active</ProductStatus>
      <Compensable>Y</Compensable>
      <Jurisdiction>Everywhere</Jurisdiction>
      <ActiveFlag>Y</ActiveFlag>
    - <Availabilities>
      <Availability>SE</Availability>
      <Availability>E</Availability>
      </Availabilities>
    - <Segments>
      <Segment>SCG</Segment>
      <Segment>PCG</Segment>
      </Segments>
      <VDIndicator>Voice</VDIndicator>
      <PSOCCode>PSOC 1</PSOCCode>
      <USBilled>Y</USBilled>
      <MOWBilled>N</MOWBilled>
      <ProductStartDate>2009-11-20</ProductStartDate>
      <ProductUpdateDate>2009-11-20</ProductUpdateDate>
      <ProductEndDate>2010-11-20</ProductEndDate>
    - <AliasNames>
      <AliasName>AT&T HSI</AliasName>
      <AliasName>AT&T Fast Internet</AliasName>
      </AliasNames>
    - <OfferTypes>
      <OfferType productCode="ABN" endDate="2009-11-20" />
      <OfferType productCode="OneNet" />
      </OfferTypes>
    - <DynamicAttributes>
    - <DynamicAttribute dataType="String" defaultValue="2.5 Mbps" name="Speed">
      <AttrValue>1.5 Mbps</AttrValue>
      <AttrValue>2.5 Mbps</AttrValue>
      <AttrValue>3.5 Mbps</AttrValue>
      </DynamicAttribute>
    - <DynamicAttribute dataType="String" name="TransportType">
      <AttrValue>T1</AttrValue>
      </DynamicAttribute>
      </DynamicAttributes>
      </Product>
    - <Product productCode="MSP2" modelType="Handset">
      <ProductName>Blackberry Bold</ProductName>
      <ProductDescription>Blackberry Bold Phone</ProductDescription>
      <LegacyCoProdIndicator />
      <RevenueCBLCode />
      <VolumeCBLCode />
      <SAARTServiceIDCode />
      <MarginPercentRequired />
      <PercentIntl />
      <UOM>Each</UOM>
      <PriceType />
      <ProductStatus>Active</ProductStatus>
      <Compensable />
      <Jurisdiction />
      <ActiveFlag>Y</ActiveFlag>
    - <Availabilities>
      <Availability />
      </Availabilities>
    - <Segments>
      <Segment>SCG</Segment>
      <Segment>PCG</Segment>
      </Segments>
      <VDIndicator>Voice</VDIndicator>
      <PSOCCode />
      <USBilled />
      <MOWBilled />
      <ProductStartDate>2009-11-20</ProductStartDate>
      <ProductUpdateDate>2009-11-20</ProductUpdateDate>
    - <AliasNames>
      <AliasName />
      </AliasNames>
    - <OfferTypes>
      <OfferType productCode="ABN" />
      </OfferTypes>
    - <DynamicAttributes>
    - <DynamicAttribute dataType="String" name="StlmntContractType">
      <AttrValue />
      </DynamicAttribute>
    - <DynamicAttribute dataType="String" name="BMG 2 year price">
      <AttrValue>20</AttrValue>
      </DynamicAttribute>
    - <DynamicAttribute dataType="String" name="MSRP">
      <AttrValue>40</AttrValue>
      </DynamicAttribute>
    - <DynamicAttribute dataType="String" name="BMGAvailableType">
      <AttrValue />
      </DynamicAttribute>
    - <DynamicAttribute dataType="String" name="ProductId">
      <AttrValue>123456</AttrValue>
      </DynamicAttribute>
    - <DynamicAttribute dataType="String" name="modelSource">
      <AttrValue>product</AttrValue>
      </DynamicAttribute>
      </DynamicAttributes>
      </Product>
      </Products>
      <CatalogChanged>Y</CatalogChanged>
      </ABSProductCatalog>

    Two options that come to mind. Others exist.
    #1 - {thread:id=474031}, which is basically storing the XML in an Object Relational structure for parsing
    #2 - Dump the XML into either an XMLType based table or column and use SQL (with XMLTable) to create a view that parses the data. This would be the same as the view shown in the above post.
    Don't use sql*loader to parse the XML. I was trying to find a post from mdrake about that but couldn't. In short, sql*loader was not build as an XML parser so don't try to use it that way.

  • How to process each records in the derived table which i created using cte table using sql server

    I want to process each row from the CTE table I created, how can I traverse from first row to second row and so on....
    how to process each records in the derived table which i created using  cte table using sql server

    Ideally you would be doing a set based processing rather than traversing row by row as thats more efficient. To answer it specific to your scenario we may need more info. Can you explain with some sample data your exact requirement?
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How do I add more than one column to a table using SQL?

    Hi
    I need to add 3 columns to a table using SQL
    the syntax
    "ALTER TABLE TEST ADD COLUMN newcol1 float";
    works fine - for adding one coumn only.
    For multiple columns I tried various permutations along the lines of
    "ALTER TABLE TEST ADD (COLUMN newcol01 float, COLUMN new2 float,COLUMN new3 float)";
    "ALTER TABLE TIPSTEST ADD COLUMN new1 float"
    "ALTER TABLE TIPSTEST ADD COLUMN new2 float"
    "ALTER TABLE TIPSTEST ADD COLUMN new3 float"
    etc., but this doesn't work.
    From a web search it sounds like SQL can only add one column at a time.
    I have a workaround : create intermediate temporary tables , copying data and adding
    one column at each stage. It seems a fairly awkward way of programming though.
    Am I missing something simple : is there a way to add multiple columns in one go?
    Thanks

    OK : solved an underlying problem with this one myself
    for the code
    String createString;
    createString =  "select COFFEES.* INTO NEWCOFFEES FROM COFFEES"; // example
              Statement stmt;
              try {
                   stmt = a_Globals.database1Connection.createStatement();
                          stmt.executeUpdate(createString);
                   stmt.close();
                   a_Globals.database1Connection.close();
              } catch(SQLException ex) {
                   System.err.println("SQLException: " + ex.getMessage());
              }                    commenting out the line:
    a_Globals.database1Connection.close();
    Allowed the subsequent SQL statement(s) to work OK. Looks like this was the cause of several
    difficulties, preventing me doing several SQL instructions in turn.
    Thanks for the responses.
    Mike2z

  • How to store Multiple Ec\xcels into Table Using sql loder

    Plese guide me to store Multiple Ec\xcels into Table Using sql loder

    I am not clear with your question. Do you want to load multipel Excel Files into a table. If so you can follow this link.
    http://www.orafaq.com/wiki/SQL*Loader_FAQ#Can_one_load_data_from_multiple_files.2F_into_multiple_tables_at_once.3F
    Thanks,
    Karthick.

  • How to get the complete definition of a table using SQL?

    How to get the complete definition code of a table using SQL?

    Something like this ?
    SQL> set long 10000
    SQL> set pages 200
    SQL> select dbms_metadata.get_ddl('TABLE','EMP') from dual;
    DBMS_METADATA.GET_DDL('TABLE','EMP')
      CREATE TABLE "SCOTT"."EMP"
       (    "EMPNO" NUMBER(4,0),
            "ENAME" VARCHAR2(10),
            "JOB" VARCHAR2(9),
            "MGR" NUMBER(4,0),
            "HIREDATE" DATE,
            "SAL" NUMBER(7,2),
            "COMM" NUMBER(7,2),
            "DEPTNO" NUMBER(2,0),
             CONSTRAINT "PK_EMP" PRIMARY KEY ("EMPNO")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"  ENABLE,
             CONSTRAINT "FK_DEPTNO" FOREIGN KEY ("DEPTNO")
              REFERENCES "SCOTT"."DEPT" ("DEPTNO") ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS"
    SQL>Amardeep Sidhu

  • How to find out the script for the table using SQL

    Hi,
    Could any one tell me that how to find out the script for the table using SQL.
    Thanks,
    kamal

    Kamal,
    You can find the SQL query in Advanced tab of Answers
    Thanks,
    Balaa...

  • Create temporary Tables using SQL

    Hello,
    I'm wondering if SAP allows the creation of new Tables without SDK objects,
    I want to create temporary tables using SQL scripts an compile them when an specific addon is connected and erase them when the addon disconnects,
    Do you think this is allowed?.
    thanks,
    Gabriela

    You could always have a second DB to create your temp tables in.  This is the way I've done this, as well as created my own views and stored procedures in it.  No updating of the primary table necessary.  The way I named things was:
    Company_DB - Company Database
    Company_DB-Extern - My own stuff
    Then, in sap, you can just do [Company_DB-Extern]..Object to call it, or you do the same from withing your project.

  • How to show data in a matrix form from a table using SQL

    Dear Friends,
    I have a table with three columns with the following data:
    Market, Product, Date, Value
    Market-A Product-A 01/01/04 34
    Market-A Product-A 01/02/04 33
    Market-A Product-A 01/03/04 67
    Market-A Product-A 01/04/04 64
    Market-A Product-B 01/01/04 34
    Market-A Product-B 01/02/04 36
    Market-A Product-B 01/03/04 77
    Market-A Product-B 01/04/04 32
    Market-B Product-C 01/01/04 25
    Market-B Product-C 01/02/04 56
    Market-B Product-C 01/03/04 45
    Market-B Product-C 01/04/04 68
    Market-B Product-D 01/01/04 78
    Market-B Product-D 01/02/04 75
    Market-B Product-D 01/03/04 32
    Market-B Product-D 01/04/04 35
    I have a requirement where in I have to filter the products based on market and then show in the following format on the screen:
    After filtering based on Market-A (eg) the data should look like:
    01/01/04 01/02/04 01/03/04 01/04/04
    Product-A 34 33 67 64
    Product-B 34 36 77 32
    Kinldy suggest how can I write a query to get the data in this format using SQL
    Thanks & Regards,
    Vinay

    scott@ORA92> -- test data:
    scott@ORA92> SELECT * FROM a_table
      2  /
    Market-A Product-A 01/01/04         34
    Market-A Product-A 01/02/04         33
    Market-A Product-A 01/03/04         67
    Market-A Product-A 01/04/04         64
    Market-A Product-B 01/01/04         34
    Market-A Product-B 01/02/04         36
    Market-A Product-B 01/03/04         77
    Market-A Product-B 01/04/04         32
    Market-B Product-C 01/01/04         25
    Market-B Product-C 01/02/04         56
    Market-B Product-C 01/03/04         45
    Market-B Product-C 01/04/04         68
    Market-B Product-D 01/01/04         78
    Market-B Product-D 01/02/04         75
    Market-B Product-D 01/03/04         32
    Market-B Product-D 01/04/04         35
    scott@ORA92> -- query:
    scott@ORA92> SELECT product,
      2           SUM (DECODE (the_date, to_date ('01/01/2004', 'mm/dd/yyyy'), value)) AS "01/01/04",
      3           SUM (DECODE (the_date, to_date ('01/02/2004', 'mm/dd/yyyy'), value)) AS "01/02/04",
      4           SUM (DECODE (the_date, to_date ('01/03/2004', 'mm/dd/yyyy'), value)) AS "01/03/04",
      5           SUM (DECODE (the_date, to_date ('01/04/2004', 'mm/dd/yyyy'), value)) AS "01/04/04"
      6  FROM   a_table
      7  WHERE  market = 'Market-A'
      8  GROUP  BY product
      9  /
    Product-A         34         33         67         64
    Product-B         34         36         77         32
    scott@ORA92>

  • How to retrive the blob data from a table using sql query

    Hi gurus,
    I have a table which has " BLOB "content in a column .I want to view the data From BLOB column using sql query .It would be helpfull If some one share their idea.
    Regards,
    vardhani.

    You can use data templates.
    See this: http://blogs.oracle.com/xmlpublisher/entry/blob_clob_raw_and_looooong
    http://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
    Thanks,
    Bipuser

  • Internal table value checking in custom table using SQL...

    I have a table which has following fields:
    X1 TABLE (ZCONfig custom table)     
    LIFNR  land1                   
    123      br                    
    234      br                     
    456      br                     
    567      Gr
    and
    X2 TABLE: (Internal table)
    LIFNR:
    234
    567
    123
    Now I want to see if all the field values of LIFNR in internal table X2 (X2-LIFNR) are present in X1 or not.
    Raise error if it is not.
    How do I do this using SQL ? I guess I have to use read statement.
    Please help. Points will be awarded.
    Thanks.
    Regards

    Hi Tushar,
    1 Ya u are right , we need to use READ statement.
    2. Populate X1 (all records)
       in an internal table.
    3. Then Loop at X2
       and compare with X1.
      ( u can also keep an extra field in X2
        of type c, so that if a record is found,
       mark it as X )
    4. try this code (just copy paste)
    REPORT abc.
    DATA : BEGIN OF itab OCCURS 0,
           bukrs LIKE t001-bukrs,
           present TYPE c,
           END OF itab.
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    itab-bukrs = '1000'.
    APPEND itab.
    itab-bukrs = 'X000'.
    APPEND itab.
    SELECT * FROM t001 INTO TABLE t001.
    LOOP AT itab.
      READ TABLE t001 with key bukrs = itab-bukrs.
      IF sy-subrc = 0.
        itab-present = 'X'.
        MODIFY itab.
      ENDIF.
    ENDLOOP.
    BREAK-POINT.
    regards,
    amit m.
    Message was edited by: Amit Mittal

  • Count rows from multiple tables using SQL only

    Hi, I know this has probably been answered before, but I couldn't find the answer anywhere. Please help.
    I'd like count(*) [rows] for all tables in database using SQL only - no PL/SQL
    The result should be something like:
    Table RowCount
    DBA_TABLES 1000
    DBA_USERS 50
    etc.
    Thanks!

    offcource write this script:
    create or replace procedure count_tables (ip_schema VARCHAR2)
    is
    lv_owner VARCHAR2(100);
    lv_table_name VARCHAR2(100);
    lv_sql_statement VARCHAR2(2000);
    lv_count_table NUMBER;
    CURSOR c1 IS
    SELECT owner, table_name
    FROM all_tables
    WHERE owner = ip_schema
    ORDER BY table_name;
    begin
    dbms_output.put_line ('+--------------------------------------------------------------------+');
    dbms_output.put_line ('¦ | | ¦');
    dbms_output.put_line ('¦ Schema Name | Table Name | Number of Rows ¦');
    dbms_output.put_line ('¦ | | ¦');
    dbms_output.put_line ('¦------------------------------------------------------------------¦');
    OPEN c1;
    LOOP
    FETCH c1 INTO lv_owner , lv_table_name;
    EXIT WHEN c1%NOTFOUND;
    lv_sql_statement := 'SELECT count(*) FROM ' || lv_owner || '.' || lv_table_name;
    EXECUTE IMMEDIATE lv_sql_statement INTO lv_count_table;
    IF lv_count_table > 0 THEN
    dbms_output.put_line ('| '||rpad(lv_owner, 14, ' ')||'| '|| rpad(lv_table_name, 32, ' ')||'| '|| rpad(lv_count_table, 16, ' ')||' |');
    -- dbms_output.put_line ('|---------------|---------------------------------|------------------|');
    END IF;
    END LOOP;
    CLOSE c1;
    dbms_output.put_line ('+--------------------------------------------------------------------+');
    exception
    WHEN OTHERS THEN
    dbms_output.put_line ('owner: '||lv_owner||' - table: '||lv_table_name||' - '||sqlerrm);
    end count_tables;
    set serveroutput on size 1000000
    exec count_tables
    drop procedure count_tables;

  • Question about creating new tables using SQL script in WebLogic Server

    Hi,
    I am new to WebLogic and I am following a book Java EE Development with Eclipse published by PACKT Publishing to learn
    Java EE.  I have installed Oracle Enterprise Pack for Eclipse on the PC and I am able to log into the WebLogic Server Administration Console
    and set up a Data Source.  However the next step is to create tables for the database.  The book says that the tables can be created using
    SQL script run from the SQL command line.
    I cannot see any way of inputting SQL script into the WebLogic Server Admistration Console.  Aslo there is no SQL Command line in DOS.
    Thanks  for your help.
    Brian.

    Sounds like you are to run the scripts provided by a tutorial to create the tables, right?  In that case, you may need to install an Oracle client to connect to your database.  The client is automatically installed with the database, so if you have access to the server that hosts the database, you should be able to run SQLplus from there.
    As far as I know, there is no way to run a script from the Admin Console.  I could be wrong, however.

  • DML on nested tables using SQL

    Hello. Can anyone tell me what's wrong??
    SQL> create type mytype as table of varchar2(20);
    Type created
    real: 78
    SQL> declare
    2 c mytype;
    3 begin
    4 select table_name bulk collect into c from user_tables;
    5 delete from table(cast(c as mytype));
    6 end;
    7 /
    declare
    ERROR at line 1:
    ORA-06550: line 5, column 13:
    PL/SQL: ORA-00903: invalid table name
    ORA-06550: line 5, column 1:
    PL/SQL: SQL Statement ignored
    real: 31

    we cannot use variables in regular SQL. It has to be
    dynamic, viz
    begin
    for r in ( select table_name from user_tables )
    loop
    execute immediate ' delete from '||r.table_name;
    d loop;
    end;
    /Cheers, APCyes, but user_tables was only a example. I want to load some data into nested table using BULK COLLECT and then perform some operation on this pl/sql table.
    For example:
    SELECT col BULK COLLECT INTO c FROM a_table;
    SELECT * BULK COLLECT INTO d FROM TABLE(CAST (c AS sql_type));
    --After that c and d contain the same data
    --but for example
    UPDATE TABLE(CAST(c AS sql_type)) Set c.col=...;
    generates invalid table name.
    Why SELECT INTO works, and UPDATE doesn't (all of this was in PL/SQL context, not SQL).

  • How to view /SAPAPO/ tables using SQL Studio question

    Hi,
    This is for Livecache 7.4 on AIX.
    I have installed a SQL Studio 7.6. When I logged using SUPERDBA/admin, I can only see tables owned by SUPERDBA, SYS, and DOMAIN.
    I cannot see any tables owned by SAP<LC Name>. I want to see details about table e.g. /SAPAPO/ORDKEY, which is owed by SAP<LC Name>.
    Is it possible to see it using SQL Studio?
    Please let me know if anybody has any idea about it.
    Regards.
    Sume.

    Hello Sume,
    If you would like to see details about table e.g. /SAPAPO/ORDKEY.
    =>
      Did you check the owner of this table?
    => You could check, for example, in LC10 -> liveCache:Monitoring
    -> Problem Analysis -> Tables/Views/Synonyms ->
       Database Object Schema           SAPLCT
       Name of Database Object          *
       < execute >
       & review if the table /SAPAPO/ORDKEY is listed.
    => If the table is listed, you should be able to run the select statement as SAPLCT user on this table.
    If you are sure that you was using the SAPLCT user, please
    Check if this user has application tables:
    < May be the password was changed from the default sap for the
    Standard liveCache user, you should know it. >
    dbmcli -d LCT -u control,control
    dbmcli on LCT>sql_connect SAPLCT,sap
    dbmcli on LCT> sql_execute select * from users
    dbmcli on LCT> sql_execute select * from users
    < I would like to see what DBA users you have in liveCche &
      when the SAPLCT user was created. >
    dbmcli on LCT>sql_execute select tablename from tables where owner='SAPLCT'
    < If the SAPLCT is the owner of the liveCche application tables,
      and the table /SAPAPO/ORDKEY will be listed. >
    dbmcli on LCT> sql_execute select * from tables where owner='SAPLCT'
    dbmcli on LCT> sql_execute select count(*) from "SAPLCT"."/SAPAPO/ORDKEY"
    < to get number of the entries in the table with owner - SAPLCT >
    dbmcli on LCT>exit
    You could also to check what user did you set for the LCA connection.
    And run //om16 transaction in the liveCache relevant client on the system
    to see the entries in the /sapapo/ordkey & /sapapo/ordmap in liveCache in this client.
    Question: What details you need about table /SAPAPO/ORDKEY?
              Do you have problems on your system?
    Thank you and best regards, Natlia Khlopina

Maybe you are looking for

  • Article MAP issue

    Dear Experts,       Is there any configuration to disallow all transactions on an article for which MAP(Moving Average Price) is zero? Regards, Shanthi

  • Having a sound issue.

    I turned my Macbook on today and eventually found myself at iTunes, picked a song, hit the volume button and something strange happened. When I hit the volume button it comes up as full bars, and I cannot change it from that, it also has a slashed ou

  • Replication in 10g

    I am trying to do the replication(Materialized views) between two remotely located servers. The data replicates from Mat view side to the master but not the other way round. I have run all the necessary scripts in both ends. The same script while run

  • Trouble importing photos LR4

    when try to import a load of photographs i uncheck them all, then try to highlight the ones i want but when i have ticked 5 or 6 the screen just shows the first one in the bunch, whether i have highlighted it or not. the few i have ticked still show

  • WEB CRM INSTALLATION

    Dear all, I am new at SAP Web CRM. I as wondering if any of you would be so kind to give an estimate of how long a standard Web CRM installation may take. I thank you in advance for your support on this matter. Gus