Extract data from the table on hourly basis

Hello

I have a table that has two columns date all the hours of the base and the response time. I want to extract data from the date corresponding previous hourly basis with the response time. The data will be loaded into the table every midnight.

for example: today date 23/10/2012
I want to extract data from 22/10/12 00 to the 22/10/12 23

The sub query pulls the date as demanded, but I'm not able to take the time to answer.

with one also
(select min (trunc (lhour)) as mindate, max (trunc (lhour)) as AVG_HR maxdate)
SELECT to_char (maxdate + (level/25), "dd/mm/yyyy hh24") as a LEVEL CONNECTION dates < = * (1) 24;

Please help me on this.

Try this

SELECT * FROM table_nm
 WHERE to_char(hour,'DD') = to_char(SYSDATE-1,'DD')

Tags: Database

Similar Questions

  • extract data from a table to a text file

    I need to extract data from a table to a text file, I twist my output is the following...

    bash-3. $00 vi tap3roamercosts_20110915144318.txt
    lines of 'tap3roamercosts_20110915144318.txt' 393948, 23464348 characters
    ^ LAFGTD | N | 2011090203000001 | 13242514000064 | 1. 0 | 20. 41220 | 02-SEVEN.-11. 01-SEPT.-11. 0 | 13244
    755. 64. 70. 0093794428588 | 0093796234547 | 0 | S2 | E | 412200306902634 | 8. 1. 61500 | 16081 |
    | HW | Call to the Roamer. 0 | I have | Roaming billing Inroamer Plan | 1_0_1 | LKA | N_I_Independent
    the time of day. Rate of Roamer SMST systems | AFGTD20110902030000010001013242514000064 |
    |||||||||||||||||||||

    AFGTD | N | 2011090203000001 | 13242612000044 | 1. 0 | 20. 41220 | 02-SEVEN.-11. 01-SEPT.-11. 0 | 13244
    853. 44. 70. 234. 0093793252818 | 0 | S2 | E | 412200303198150 | 8. 1. 61000 | 12403 | HW | -Ro
    bitter call | 0 | I have | Roaming billing Inroamer Plan | 1_0_1 | N_I_Independent time of Da
    There | Rate of Roamer SMST systems | AFGTD20110902030000010001013242612000044 |
    ||||||||

    AFGTD | N | 2011090203000001 | 13242612000047 | 1. 0 | 20. 41220 | 02-SEVEN.-11. 01-SEPT.-11. 0 | 13244
    853. 47. 70. 234. 0093793252818 | 0 | S2 | E | 412200303198150 | 8. 1. 61000 | 12403 | HW | -Ro
    bitter call | 0 | I have | Roaming billing Inroamer Plan | 1_0_1 | N_I_Independent time of Da
    There | Rate of Roamer SMST systems | AFGTD20110902030000010001013242612000047 |
    ||||||||
    .
    .
    .
    .
    .

    Please help me how to format my output each record in simple lines in oracle sqlplus. Here are the settings I used...

    TERMOUT OFF SET;
    SET ECHO OFF;
    SET LINESIZE 100000;
    THE VALUE OF NEWPAGE 0;
    SET SPACE 0;
    SET PAGESIZE 50000;
    SET FEEDBACK OFF;
    SET THE OFF POSITION;
    SET TRIMSPOOL
    SET THE TAB

    And what was wrong with the answers that you have on your previous thread?

    How to extract data in a text file

    Please do not ask the same question again. If there is a problem with the answers provided, then continue on the same thread that tell people what is the problem.

    Saying that, this is another possibility for you...

    As user sys:

    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    /
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /
    

    As myuser:

    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      --
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    

    This allows the header line and the data to write into files separate if necessary.

    for example

    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    
    PL/SQL procedure successfully completed.
    

    Output.txt file contains:

    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10
    

    The procedure allows for the header and the data to separate files if necessary. Just by specifying the file name "header" will put the header and the data in a single file.

    Adapt to the exit of styles and different types of data are needed.

  • How to export data from the table with the colouring of cells according to value.

    Hi all

    I use jdeveloper 11.1.1.6

    I want to export data from the table with a lot of formatting. as for color cells based on value and so much. How to do this?

    You can find us apache POI-http://poi.apache.org/

    See this http://www.techartifact.com/blogs/2013/08/generate-excel-file-in-oracle-adf-using-apache-poi.html

  • Is it possible to see/get the data from the table to a dump file

    I have files dmp generated using expdp on oracle 11 g...

    expdp_schemas_18MAY2013_1.dmp

    expdp_schemas_18MAY2013_2.dmp

    expdp_schemas_18MAY2013_3.dmp

    Can I use a settings file given below to get the data from the table in the file sql or impdp the only option to load the data of table in database.

    VI test1.par

    USERID = "/ as sysdba".

    DIRECTORY = DATA

    dumpfile=expdp_schemas_18MAY2013%S.dmp

    SCHEMAS = USER1, USER2

    LOGFILE = user_dump_data.log

    SQLFILE = user_dump_data. SQL

    and impdp parfile = test1.par.

    No,

    DataPump cannot retrieve a dumpfile data in a flat file.

    Dean

  • extract data from the generic cursor xy graph

    Hi, I'm new in this Forum.

    In my VI I need to extract the data from the graph xy of one cursor to another, how can I do this?

    I want to extract all the data between the two sliders, to develop.

    Thank you

    In addition to everything said altenbach, you want the slider list: property of the Index. That will tell you where in the table of data, the sliders are.

    The attached VI shows how we can work and also meaningless how it can be with common types of XY data.

    Lynn

  • Insert XML data from the Table-&gt; back to null

    Dear Experts,

    -I have table xml as below:

    Example of CREATE TABLE (XML_spec XMLTYPE);

    Insert in the example
    Select ' < name of Message = "dataStaticInvestor" type = "IncomingMessage" >
    < name of field = "batchReference" > OPENINGBATCH000000 < / field > < List name = "data" >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < = record name "data" >
    < name of field = "externalReference" > 01234567890aaaaaaa < / field >
    < name of field = "participantID" > OD001 < / field >
    < name of field = "participantName" > EQUITY SECURITIES INDONESIA, PT < / field >
    < / recording >
    < / list >
    < / message > ' double.

    Select * example;

    create table hasil1 (c1 varchar2 (500), c2 varchar2 (500), c3 varchar2 (500));

    -This step I create the procedure to insert xml data into the table as the batch.

    DECLARE
    x XmlType;
    BEGIN
    Select XML_SPEC in x for example;

    insert into hasil1
    SELECT
    p.Extract('/Record/Field/@externalReference').getstringval (C1),
    p.Extract('/Record/Field/@participantID').getstringval (C2),
    p.Extract('/Record/Field/@participantName').getstringval () as c3
    TABLE (XMLSequence (Extract(x,'Message/List/Record'))) p;
    commit;
    END;
    /

    -when the result of select hasil1, the output is back 3 rows and 3 columns, but all data is a null *.

    Best regards
    Sigcle

    You don't explain what output you need, but I guess something like this:

    SQL> insert into hasil1 (c1, c2, c3)
      2  select x.c1, x.c2, x.c3
      3  from example t
      4     , xmltable(
      5         'Message/List/Record'
      6         passing t.xml_spec
      7         columns c1 varchar2(500) path 'Field[@name="externalReference"]'
      8               , c2 varchar2(500) path 'Field[@name="participantID"]'
      9               , c3 varchar2(500) path 'Field[@name="participantName"]'
     10       ) x
     11  ;
    
    3 rows inserted
    
    SQL> select * from hasil1;
    
    C1                     C2        C3
    ---------------------- --------- --------------------------------
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
    01234567890aaaaaaa     OD001     EQUITY SECURITIES INDONESIA,PT
     
    
  • wanted to extract data from nested table pl/sql Ref Cursor getting an erro

    create or replace type 'DEPT12' as an object (dno number (2), dname varchar2 (30), varchar2 (50)) loc;

    create or replace type dept_tab in the table in "DEPT12".

    create or replace type 'LOC12' as an object (locno number, loc_name varchar2 (100))

    create or replace type loc_tab in the table of "LOC12.

    create or replace type dept_loc_rec1 as an object (dept_tab, eno number, loc_dt loc_tab dept_dt);

    Create type dept_loc_tb as table of the dept_loc_rec1

    create table dept_loc_tb_bk1 (dept_dt dept_tab, eno number, loc_dt loc_tab)
    NESTED TABLE dept_dt
    STORE AS dept_tab12,
    NESTED TABLE loc_dt
    STORE AS loc_tab12




    insert into dept_loc_tb_bk1 values (dept_tab (dept12(3,'ABD','LOC')
    dept12(4,'ABD','LOC')
    (, dept12(5,'ABD','LOC')), 3, loc_tab (loc12(21,'AAB'),
    loc12(22,'AAB'),
    loc12(23,'AAB')));

    When I try to extract data from Ref cursor to pl/sql table that I get an error ora-06504: pl/sql: return types of the result set of variables or request do not match.
    I created a table nested, as well as the pl/sql nested table object dept_loc_tb and I said the same dept_loc_tb lv_dept_loc_tb, but trying to get in this variable we get an error above.

    Please anyone can solve my problem.
    -----------------
    declare
    type cr is ref cursor;
    cr_obj cr;

    lv_dept_loc_tb dept_loc_tb;

    Start
    Open cr_obj to select dept_dt, eno, dept_loc_tb_bk1 loc_dt;
    collect the fetch cr_obj in bulk in lv_dept_loc_tb;
    close cr_obj;
    end;

    Your query selects 3 distinct columns requires so 3 collections of matching types. You want to treat these 3 columns as an object of type DEPT_LOC_REC1:

    SQL> declare
      2  type cr is ref cursor;
      3  cr_obj cr;
      4
      5  lv_dept_loc_tb dept_loc_tb;
      6
      7  begin
      8  open cr_obj for select dept_dt,eno,loc_dt from dept_loc_tb_bk1;
      9  fetch cr_obj bulk collect into lv_dept_loc_tb;
     10  close cr_obj;
     11  end;
     12  /
    declare
    *
    ERROR at line 1:
    ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
    ORA-06512: at line 9
    
    SQL> declare
      2  type cr is ref cursor;
      3  cr_obj cr;
      4
      5  lv_dept_loc_tb dept_loc_tb;
      6
      7  begin
      8  open cr_obj for select DEPT_LOC_REC1(dept_dt,eno,loc_dt) from dept_loc_tb_bk1;
      9  fetch cr_obj bulk collect into lv_dept_loc_tb;
     10  close cr_obj;
     11  end;
     12  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.
    P.S. discover sys_refcursor.

  • How publish data from the table with some data loss all post in the forum

    I wonder how people are displayed the data in the table or the result of a query with losing them its format from Sqlplus display when they post in the forums of Oracle. I searched on the basis of knowledge of DB but I see no article about it. can you please help me or direct me to this link, I tried different options using code and other tags but nothing has worked, thank you for your help. Thank you.

    Edited by: Ariean October 3, 2011 12:34

    You can click on the link to the FAQ at the top right: http://wikis.sun.com/display/Forums/Forums+FAQ.

  • export data from the table in xml files

    Hello

    This thread to get your opinion on how export data tables in a file xml containing the data and another (xsd) that contains a structure of the table.
    For example, I have a datamart with 3 dimensions and a fact table. The idea is to have an xml file with data from the fact table, a file xsd with the structure of the fact table, an xml file that contains the data of the 3 dimensions and an xsd file that contains the definition of all the 3 dimensions. So a xml file fact table, a single file xml combining all of the dimension, the fact table in the file a xsd and an xsd file combining all of the dimension.

    I never have an idea on how to do it, but I would like to have for your advise on how you would.

    Thank you in advance.

    You are more or less in the same situation as me, I guess, about the "ORA-01426 digital infinity. I tried to export through UTL_FILE, content of the relational table with 998 columns. You get very quickly in this case in these ORA-errors, even if you work with solutions CLOB, while trying to concatinate the column into a CSV string data. Oracle has the nasty habbit in some of its packages / code to "assume" intelligent solutions and converts data types implicitly temporarily while trying to concatinate these data in the column to 1 string.

    The second part in the Kingdom of PL/SQL, it is he's trying to put everything in a buffer, which has a maximum of 65 k or 32 k, so break things up. In the end I just solved it via see all as a BLOB and writing to file as such. I'm guessing that the ORA-error is related to these problems of conversion/datatype buffer / implicit in the official packages of Oracle DBMS.

    Fun here is that this table 998 column came from XML source (aka "how SOA can make things very complicated and non-performing"). I have now 2 different solutions 'write data to CSV' in my packages, I use this situation to 998 column (but no idea if ever I get this performance, for example, using table collections in this scenario will explode the PGA in this case). The only solution that would work in my case is a better physical design of the environment, but currently I wonder not, engaged, as an architect so do not have a position to impose it.

    -- ---------------------------------------------------------------------------
    -- PROCEDURE CREATE_LARGE_CSV
    -- ---------------------------------------------------------------------------
    PROCEDURE create_large_csv(
        p_sql         IN VARCHAR2 ,
        p_dir         IN VARCHAR2 ,
        p_header_file IN VARCHAR2 ,
        p_gen_header  IN BOOLEAN := FALSE,
        p_prefix      IN VARCHAR2 := NULL,
        p_delimiter   IN VARCHAR2 DEFAULT '|',
        p_dateformat  IN VARCHAR2 DEFAULT 'YYYYMMDD',
        p_data_file   IN VARCHAR2 := NULL,
        p_utl_wra     IN VARCHAR2 := 'wb')
    IS
      v_finaltxt CLOB;
      v_v_val VARCHAR2(4000);
      v_n_val NUMBER;
      v_d_val DATE;
      v_ret   NUMBER;
      c       NUMBER;
      d       NUMBER;
      col_cnt INTEGER;
      f       BOOLEAN;
      rec_tab DBMS_SQL.DESC_TAB;
      col_num NUMBER;
      v_filehandle UTL_FILE.FILE_TYPE;
      v_samefile BOOLEAN      := (NVL(p_data_file,p_header_file) = p_header_file);
      v_CRLF raw(2)           := HEXTORAW('0D0A');
      v_chunksize pls_integer := 8191 - UTL_RAW.LENGTH( v_CRLF );
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      --
      FOR j IN 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
        WHEN 1 THEN
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,4000);
        WHEN 2 THEN
          DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
        WHEN 12 THEN
          DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,4000);
        END CASE;
      END LOOP;
      -- --------------------------------------
      -- This part outputs the HEADER if needed
      -- --------------------------------------
      v_filehandle := UTL_FILE.FOPEN(upper(p_dir),p_header_file,p_utl_wra,32767);
      --
      IF p_gen_header = TRUE THEN
        FOR j        IN 1..col_cnt
        LOOP
          v_finaltxt := ltrim(v_finaltxt||p_delimiter||lower(rec_tab(j).col_name),p_delimiter);
        END LOOP;
        --
        -- Adding prefix if needed
        IF p_prefix IS NULL THEN
          UTL_FILE.PUT_LINE(v_filehandle, v_finaltxt);
        ELSE
          v_finaltxt := 'p_prefix'||p_delimiter||v_finaltxt;
          UTL_FILE.PUT_LINE(v_filehandle, v_finaltxt);
        END IF;
        --
        -- Creating creating seperate header file if requested
        IF NOT v_samefile THEN
          UTL_FILE.FCLOSE(v_filehandle);
        END IF;
      END IF;
      -- --------------------------------------
      -- This part outputs the DATA to file
      -- --------------------------------------
      IF NOT v_samefile THEN
        v_filehandle := UTL_FILE.FOPEN(upper(p_dir),p_data_file,p_utl_wra,32767);
      END IF;
      --
      d := DBMS_SQL.EXECUTE(c);
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT
      WHEN v_ret    = 0;
        v_finaltxt := NULL;
        FOR j      IN 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
          WHEN 1 THEN
            -- VARCHAR2
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            v_finaltxt := v_finaltxt || p_delimiter || v_v_val;
          WHEN 2 THEN
            -- NUMBER
            DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
            v_finaltxt := v_finaltxt || p_delimiter || TO_CHAR(v_n_val);
          WHEN 12 THEN
            -- DATE
            DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
            v_finaltxt := v_finaltxt || p_delimiter || TO_CHAR(v_d_val,p_dateformat);
          ELSE
            v_finaltxt := v_finaltxt || p_delimiter || v_v_val;
          END CASE;
        END LOOP;
        --
        v_finaltxt               := p_prefix || v_finaltxt;
        IF SUBSTR(v_finaltxt,1,1) = p_delimiter THEN
          v_finaltxt             := SUBSTR(v_finaltxt,2);
        END IF;
        --
        FOR i IN 1 .. ceil( LENGTH( v_finaltxt ) / v_chunksize )
        LOOP
          UTL_FILE.PUT_RAW( v_filehandle, utl_raw.cast_to_raw( SUBSTR( v_finaltxt, ( i - 1 ) * v_chunksize + 1, v_chunksize ) ), TRUE );
        END LOOP;
        UTL_FILE.PUT_RAW( v_filehandle, v_CRLF );
        --
      END LOOP;
      UTL_FILE.FCLOSE(v_filehandle);
      DBMS_SQL.CLOSE_CURSOR(c);
    END create_large_csv;
    
  • Export data from the table

    Hello. Is it possible to export data from a table in Oracle using SQL Loader? If Yes, can you tell a good examples?

    Hello

    Hello. Is it possible to export data from a table in Oracle using SQL Loader?

    No, with SQL * Loader, you can load data from external files into tables not export.

    coil c:\temp\empdata.txt
    sqlplus abc.sql (assumes that abc.sql runs select * from emp)
    spool off

    It cannot work like this, because the declaration of the COIL is not recognized outside the SQL * Plus the term.

    But, you can include the statement of the COIL in abc.sql like this:

    spool c:\temp\empdata.txt
    select * from emp;
    spool off
    

    Then, you just have to run the SQL script as follows:

    sqlplus  @abc.sql 
    

    However, I advise you to use Oracle SQL Developer, this is a free tool and with it you can export a Table in several types of format (html, xml, csv, xls,...).

    Please find attached a link to this tool:

    http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/Overview/index.html

    Hope this helps.
    Best regards
    Jean Valentine

  • Update on the table by extracting the data from the table even under certain conditions

    Hi Experts,

    I have the table EMP which currently has 6 entries.

    EMP_SYS BATCH_NO JOIN_DATE LOGIN_ID STATUS FLAG

    1 FEBRUARY 10 PROD 84 Y IND123 ABC

    DEV 1-23 APRIL 98 Y IND123 ABC

    2 12 APRIL PROD 98 Y IND123 ABC

    2 2 APRIL DEV 98 Y IND123 ABC

    3 13 APRIL PROD 98 Y IND123 ABC

    3 3 APRIL DEV 98 Y IND123 ABC

    CONDITION: I need to take lines which has the minimum BATCH_NO for each of the EMP_SYS

    for example,.

    1 FEBRUARY 10 PROD 84 Y IND123 ABC

    DEV 1-23 APRIL 98 Y IND123 ABC

    For the above two lines, I need to update the status of DEF. How to select this criterion and update in the same query?

    Currently, I used the query to select the minimum BATCH_NO for each of the EMP_SYS below.

    SELECT EMP_SYS, BATCH_NO, JOIN_DATE, FLAG, LOGIN_ID, STATUS

    Of

    (

    EMP_SYS, BATCH_NO, JOIN_DATE, FLAG, LOGIN_ID, STATUS, SELECT ROW_NUMBER)

    COURSE NR (PARTITION BY ORDER OF EMP_SYS OF EMP_SYS)

    FROM EMP

    WHEN STATUS = 'ABC' AND FLAG = "Y".

    )

    WHERE

    NR = 1;

    If I try to use the update on the above query statement... It updates every 6 rows instead of 2 rows.

    Please suggest me a way to update only the two lines that has the minimum BATCH_NO for each of the EMP_SYS.

    But is possible to write the query without using the Group of?

    Update e EMP

    set STATUS = "DEF".

    where BATCH_NO = (select min (BATCH_NO) from EMP I where STATUS = 'ABC' AND FLAG = 'Y' and i.emp_sys = e.emp_sys)

  • extracting data from the CLOB using materialized views

    Hello

    We have xml data from clob which I have a requirement to extract (~ 50 attributes) on a daily basis, so we decided to use materialized views with refreshes full (open good suggestions)

    A small snippet of code

    CREATE THE MWMRPT MATERIALIZED VIEW. TASK_INBOUND

    IMMEDIATE CONSTRUCTION

    FULL REFRESH ON DEMAND

    WITH ROWID

    AS

    SELECT M.TASK_ID, M.BO_STATUS_CD, b.*

    OF CISADM. M1_TASK m,

    XMLTABLE (' / a ' XMLPARSE PASSING ())

    CONTENT '< a > | M.BO_DATA_AREA | "< /a >."

    ) COLUMNS

    serviceDeliverySiteId varchar2 (15) PATH

    "cmPCGeneralInfo/serviceDeliverySiteId"

    serviceSequenceId varchar2 (3) PATH "cmPCGeneralInfo/serviceSequenceId"

    completedByAssignmentId varchar2 (50) PATH "completedByAssignmentId."

    Cust_id varchar2 (10) PATH "cmPCCustomerInformation/customerId,"

    ACCT_SEQ varchar2 (5) PATH "customerInformation/accountId"

    AGRMT_SEQ varchar2 (5) PATH cmPCCustomerAgreement/agreementId"."

    COLL_SEQ varchar2 (5) PATH "cmPCGeneralInfo/accountCollectionSeq"

    REVENUE_CLASS varchar2 (10) PATH "cmPCCustomerAgreement/revenueClassCode"

    REQUESTED_BY varchar2 (50) PATH ' attributes customerInformation/contactName',...~50

    This ddl ran > 20 hours and no materialized view created. There are certain limits that we have

    • Cannot create a materialized view log
    • cannot change the source as its defined provider table
    • cannot do an ETL

    DB is 11g R2

    Any ideas/suggestions are very much appreciated

    I explored a similar approach, using the following test case.

    It creates a table "MASTER_TABLE" containing 20,000 lines and a CLOB containing an XML fragment like this:

    09HOLVUF3T6VX5QUN8UBV9BRW3FHRB9JFO4TSV79R6J87QWVGN

    UUL47WDW6C63YIIBOP1X4FEEJ2Z7NCR9BDFHGSLA5YZ5SAH8Y8

    O1BU1EXLBU945HQLLFB3LUO03XPWMHBN8Y7SO8YRCQXRSWKKL4

    ...

    1HT88050QIGOPGUHGS9RKK54YP7W6OOI6NXVM107GM47R5LUNC

    9FJ1JZ615EOUIX6EKBIVOWFDYCPQZM2HBQQ8HDP3ABVJ5N1OJA

    then an intermediate table "MASTER_TABLE_XML" with the same columns with the exception of the CLOB which turns into XMLType and finally a MVIEW:

    SQL > create table master_table like

    2. Select level as id

    3, cast ('ROW' | to_char (Level) as varchar2 (30)) as the name

    4       , (

    5. Select xmlserialize (content

    XMLAGG 6)

    7 xmlelement (evalname ('ThisIsElement' | to_char (Level)), dbms_random.string ('X', 50))

    8                    )

    9 as clob dash

    10                  )

    11 double

    12 connect by level<=>

    (13) as xmlcontent

    14 double

    15 connect by level<= 20000="">

    Table created.

    SQL > call dbms_stats.gather_table_stats (user, 'MASTER_TABLE');

    Calls made.

    SQL > create table (master_table_xml)

    Identification number 2

    3, name varchar2 (30)

    4, xmlcontent xmltype

    5)

    binary xmltype 6 securefile XML column xmlcontent store

    7;

    Table created.

    SQL > create materialized view master_table_mv

    2 build postponed

    full 3 Refresh on demand

    4, as

    5. Select t.id

    6, t.nom

    7       , x.*

    master_table_xml 8 t

    9, xmltable ('/ r' in passing t.xmlcontent)

    10 columns

    11 path of varchar2 (50) ThisIsElement1 'ThisIsElement1 '.

    12, path of varchar2 (50) ThisIsElement2 'ThisIsElement2 '.

    13, path of varchar2 (50) ThisIsElement3 'ThisIsElement3 '.

    14, path of varchar2 (50) ThisIsElement4 'ThisIsElement4 '.

    15 road of varchar2 (50) ThisIsElement5 'ThisIsElement5 '.

    16, road of varchar2 (50) ThisIsElement6 'ThisIsElement6 '.

    17 road of varchar2 (50) ThisIsElement7 'ThisIsElement7 '.

    18 road of varchar2 (50) ThisIsElement8 'ThisIsElement8 '.

    19 road to varchar2 (50) ThisIsElement9 'ThisIsElement9 '.

    20, path of varchar2 (50) ThisIsElement10 'ThisIsElement10 '.

    21, road to varchar2 (50) ThisIsElement11 'ThisIsElement11 '.

    22 road of varchar2 (50) ThisIsElement12 'ThisIsElement12 '.

    23 road of varchar2 (50) ThisIsElement13 'ThisIsElement13 '.

    24, path of varchar2 (50) ThisIsElement14 'ThisIsElement14 '.

    25 road of varchar2 (50) ThisIsElement15 'ThisIsElement15 '.

    26, path of varchar2 (50) ThisIsElement16 'ThisIsElement16 '.

    27, way to varchar2 (50) ThisIsElement17 'ThisIsElement17 '.

    28 road of varchar2 (50) ThisIsElement18 'ThisIsElement18 '.

    29 road of varchar2 (50) ThisIsElement19 'ThisIsElement19 '.

    30, path of varchar2 (50) ThisIsElement20 'ThisIsElement20 '.

    31, path of varchar2 (50) ThisIsElement21 'ThisIsElement21 '.

    32 road of varchar2 (50) ThisIsElement22 'ThisIsElement22 '.

    33, path of varchar2 (50) ThisIsElement23 'ThisIsElement23 '.

    34 road of varchar2 (50) ThisIsElement24 'ThisIsElement24 '.

    35 road of varchar2 (50) ThisIsElement25 'ThisIsElement25 '.

    36, road to varchar2 (50) ThisIsElement26 'ThisIsElement26 '.

    37, path of varchar2 (50) ThisIsElement27 'ThisIsElement27 '.

    38, path of varchar2 (50) ThisIsElement28 'ThisIsElement28 '.

    39, path of varchar2 (50) ThisIsElement29 'ThisIsElement29 '.

    40, road of varchar2 (50) ThisIsElement30 'ThisIsElement30 '.

    41 road of varchar2 (50) ThisIsElement31 'ThisIsElement31 '.

    42, path of varchar2 (50) ThisIsElement32 'ThisIsElement32 '.

    43, road to varchar2 (50) ThisIsElement33 'ThisIsElement33 '.

    44, path of varchar2 (50) ThisIsElement34 'ThisIsElement34 '.

    45, path of varchar2 (50) ThisIsElement35 'ThisIsElement35 '.

    46, path of varchar2 (50) ThisIsElement36 'ThisIsElement36 '.

    47, path of varchar2 (50) ThisIsElement37 'ThisIsElement37 '.

    48, path of varchar2 (50) ThisIsElement38 'ThisIsElement38 '.

    49, path of varchar2 (50) ThisIsElement39 'ThisIsElement39 '.

    50 road of varchar2 (50) ThisIsElement40 'ThisIsElement40 '.

    51, path of varchar2 (50) ThisIsElement41 'ThisIsElement41 '.

    52, path of varchar2 (50) ThisIsElement42 'ThisIsElement42 '.

    53, path of varchar2 (50) ThisIsElement43 'ThisIsElement43 '.

    54, path of varchar2 (50) ThisIsElement44 'ThisIsElement44 '.

    55 road of varchar2 (50) ThisIsElement45 'ThisIsElement45 '.

    56, path of varchar2 (50) ThisIsElement46 'ThisIsElement46 '.

    57, path of varchar2 (50) ThisIsElement47 'ThisIsElement47 '.

    58 road of varchar2 (50) ThisIsElement48 'ThisIsElement48 '.

    59 road of varchar2 (50) ThisIsElement49 'ThisIsElement49 '.

    60 road of varchar2 (50) ThisIsElement50 'ThisIsElement50 '.

    (61) x;

    Materialized view created.

    The discount is then performed in two steps:

    1. INSERT INTO master_table_xml
    2. Refresh the MVIEW

    (Note: as we insert in an XMLType column, we need an XML (only root) document this time)

    SQL > set timing on

    SQL >

    SQL > truncate table master_table_xml;

    Table truncated.

    Elapsed time: 00:00:00.27

    SQL >

    SQL > insert into master_table_xml

    2. select id

    3, name

    4, xmlparse (document '' |) XmlContent |'')

    5 master_table;

    20000 rows created.

    Elapsed time: 00:04:38.72

    SQL >

    SQL > call dbms_mview.refresh ('MASTER_TABLE_MV');

    Calls made.

    Elapsed time: 00:00:22.42

    SQL >

    SQL > select count (*) in the master_table_mv;

    COUNT (*)

    ----------

    20000

    Elapsed time: 00:00:01.38

    SQL > truncate table master_table_xml;

    Table truncated.

    Elapsed time: 00:00:00.41

  • How to extract data from the APEX report with stored procedure?

    Hi all

    I am doing a report at the APEX. the user selects two dates and click on the GO button - I have a stored procedure linked to this region of outcome for the stored procedure is called.

    my stored procedure does the following-

    using dates specified (IN) I do question and put data in a table (this painting was created only for this report).

    I want to show all the data that I entered in the table on my APEX report the same procedure call. can I use Ref cursor return? How to do this?

    Currently, I use another button in the APEX that basically retrieves all the data from table. Basically, the user clicks a button to generate the report and then another button for the report. which is not desirable at all :(


    I m using APEX 3.1.2.00.02 and Oracle 10 database.

    pls let me know if you need more clarification of the problem. Thanks in advance.

    Kind regards

    Probashi

    Published by: porobashi on May 19, 2009 14:53

    APEX to base a report out of a function that returns the sql code... Your current code goes against a Ref cursor returns the values...

    See this thread regarding taking a ref cursor and wrapping it in a function to channel out as a 'table' (use a cast to cast tabular function vale)...

    (VERY COOL STUFF HERE!)

    Re: Tyring to dynamically create the SQL statement for a calendar of SQL

    Thank you

    Tony Miller
    Webster, TX

  • Series read returns the string with excess-need information to extract data from the middle of the string

    I read data from a STI flow meter using the base series writing and reading which used the VISA.  The read string begins with 'OK' or an error code, then a carriage return, then the data follows streaming rate temp pressure flow rate comma comma comma comma Temp... and so on. The string ends with a CR LF.  I need to pull the flow, temperature and pressure data out of the string and write it to a file.  I have difficulties to find a function that will retrieve the data for the string.  Any suggestions?  Thank you.

    Try the subset of string in the palette of the chain.

    Or match the model if you want a more direct control.

    Also a good way is the string analysis, but you must be willing to read oexactly, what happens or an error, pass the entrance.

  • Loading data from the table of operating system

    Hi all;

    MY DB vsersion is 10.2.0.5.0 in LINUX

    I have the .sql file in path X11R6.

    I am trying to load data by running the script load.sql , but I get the error message.

    > > CONTENT

    $ cat vi.sample_tab.sql

    create table tab1 (identification number,

    name varchar2 (15).

    Qual varchar2 (15).

    City varchar2 (15).

    Mobile number);

    $ vi load.sql;

    Start

    because me 1.100000 loop

    insert into table values (i,'* ',' MS ',' *', 1234554321);

    commit;

    end loop;

    end;

    /

    SQL > @sample.sql;

    Table created.

    SQL > @load.sql;

    insert into table values (i,'* ',' MS ',' *', 1234554321);

    *

    ERROR at line 3:

    ORA-06550: line 3, column 19:

    PL/SQL: ORA-00942: table or view does not exist

    ORA-06550: line 3, column 1:

    PL/SQL: SQL statement ignored

    SQL > select * from tab;

    TNOM TABTYPE CLUSTERID

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

    TABLE TAB1

    SQL > tab1 desc;

    Name                                      Null?    Type

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

    ID                                                 NUMBER

    NAME VARCHAR2 (15)

    QUAL VARCHAR2 (15)

    CITY VARCHAR2 (15)

    MOBILE PHONE NUMBER


    Thanks in advance.

    Hello

    GTS (DBA) wrote:

    Hi all;

    MY DB vsersion is 10.2.0.5.0

    I have the .sql file in path X11R6.

    I am trying to load data by running the script load.sql , but I get the error message.

    > CONTENT

    $ cat vi.sample_tab.sql

    create table tab1 (identification number,

    name varchar2 (15).

    Qual varchar2 (15).

    City varchar2 (15).

    Mobile number);

    ...

    Well, which creates a table called TAB1.  The last character of the name of the table is the numeral "1".

    $ vi load.sql;

    Start

    because me 1.100000 loop

    insert into table values (i,'* ',' MS ',' *', 1234554321);

    commit;

    end loop;

    end;

    /

    SQL > @sample.sql;

    Table created.

    SQL > @load.sql;

    insert into table values (i,'* ',' MS ',' *', 1234554321);

    *

    ERROR at line 3:

    ORA-06550: line 3, column 19:

    PL/SQL: ORA-00942: table or view does not exist

    ORA-06550: line 3, column 1:

    PL/SQL: SQL statement ignored

    Refers to another table.  The last character of the name of this table is the letter 'L '.

    SQL > tab1 desc;

    Name                                      Null?    Type

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

    ID                                                 NUMBER

    NAME VARCHAR2 (15)

    QUAL VARCHAR2 (15)

    CITY VARCHAR2 (15)

    MOBILE PHONE NUMBER

    This is the table that you created (its name ends with the digit "1"), not that used in the INSERT statement (its name ends with the letter "L").

Maybe you are looking for