Iterate through string column of data that is a varchar2 (2000)

Hi,
My question is how to iterate through the data by selecting the first 120 bytes of the column writing that to a UTL_FILE, then selecting the next 120 bytes to write that to the UTL_FILE as well until there is no more data. I am having a problem getting the second 120 and so on. The column of data is just text.
Thanks any help is greatly appreciated.

I'm sure there is a shorter or more elegant solution, but this is from a quick function I wrote a while back that might give you an example-
-- Declare variables
        v_msg VARCHAR2(2000) := 'whatever your message is';
        v_pos NUMBER := 1;
        v_len NUMBER := 0;
        v_max_len NUMBER := 120;  
        v_yourstring VARCHAR2(150);
-- Iterate in the body of your procedure
           v_len := length(v_msg);
            WHILE v_len > 0
            LOOP
                v_yourstring :=  (substr(v_msg, v_pos, v_max_len));
                -- do whatever you need to do with first 120 characters
                v_pos := v_pos + v_max_len; 
                v_len := v_len - v_max_len;                                             
            END LOOP;

Similar Messages

  • Need query to list columns and data

    Hi all,
    I am having a requirement that to compare two identical rows based on empno and list the columns and data which columns are varied.
    SQL> select * from emp1 where empno=7369;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-1980       2000                    20
          7369 SMITH      PRO             7788 17-DEC-1980       2100                    20if we see above data - columns mgr,sal and job have different data but same having same employee number
    Now i want to display the columns which are having different values for a given perticular employee having identical rows with employee number
    Note : in my original table i have 300 columns around. above explained is sample example for understanding
    thanks
    krishna.

    Hi,
    If you want a variable number of columns, depending on the data found, then you'll have to use dynamic SQL.
    I suggest you don't do that. I recommend String Aggregation , that is, concatenating the variable number of items into one big string column, formatted so that ir looks like differenct columns. That is, you might get output like this:
    EMPNO MISMATCHED_DATA
          JOB       MGR       SAL
    7369 CLERK     7902      2000
    7369 PRO       7788      2100Notice that the output consists of 3 rows and 2 columns.
    The 1st row displayed serves as a header. (The actual header has the actual, generic column name, mismatched_data.)
    Here's one way to get output like that:
    VARIABLE  data_width     NUMBER
    EXEC      :data_width := 10;
    WITH     unpivoted_data          AS
         SELECT       e.empno
         ,       DENSE_RANK () OVER ( PARTITION BY  e.empno
                                      ORDER BY          e.ROWID
                             )                    AS r_num
         ,       c.column_name
         ,       c.column_id
         ,       RPAD ( COALESCE ( CASE  c.column_name
                                        WHEN  'ENAME'       THEN  e.ename
                                    WHEN  'JOB'       THEN     e.job
                                    WHEN  'MGR'       THEN  TO_CHAR (e.mgr)
                                  WHEN  'HIREDATE'       THEN  TO_CHAR (e.hiredate, 'DD/MM/YYYY HH:MI:SS AM')
                                -- ... more columns in your real problem
                            END
                          , CASE  c.column_name
                                WHEN  'SAL'       THEN     TO_CHAR (e.sal)
                                WHEN  'COMM'         THEN  TO_CHAR (e.comm)
                                WHEN  'DEPTNO'    THEN  TO_CHAR (e.deptno)
                            END
                   , :data_width       -- maximum column width
                   )                         AS d
         FROM    emp1               e
         JOIN       user_tab_columns     c  ON     c.table_name     = 'EMP1'
         WHERE     e.empno     IN (7369)        -- any 1 or more empnos
    ,     got_val_cnt     AS
         SELECT     u.*
         ,     COUNT (DISTINCT d) OVER ( PARTITION BY  empno
                                        ,              column_name
                             )      AS val_cnt
         FROM    unpivoted_data     u
    ,     discrepancies     AS
         SELECT  v.*
         FROM     got_val_cnt     v
         WHERE     val_cnt     > 1
    ,     relevant_columns     AS
         SELECT DISTINCT  column_name
         ,           DENSE_RANK () OVER ( ORDER BY  column_id)     AS c_num
         FROM     discrepancies
    SELECT       d.empno
    ,       REPLACE ( SYS_CONNECT_BY_PATH ( NVL ( d
                                         , RPAD (' ', :data_width)
                             , '~'
                  , '~'
                ) AS mismatched_data
    FROM            discrepancies          d     PARTITION BY ( d.empno
                                              , d.r_num
    RIGHT OUTER JOIN  relevant_columns     r     ON         r.column_name = d.column_name
    WHERE     CONNECT_BY_ISLEAF     = 1
    START WITH     r.c_num          = 1
    CONNECT BY     r.c_num          = PRIOR r.c_num + 1
         AND     d.empno          = PRIOR d.empno
         AND     d.r_num          = PRIOR d.r_num
        UNION ALL
    SELECT    NULL          AS empno
    ,       REPLACE ( SYS_CONNECT_BY_PATH ( RPAD (column_name, :data_width)
                                   , '~'
                , '~'
                )     AS mismatched_data
    FROM      relevant_columns
    WHERE       CONNECT_BY_ISLEAF     = 1
    START WITH     c_num          = 1
    CONNECT BY     c_num          = PRIOR c_num + 1
    ORDER BY  empno          NULLS FIRST
    ;You can specify any number of empnos to be included in the report.
    You really want a CASE expression that has a WHEN clause for every column in your table, but CASE expressions have a maximum of (I believe) 128 WHEN clauses. If you really have 300 rows, you'll have to break that down into smaller groups. In the query above, I used 2 CASE expressions in a COALESCE function, where each of the CASE expressions had no more than 4 WHEN clauses. You may have to use 3 CASE expressions, each with 100 WHEN clauses.
    This solution does not assume there are exactly 2 rows per empno; there can be any number.
    If all the rows for an empno are completely identical, that empno will not be included in the output. This includes the situation where a given empno is unique.
    Again, you can get separate columns for each mismatched item, using dynamic SQL, but it's even more convoluted than the query above.

  • Change Date-Time format through derived column

    Hi,
    I have Date in MM-DD-YYYY Format & Want to convert it to
    YYYY-MM-DD format through derived column. Can anyone help with the expression required for the conversion.???
    Thanks.

    Adarsh,
    check the below modified one ..
    I have my OLEDB source query as :
    select convert(varchar(10),getdate(),101) as date_var
    My Expression used in the Derived Column part is :
    SUBSTRING((DT_WSTR,100)date_var,7,4) + "-" + SUBSTRING((DT_WSTR,100)date_var,1,2) + "-" + SUBSTRING((DT_WSTR,100)date_var,4,2)
    (It works irrespective of whther it is a DATE/DATETIME type or STRING type .. )
    Hope that helps!!
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • I want to build an array using the data that I get through the serial port

    I am reading data through the serial port, but I want to buffer these data. I have seen a function, but i think that i can use this if I am reading data from I/O intrument, so I don´t how can I fill an array, with the data that I am reading!!!
    Thank you!!!

    I'll hazard a guess that you are reading data with VISA as a string. Then you want to convert that (probably with Scan From String) into a number. Then, you want to collect those numbers into an array.
    We don't really have enough information to tell you the best way to do this. Here are some ideas.
    If you are reading all the numbers from the instrument at once (e.g., a waveform from a scope), you might consider using "Spreadsheet string to array". Most scopes return the data as ASCII with commas between the values, so you'd wire a "," to the "delimiter" input of the "Spreadsheet string to array" function.
    If, however, the instrument is returning a single point at a time, there are more questions. Do you want to do this continuously, or do you want t
    o collect only a certain number of data points, and then process them as a block?
    If the latter, then you'd just acquire each data point, convert it to a number, and then use output indexing on the for loop to create your array.
    If the former, then you may want to store the data in a queue, and read it from the queue elsewhere in your program.
    If you let us know what you want to do, we can probably provide more precise help.
    Brian

  • Query a column of data through IFS?

    We need to know how to query a column of data through iFS (if this is even possible). For instance, in our database, there is a table ODM_TEST with a column RELEVANT_LOCATION. To get the unique values, we'd just query in SQL:
    SELECT DISTINCT(relevant_location) FROM odm_test
    WHERE relevant_location is not null
    ORDER BY relevant_location
    Is there a way of doing that through the iFS API?
    null

    You can use Selector or Search API of iFS to do the query. Selector is used for simple queries and Search is used for complex queries.
    For example, page 8-9 of Developer Reference of iFS release 9.0.1 has an example of how to use a selector to do the following query -
    SELECT * FROM ATTRIBUTE WHERE DATATYPE = BOOLEAN ORDER BY NAME DESC, REQUIRED
    You can also fine examples of how to use Search classes in the same chapter.
    I hope it helps.
    null

  • How to split a string into tokens and iterate through the tokens

    Guys,
    I want to split a string like 'Value1#Value2' using the delimiter #.
    I want the tokens to be populated in a array-like (or any other convenient structure) so that I can iterate through them in a stored procedure. (and not just print them out)
    I got a function on this link,
    http://www.orafaq.com/forum/t/11692/0/
    which returns a VARRAY. Can anybody help me how to iterate over the VARRAY, or suggest a different alternative to the split please ?
    Thanks.

    RTFM: http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/collections.htm#sthref1146
    or
    http://www.oracle-base.com/articles/8i/Collections8i.php

  • Help with filtering a query with a date as string column

    Hello -- I've got a table column that contains dates as
    string/text type (access db). I need to make a query of my table
    that includes only the dates that match today's date (example
    5-13-2008). I need two parts. One is to capture today's date, and
    another to set the filter in the query.
    Here's my base query
    <cfquery name="someQuery" datasource="someDS">
    SELECT col1, col2, dateCol, col4
    FROM someTable
    WHERE dateCol = "today's date"
    </cfquery>
    What's the best way to capture today's date? And then what's
    the best way to set it to a string so I have an object to compare
    with dateCol. I know #now()# will get today's date, however it
    returns date + time. How can I format it as M-D-YYYY? Then, how do
    I convert it to a string so I can evaluate in my query? Any help is
    appreciated!

    quote:
    Originally posted by:
    Dan Bracuk
    Redesign your database and store dates as dates instead of
    strings.
    I would love to do this, however I couldn't figure out how to
    store date and time values AS DATE to my database. My front end is
    Flex with a Coldfusion backend. When a form is filled, I need it to
    send the current time and the current date of submission. Using
    Date(), I can obtain the current date (date + time). However it's
    not easy to separate the [date] and [time] values of the Date()
    result without using a dateformatter with a mask. By doing this,
    I've now taken my date as DATE and converted it to date and time
    both AS STRING. Well after several trial and error tries as well as
    looking for any help online, I just decided to use the
    dateformatter, convert date and time to string and then save each
    to their own columns.
    The other way of doing this is to just have one column that
    holds both the date and time, and use Date() to pass the correct
    data-type to my db. However, when passing Date() to my db, it only
    stores the date but sets the time to 00:00:00. Now if I could find
    a way to get both correct date and time (example 5-13-2008 1:31:xx
    PM), I could just use a dateformatter in my front end to display
    the dates as I want. Again, the problem is I need the TIME value as
    well, and it keeps defaulting to 00:00:00 in access.
    @paross1-- I will try what you've provided just to get this
    thing working, regardless if they are strings in the db instead of
    dates.
    If anyone can solve my default time issue mentioned above,
    that would be great too..

  • How to create a variance on data that exists iIn only one database column

    How to create a variance on data that exists iIn only one database column?
    I'm trying to create a calculation to show the difference between the budgets for two different years in a Discoverer crosstab query.
    I'm using the lag function to repeat the value of a column for the current year and the year before.

    Lag and lead seems to be the only choice and they work excellent. Checkout the new 10g Database features. There is new SQL modal clause which might give additional and powerful analytics but in this case lag and lead should be sufficient.
    regards
    http://www.infocaptor.com/workbook-dump.php

  • How do you iterate through a string?

    Hi! How do I loop through a string of characters. My program needs to iterate through a string in order to do some calculations. Here is an example:
    <item>1</item>
    <description>This is an example.</description>
    How I iterate through description one character at a time.
    Thanks for your help!

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
    <xsl:template name="add-X">
    <xsl:param name="string" select="." />
    <xsl:if test="$string">
    <xsl:text>X</xsl:text>
    <xsl:value-of select="substring($string, 1,1)"/>
    <xsl:call-template name="add-X">
    <xsl:with-param name="string"
    select="substring($string, 2)" />
    </xsl:call-template>
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>
    Create an file named TEST.xsl with the above code.
    <aaaa>ABCDE</aaaa>
    Create an file named TEST.XML with the above code.
    Create an RTF template with form field valus as
    <?import: file:///C:\Desktop\Sample RTF\TEST.xsl?>
    Note : here you have to point the xsl path where your TEST.xsl is located.
    Then create another form field with value
    <xsl:call-template name="add-X"> <xsl:value-of select="." /> </xsl:call-template>
    When you merge the xml and RTF , you will find the no of "X" equivalent to length of the string in <aaaa> tag in xml

  • HELP:script that iterates through all opened documents and rezise them to match the biggest one.

    Hi,
    I'm making a batch processing action and I really need a script that iterates through all open documents, finds the one with the biggest image size and then iterates one more time to change the rest of the documents to the same image size dimensions. At the end all documents must share identical image size.  I'll really  appreciate if someone can put a quick script for doing this. Thank you !

    I think should do…
    #target photoshop
    if (documents.length > 1) {
         var smallest = 1000000; // Set beyond any size you may be expecting this should do?
         for (var a = 0; a < documents.length; a++) {
              smallest = Math.min(smallest,documents[a].width.as('px'));
         for (var b = 0; b < documents.length; b++) {
              if (documents[b].width.as('px') != smallest) {
                   app.activeDocument = documents[b];
                   var newWidth = new UnitValue(smallest, 'px');
                   documents[b].resizeImage(newWidth,undefined,undefined,ResampleMethod.BICUBICSMOOTHER);
    }else{
         alert("NOT enough docs to resize?");

  • Import csv through SSIS package - format date column

    Hello -
    I need to import a csv file to SQL server using SSIS.  The date column in excel is, for example, 7/8/2014, but it imports as 41828 in SQL Server.  How can I convert this?
    Any help will be greatly appreciated!

    Hi,
    According to your descrition, date column convert to string data type column when import data from a csv file to SQL Server table. While you want the column still stores as date data type in SQL Server table.
    In order to achieve this goal, there are several methods:
    Add a Derived Column Transformation before the OLE DB Destination. Then add a derived column  to replace the date column with the expression like bewlow to convert the column to date data type:
    (DT_DBDATE)column_name
    Add a Data Conversion Transformation before the OLE DB Destination.Then convert the date column to date[DT_DATE] data type. Use the new column as the destination column.
    In the OLE DB Destination Editor, we can change the data type from varchar(50) to date when create a table as the destination.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Since mountain lion Find in Numbers 3-4 columns of data missing and some columns in the wrong order. Fortunately I have a back up on my iPad and was able to put that version in as a new file. Why has this happened ?

    Since mountain lion I have noticed 3-4 columns of data missing from a Numbers file. I have fortunately been able to replace the total file from my iPad version but why has this happened. Makes me lose trust in Numbers

    That would be strange.

  • Dynamically Iterate through data a deliver a seperate report for each

    How would I configure my Crystal Report Server to dynamically iterate through a batch of check numbers, generate & deliver a report for each check number?

    Jaggy like this

  • How can I iterate over the columns of a REF CURSOR?

    I have the following situation:
    DECLARE
       text   VARCHAR2 (100) := '';
       TYPE gen_cursor is ref cursor;
       c_gen gen_cursor;
       CURSOR c_tmp
       IS
            SELECT   *
              FROM   CROSS_TBL
          ORDER BY   sn;
    BEGIN
       FOR tmp IN c_tmp
       LOOP
          text := 'select * from ' || tmp.table_name || ' where seqnum = ' || tmp.sn;
          OPEN c_gen FOR text;
          -- here I want to iterate over the columns of c_gen
          -- c_gen will have different number of columns every time,
          --        because we select from a different table
          -- I have more than 500 tables, so I cannot define strong REF CURSOR types!
          -- I need something like
          l := c_gen.columns.length;
          for c in c_gen.columns[1]..c_gen.columns[l]
          LOOP
              -- do something with the column value
          END LOOP;
       END LOOP;
    END;As you can see from the comments in the code, I couln'd find any examples on the internet with weak REF CURSORS and selecting from many tables.
    What I found was:
    CREATE PACKAGE admin_data AS
       TYPE gencurtyp IS REF CURSOR;
       PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT);
    END admin_data;
    CREATE PACKAGE BODY admin_data AS
       PROCEDURE open_cv (generic_cv IN OUT gencurtyp, choice INT) IS
       BEGIN
          IF choice = 1 THEN
             OPEN generic_cv FOR SELECT * FROM employees;
          ELSIF choice = 2 THEN
             OPEN generic_cv FOR SELECT * FROM departments;
          ELSIF choice = 3 THEN
             OPEN generic_cv FOR SELECT * FROM jobs;
          END IF;
       END;
    END admin_data;
    /But they have only 3 tables here and I have like 500. What can I do here?
    Thanks in advance for any help!

    The issue here is that you don't know your columns at design time (which is generally considered bad design practice anyway).
    In 10g or before, you would have to use the DBMS_SQL package to be able to iterate over each of the columns that are parsed from the query... e.g.
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
      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_rowcount  NUMBER := 0;
    BEGIN
      -- create a cursor
      c := DBMS_SQL.OPEN_CURSOR;
      -- parse the SQL statement into the cursor
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      -- execute the cursor
      d := DBMS_SQL.EXECUTE(c);
      -- Describe the columns returned by the SQL statement
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      -- Bind local return variables to the various columns based on their types
      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); -- Varchar2
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);      -- Number
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);     -- Date
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);  -- Any other type return as varchar2
        END CASE;
      END LOOP;
      -- Display what columns are being returned...
      DBMS_OUTPUT.PUT_LINE('-- Columns --');
      FOR j in 1..col_cnt
      LOOP
        DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
                                                                                  when 2 then 'NUMBER'
                                                                                  when 12 then 'DATE'
                                                         else 'Other' end);
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('-------------');
      -- This part outputs the DATA
      LOOP
        -- Fetch a row of data through the cursor
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        -- Exit when no more rows
        EXIT WHEN v_ret = 0;
        v_rowcount := v_rowcount + 1;
        DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
        DBMS_OUTPUT.PUT_LINE('--------------');
        -- Fetch the value of each column from the row
        FOR j in 1..col_cnt
        LOOP
          -- Fetch each column into the correct data type based on the description of the column
          CASE rec_tab(j).col_type
            WHEN 1  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
            WHEN 2  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
          END CASE;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('--------------');
      END LOOP;
      -- Close the cursor now we have finished with it
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    DEPTNO - NUMBER
    SAL - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    DEPTNO : 10
    SAL : 2450
    Row: 2
    EMPNO : 7839
    ENAME : KING
    DEPTNO : 10
    SAL : 5000
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    DEPTNO : 10
    SAL : 1300
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    JOB - VARCHAR2
    MGR - NUMBER
    HIREDATE - DATE
    SAL - NUMBER
    COMM - NUMBER
    DEPTNO - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    JOB : MANAGER
    MGR : 7839
    HIREDATE : 09/06/1981 00:00:00
    SAL : 2450
    COMM :
    DEPTNO : 10
    Row: 2
    EMPNO : 7839
    ENAME : KING
    JOB : PRESIDENT
    MGR :
    HIREDATE : 17/11/1981 00:00:00
    SAL : 5000
    COMM :
    DEPTNO : 10
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    JOB : CLERK
    MGR : 7782
    HIREDATE : 23/01/1982 00:00:00
    SAL : 1300
    COMM :
    DEPTNO : 10
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from dept where deptno = 10');
    -- Columns --
    DEPTNO - NUMBER
    DNAME - VARCHAR2
    LOC - VARCHAR2
    Row: 1
    DEPTNO : 10
    DNAME : ACCOUNTING
    LOC : NEW YORK
    PL/SQL procedure successfully completed.
    SQL>From 11g onwards, you can create your query as a REF_CURSOR, but then you would still have to use the DBMS_SQL package with it's new functions to turn the refcursor into a dbms_sql cursor so that you can then describe the columns in the same way.
    http://technology.amis.nl/blog/2332/oracle-11g-describing-a-refcursor
    Welcome to the issues that are common when you start to attempt to create dynamic code. If your design isn't specific then your code can't be either and you end up creating more work in the coding whilst reducing the work in the design. ;)

  • SP2-0246 when COLUMN FORMAT DATE in sqlplus

    Hi,
    I've read in 'Oracle 11g SQL' Jason Price book that I can format column of DATE type in sqlplus by i.e.:
    COLUMN <name> FORMAT 'YYYY'
    but when I tried then got:
    SQL> SELECT table_name, column_name, data_type FROM user_tab_columns WHERE data_type LIKE '%DATE%';
    TABLE_NAME COLUMN_NAME
    DATA_TYPE
    CUSTOMERS DOB
    DATE
    CUSTOMERS2 DOB
    DATE
    ORDER_STATUS LAST_MODIFIED
    DATE
    SQL> COLUMN dob FORMAT YYYY
    SP2-0246: Illegal FORMAT string "YYYY"
    Well, there is mistake in the book or I'm doing sth in wrong way???
    greetings
    mac

    Welcome to the forum.
    Usually this is done through NLS_DATE_FORMAT:
    SQL> create table t as select sysdate dt from dual;
    Table created.
    SQL> desc t
    Name                                      Null?    Type
    DT                                                 DATE
    SQL> column dt format YYYY
    SP2-0246: Illegal FORMAT string "YYYY"
    SQL> column dt format "YYYY"
    SP2-0246: Illegal FORMAT string "YYYY"
    SQL>  column dt format 'yyyy'
    SP2-0246: Illegal FORMAT string "yyyy"
    SQL> select * from t;
    DT
    24-03-2013 14:08:39
    SQL> alter session set nls_date_format = 'YYYY';
    Session altered.
    SQL> select * from t;
    DT
    2013
    SQL>

Maybe you are looking for