Converting Varchar into Clob in Oracle 8i

Hi All,
Kindly tell me how can we convert a varchar variable into a Clob in Oracle 8i inside a stored procedure. I searched alot on the net, we have a To_Clob function available from 9i but doesn't exist in 8i. There was also talk about using dbms_lob, but i dont know how to use that to convert it.
Kindly provide me with the details of how to do this as I am just starting out with Oracle.
Thanks in Advance,
Sajid.

Hi,
You can use the dbms_lob.to_clob() function(In oracle8i).
In oracle 9i it is not required.
Thanks & Regards
venkata

Similar Messages

  • How to convert varchar to BLOB in oracle 10g?

    Hi all,
    I have 2 columns A and B which are of varchar2(2000) dataype.
    I would like to concatinate these 2 columns and convert them into BLOB in oracle 10g.
    Any help is appreciated.
    Regards,
    Ravi

    don't use BLOB to store large text, use CLOB instead
    anyway:
    SQL> create table test
      2  (txt varchar2(10)
      3  ,other varchar2(10)
      4  );
    Table created.
    SQL>
    SQL> insert into test values ('some text', 'other text');
    1 row created.
    SQL>
    SQL> create table test2
      2  (col blob)
      3  /
    Table created.
    SQL>
    SQL> insert into test2
      2  select utl_raw.cast_to_raw (txt||other)
      3    from test
      4  /
    1 row created.
    SQL> select *
      2    from test2
      3  /
    SP2-0678: Column or attribute type can not be displayed by SQL*Plus
    SQL>
    SQL> select utl_raw.cast_to_varchar2(col)
      2    from test2
      3  /
    UTL_RAW.CAST_TO_VARCHAR2(COL)
    some textother text
    SQL>
    SQL> drop table test
      2  /
    Table dropped.
    SQL> drop table test2
      2  /
    Table dropped.

  • Converting Rows into Column in Oracle 10g

    Hi All,                    
    I m using Oracle Version 10.1.0.2.0 - Production                    
    I have requirement to convert rows into column wise as per the following:                    
    My Query is:                    
    WITH t                    
    AS ( SELECT 'A' AS x, 100 AS y FROM DUAL                     
    UNION ALL                    
    SELECT 'B',200 FROM DUAL                    
    SELECT X, Y                    
    FROM t;     
    X Y
    A 100
    B 200
    My Requirement is
    A B
    100 200
    So any one could help me that how I resolve this.
    Regards,
    Prasanta

    Dear frank,
    Thanks for your support,.
    It's working fine for static cases.If the first column is dynamic then how come i will resolve it.
    Example:
    Create table mytab (ID_C Varchar2(15),Value_N Number);
    Records Population into MyTab table is dynamic.
    Insert into mytab values('HO',5000);
    Insert Into mytab values('PG1',2400);
    Insert Into mytab values('PG2',3000);
    Insert Into mytab values('PG3',800);
    Commit;
    SQL> Select * From MyTab;
    IDC_ ValueN_
    HO 5000
    PG1 2400
    PG2 3000
    PG3 800
    Then My expected result will be as follows
    HO PG1 PG2 PG3
    5000 2400 3000 800
    Thanks and Regards,
    Prasanta

  • Problem in Converting Database into Archivelog mode (Oracle 10G)

    Hi Team,
    I come across a strange problem in the ORACLE 10G Server.
    I am converting database mode from NoArchivelog to Archivelog mode through RMAN in 10G.
    Now When I execute these following commands through RMAN prompt it works properly as shown below?
    C:\>rman
    Recovery Manager: Release 10.2.0.1.0 - Production on Thu Nov 30 18:01:08 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    RMAN> connect target /
    connected to target database: RAVI (DBID=4025722893, not open)
    RMAN> shutdown immediate;
    using target database control file instead of recovery catalog
    database dismounted
    Oracle instance shut down
    RMAN> STARTUP MOUNT;
    connected to target database (not started)
    Oracle instance started
    database mounted
    Total System Global Area 167772160 bytes
    Fixed Size 1247876 bytes
    Variable Size 79693180 bytes
    Database Buffers 79691776 bytes
    Redo Buffers 7139328 bytes
    RMAN> SQL 'ALTER DATABASE ARCHIVELOG';
    sql statement: ALTER DATABASE ARCHIVELOG
    RMAN> ALTER DATABASE OPEN;
    database opened
    RMAN>
    But this same script when i writes in the backup.ora file & pass to Rman prompt it fails,
    File backup.ora contains...
    run
    SHUTDOWN IMMEDIATE;
    STARTUP MOUNT;
    SQL 'ALTER DATABASE ARCHIVELOG';
    ALTER DATABASE OPEN;
    passed to RMAN as follows...
    C:\OracleCode\BACKUP>"C:\oracle\product\10.2.0\db_1\bin\RMAN.EXE" target /"connect target SYSTEM/sreedhar@RAVI" log="C:\ORACLE~2\LOGS\backup_log.log" append cmdfile="C:\ORACLE~2\BACKUP\backup.ora"
    RMAN> 2> 3> 4> 5> 6> 7> 8>
    then it fails giving the following errors...
    using target database control file instead of recovery catalog
    database closed
    database dismounted
    Oracle instance shut down
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of startup command at 11/30/2006 18:05:59
    ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
    Recovery Manager complete.
    The same thing is working in the Oracle 9i but not in the Oracle 10G.
    Can Anybody plz help me in this?
    Regards,
    S.Tiwari
    .

    export ORACLE_SID=<SID>
    rman target /cmdfile="C:\ORACLE~2\BACKUP\backup.ora"
    it will connect to the default SID, there's no such thing as a default SID, what do you mean?
    But what if there are more that one SID available & I
    want to connect to SID other than the default SID.just specify the desired SID prior starting rman.
    more over the same string is working with 9i but not
    with 10G.maybe due to a bug?
    to summarize, you have two options it you would like to start up the instance:
    either you specify the SID prior starting rman and use os authentication
    or
    you register the instance statically and use oracle authentication.
    regards,
    -ap

  • Storing VARCHAR2 data into CLOB in Oracle 8i

    I have a variable in PL/SQL of data type CLOB. And there is another variable of type VARCHAR2. How can i assign the value in the VARCHAR2 data type to CLOB data type.
    The version iam trying to do this is
    Oracle8i Enterprise Edition Release 8.1.7.2.1
    Thanks,
    Karthick.

    This system has been build already. And this one is for some testing purpose. Any way i have given a temporary solution for them with a temp table.
    SQL> create table t (col clob)
      2  /
    Table created.
    SQL> declare
      2     lClob Clob;
      3     lVar Varchar2(100) := rpad('*',100,'*');
      4  begin
      5     insert into t values(lVar);
      6     select col into lClob from t;
      7     dbms_output.put_line(dbms_lob.substr(lClob,100,1));
      8  end;
      9  /
    PL/SQL procedure successfully completed.Thanks,
    Karthick.

  • How to convert String into Clob in Java?

    Hi all,
    from a form i have a
    String body = request.getParameter("body_name");
    i want to insert the string body to a clob field in oracle.
    string is from a textarea where the user enter html contents and i want to storeit as a clob in the database.
    can anybody help ?
    I have done with setCharaceteStream(), but it will take only 4000 characters. which suppose to take upto 4GB limit.
    So I want to set it as stmt.setClob(" some form by using String")
    Pls. help me if you can?
    thanks in advance
    Srikanth

    Have you tried using setString?
    null

  • Error in converting varchar into dd/mm/yyyy

    Hi all,
    i need to insert the "date_of_birth" in 'dd/mm/yyyy'.
    but in master table "date_of_birth" column is in Varchar2(15),and values in the master tables are not in proper format.
    i.e) some values are like *'21-jan-1988'*,
    and some are like *'01/21/1988'* and *'21-01-1988'*.
    i need to insert into a new table in dd/mm/yyyy format.
    thanks in advance.

    You could use such a method, but WITH NOT GUARANTEE AT ALL_ that you're not inserting WRONG_ dates of birth.SQL> with rotten_data as (
      2  -- start of sample data --
      3  select '10-Jan-2010' vdate from dual
      4  union all select '10/Feb/2010' from dual
      5  union all select '10-03-2010' from dual
      6  union all select '10/04/2010' from dual
      7  union all select '17/04/2010' from dual
      8  union all select '11/14/2010' from dual
      9  union all select '23-04-2010' from dual
    10  union all select '07-18-2010' from dual
    11  union all select '01-02-2010' from dual
    12  -- end of sample data --
    13  )
    14  select
    15     vdate,
    16     case
    17             when regexp_like(r2,'^\D*$') then to_date(r1||r2||yr,'ddMonyyyy')
    18             when regexp_like(r1,'^\D*$') then to_date(r2||r1||yr,'ddMonyyyy')
    19             when (to_number(r1)>12 and to_number(r2)<=12) then to_date(r1||r2||yr,'ddmmyyyy')
    20             when (to_number(r1)<=12 and to_number(r2)>12) then to_date(r2||r1||yr,'ddmmyyyy')
    21             else to_date(r1||r2||yr,'ddmmyyyy')
    22     end newdt
    23  from (
    24     select
    25             vdate
    26             ,regexp_substr(vdate,'[^-/]+',1,1) r1
    27             ,regexp_substr(vdate,'[^-/]+',1,2) r2
    28             ,regexp_substr(vdate,'[^-/]{4}',1,1)yr
    29     from rotten_data
    30  ) ;
    VDATE       NEWDT
    10-Jan-2010 10/01/2010 00:00:00
    10/Feb/2010 10/02/2010 00:00:00
    10-03-2010  10/03/2010 00:00:00
    10/04/2010  10/04/2010 00:00:00
    17/04/2010  17/04/2010 00:00:00
    11/14/2010  14/11/2010 00:00:00
    23-04-2010  23/04/2010 00:00:00
    07-18-2010  18/07/2010 00:00:00
    01-02-2010  01/02/2010 00:00:00
    9 rows selected.This would still fail if the data is not one of those format +(or is not a valid date whatever the format)+ :
    - dd/mm/yyyy
    - mm/dd/yyyy
    - dd-mm-yyyy
    - mm-dd-yyyy
    - dd-Mon-yyyy
    - dd/Mon/yyyy
    if one of the value is > 12 then it consider it as the day, the other one being the month.
    If both are <=12, then it assumes the first is the day (dd).
    Without any additionnal information, you cannot really make it better...

  • Select LONG column into CLOB variable

    Hi all,
    I am trying retrieve the data present in a LONG column into a CLOB variable.
    However I am getting an error, pls let me know how I can resolve it.
    DECLARE
    v_text CLOB;
    BEGIN
    SELECT TO_LOB(trigger_body)
    INTO v_text
    FROM
    user_triggers
    WHERE
    ROWNUM <= 1;
    END;
    ERROR at line 8:
    ORA-06550: line 8, column 20:
    PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got LONG
    ORA-06550: line 8, column 5:
    PL/SQL: SQL Statement ignored
    Let me know if there is an alternate to this. I would like to get the data present in the LONG column into a variable.
    The reason why I am not retrieving the LONG column into LONG variable is stated below (from Oracle Website):
    You can insert any LONG value into a LONG database column because the maximum width of a LONG column is 2**31 bytes.
    However, you cannot retrieve a value longer than 32760 bytes from a LONG column into a LONG variable.
    Thanks and Regards,
    Somu

    There are couple of things I did (listed in order):
    1) Create Global Temporary Table containing a CLOB column
    2) Select LONG column and convert to CLOB by using TO_LOB and insert into Global Temporary Table containing a CLOB column
    2) Select from this Global Temporary Table (which already contains data in CLOB) and assign it to a CLOB variable.
    This is done because you can not directly use TO_LOB in a select statement to assign the value to a CLOB variable.
    Stated below is an example:
    -- Create Temporary Table
    CREATE GLOBAL TEMPORARY TABLE glb_tmp_table_lob(
    time TIMESTAMP WITH LOCAL TIME ZONE,
    text CLOB
    ON COMMIT DELETE ROWS;
    -- PL/SQL Block to Execute
    DECLARE
    v_clob CLOB;
    BEGIN
    -- Insert into Temporary Table by converting LONG into CLOB
    INSERT INTO glb_tmp_table_lob (
    time ,
    text
    SELECT
    sysdate ,
    TO_LOB(dv.text)
    FROM
    dba_views dv
    WHERE
    ROWNUM <= 1
    -- Select from the Temporary table into the variable
    SELECT
    gt.text
    INTO
    v_clob
    FROM
    glb_tmp_table_lob gt;
    COMMIT;
    -- Now you can use the CLOB variable as per your needs.
    END;
    /

  • Convert data into Date Format imported from MS SQL Server.

    I have imported Data from MS SQL Server. The "Date Column" received in number format like 41017.6361109954. How can i convert it into Date in Oracle SQL.
    If i import same Data in Excel and change the Column Type to Date. It changes successfully. But in Oracle, I tried To_Date function with different parameters but it didn't work.
    Edited by: XAVER on Apr 22, 2012 2:31 AM

    XAVER wrote:
    The actual date for 41017.6361109954 is 22-Apr-2012 but its showing 20-APR-2082It looks like offset is January 1, 2000:
    select timestamp '2000-01-01 00:00:00' + numtodsinterval(41017.6361109954,'day') from dual;
    20-APR-12 03.15.59.990002560 PM
    SQL> SY.

  • Converting varchar to datetime 103

    Hi Guys
    Im making a select query where in a colomn the date is yyyy-mm-dd, i need dd-mm-yyyy (103). A simple convert query does not work because the colomn is not set as a datetime but as a varchar. Its not possible to change the tables at the source.
    The colomn name is DATE_IN
    I think the following post could be helpfull but i dont know how to fix the given statements into the select query
    http://stackoverflow.com/questions/1509977/convert-varchar-into-datetime-in-sql-server

    > in a colomn the date is yyyy-mm-dd, i need dd-mm-yyyy (103)
    As suggested above, this is string date format to string date format conversion, purely string operations.
    If you convert to DATE / DATETIME first (universal internal binary representation), then it may fail if invalid date. 
    You can use the ISDATE or TRY_CONVERT functions to check if the string date is valid.
    DATETIME functions:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to convert blob data into clob using plsql

    hi all,
    I have requirement to convert blob column into clob .
    version details
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE     11.1.0.7.0     Production
    TNS for 32-bit Windows: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    DECLARE
       v_blob      temp.blob_column%TYPE;------this is blob data type column contains  (CSV file which is  inserted  from screens)
       v_clob      CLOB; --i want to copy blob column data into this clob
       v_warning   NUMBER;
    BEGIN
       SELECT blob_column
         INTO v_blob
         FROM temp
        WHERE pk = 75000676;
       DBMS_LOB.converttoclob (dest_lob          => v_clob,
                               src_blob          => v_blob,
                               amount            => DBMS_LOB.lobmaxsize,
                               dest_offset       => 1,
                               src_offset        => 1,
                               blob_csid         => 1, -- what  is the use of this parameter
                               lang_context      => 1,
                               warning           => v_warning
       DBMS_OUTPUT.put_line (v_warning);
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.put_line (SQLCODE);
          DBMS_OUTPUT.put_line (SQLERRM);
    END;I am not getting what is the use of blob_csid , lang_context parameters after going the trough the documentation .
    Any help in this regard would be highly appreciated .......
    Thanks
    Edited by: prakash on Feb 5, 2012 11:41 PM

    Post the 4 digit Oracle version.
    Did you read the Doc for DBMS_LOB.CONVERTTOCLOB? - http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_lob.htm
    The function can convert data from one character set to another. If the source data uses a different character set than the target you need to provide the character set id of the source data.
    The blob_csid parameter is where you would provide the value for the source character set.
    If the source and target use the same character set then just pass zero. Your code is passing a one.
    >
    General Notes
    You must specify the character set of the source data in the blob_csid parameter. You can pass a zero value for blob_csid. When you do so, the database assumes that the BLOB contains character data in the same character set as the destination CLOB.
    >
    Same for 'lang_context' - your code is using 1; just use 0. It is an IN OUT
    >
    lang_context
    (IN) Language context, such as shift status, for the current conversion.
    (OUT) The language context at the time when the current conversion is done.
    This information is returned so you can use it for subsequent conversions without losing or misinterpreting any source data. For the very first conversion, or if do not care, use the default value of zero.

  • How to read/write .CSV file into CLOB column in a table of Oracle 10g

    I have a requirement which is nothing but a table has two column
    create table emp_data (empid number, report clob)
    Here REPORT column is CLOB data type which used to load the data from the .csv file.
    The requirement here is
    1) How to load data from .CSV file into CLOB column along with empid using DBMS_lob utility
    2) How to read report columns which should return all the columns present in the .CSV file (dynamically because every csv file may have different number of columns) along with the primariy key empid).
    eg: empid report_field1 report_field2
    1 x y
    Any help would be appreciated.

    If I understand you right, you want each row in your table to contain an emp_id and the complete text of a multi-record .csv file.
    It's not clear how you relate emp_id to the appropriate file to be read. Is the emp_id stored in the csv file?
    To read the file, you can use functions from [UTL_FILE|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#BABGGEDF] (as long as the file is in a directory accessible to the Oracle server):
    declare
        lt_report_clob CLOB;
        l_max_line_length integer := 1024;   -- set as high as the longest line in your file
        l_infile UTL_FILE.file_type;
        l_buffer varchar2(1024);
        l_emp_id report_table.emp_id%type := 123; -- not clear where emp_id comes from
        l_filename varchar2(200) := 'my_file_name.csv';   -- get this from somewhere
    begin
       -- open the file; we assume an Oracle directory has already been created
        l_infile := utl_file.fopen('CSV_DIRECTORY', l_filename, 'r', l_max_line_length);
        -- initialise the empty clob
        dbms_lob.createtemporary(lt_report_clob, TRUE, DBMS_LOB.session);
        loop
          begin
             utl_file.get_line(l_infile, l_buffer);
             dbms_lob.append(lt_report_clob, l_buffer);
          exception
             when no_data_found then
                 exit;
          end;
        end loop;
        insert into report_table (emp_id, report)
        values (l_emp_id, lt_report_clob);
        -- free the temporary lob
        dbms_lob.freetemporary(lt_report_clob);
       -- close the file
       UTL_FILE.fclose(l_infile);
    end;This simple line-by-line approach is easy to understand, and gives you an opportunity (if you want) to take each line in the file and transform it (for example, you could transform it into a nested table, or into XML). However it can be rather slow if there are many records in the csv file - the lob_append operation is not particularly efficient. I was able to improve the efficiency by caching the lines in a VARCHAR2 up to a maximum cache size, and only then appending to the LOB - see [three posts on my blog|http://preferisco.blogspot.com/search/label/lob].
    There is at least one other possibility:
    - you could use [DBMS_LOB.loadclobfromfile|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i998978]. I've not tried this before myself, but I think the procedure is described [here in the 9i docs|http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96591/adl12bfl.htm#879711]. This is likely to be faster than UTL_FILE (because it is all happening in the underlying DBMS_LOB package, possibly in a native way).
    That's all for now. I haven't yet answered your question on how to report data back out of the CLOB. I would like to know how you associate employees with files; what happens if there is > 1 file per employee, etc.
    HTH
    Regards Nigel
    Edited by: nthomas on Mar 2, 2009 11:22 AM - don't forget to fclose the file...

  • Error while inserting .doc file into CLOB object in oracle

    hello everybody ,
    i am trying to insert .doc file into clob column in oracle database.i am using oracle 8i. But i am getting error saying
    ORA-01461: can bind a LONG value only for insert into a LONG column
    i have no clue.
    i am pasting code here
    please help me out.
    regards
    darshan
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileReader;
    import java.io.Reader;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    public class InsertingClob {
    public static void main(String[] args) {
    File f = new File("E:\\dar
    sowres.doc");
    int len = (int) f.length();
    System.out.println(len);
    Connection conn = null;
    PreparedStatement ps = null;
    try {
    FileReader fr = new FileReader(f);
    String FILE_INSERT_QUERY = "INSERT INTO RESUMED VALUES(?,?)";
    conn = JDBCUtility.getConnection();
    ps = conn.prepareStatement(FILE_INSERT_QUERY);
    ps.setString(1,"1");
    ps.setCharacterStream(2,fr,len);
    int result = ps.executeUpdate();
    if(result ==1) {
    System.out.println("file has been successfully inserted into the db");;
    }else {
    System.out.println("not inserted");
    }catch (Exception e) {
    e.printStackTrace();
    and the error is
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986)
    at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1144)
    at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2152)
    at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2035)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2876)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609)
    at InsertBlob.main(InsertBlob.java:21)
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column

    You may have one of a few errors going for you there:
    The error says your column in Oracle is a Long not a CLOB, if it is, then make your column a CLOB.
    CLOB's are not suppored in all environments and/or all interfaces (specifically Windoz ODBC has a problem).
    I believe a DOC (Windoz MS-Word) file is a BLOB, due to formatting characters in the file.
    I had a very similar error using Access and trying to do this, but changing to SAS fixed the problem. It could very well be that your version of ODBC/JDBC drivers does not support it properly.

  • Insert into CLOB fails with Oracle ODBC driver version 9.02.00.65

    I tried to insert into CLOB using the latest Oracle ODBC driver 9.02.00.65 and it fails. But the same works with earlier versions of ODBC driver earlier to 9.02.00.65 ie., 9.02.00.63.
    Here is the code snippet I tried. Any help now is highly appreciated as I am in the crunch time.
    I tried the same code snippet with VARCHAR2 column with the same driver and it works.
    ** CONVDSN.C - This is the ODBC sample code for
    ** creating File DSN pointers to machine DSNs.
    **This code is furnished on an as-is basis as part of the ODBC SDK and is
    **intended for example purposes only.
    #include <windows.h>
    #include <stdio.h>
    #include <tchar.h>
    #include <sql.h>
    #include <sqlext.h>
    #include <odbcinst.h>
    #include <sqltypes.h>
    #define MAXDATALEN 25 //maximum data length per column
    #define MAX_COL 15 //maximum column in result set
    #define MAX_ROW 100 //maximum number of rows
    #define MAXBUFLEN 256
    #define SQLERR_FORMAT "SQL Error State:%s, Native Error Code: %lX, ODBC Error: %s"
    #define MAXDISPLAYSIZE MAX_COL*(MAXDATALEN+1)
    #define SQLWRNMSGTITLE "SQL_SUCCESS_WITH_INFO results"
    #define SQLERRCNTDTITLE "SQL_ERROR results continued"
    #define SQLWRNMSGTITLE "SQL_SUCCESS_WITH_INFO results"
    #define SQLWRNCNTDTITLE "SQL_SUCCESS_WITH_INFO results continued"
    #define NULLDATASTRING "SQL_NULL_DATA"
    #define SQLERRMSGTITLE "SQL_ERROR results"
    // prototypes
    void ExpandFileName(LPSTR szFileDSNName, LPCSTR szDSNName);
    void MakeLegalName(LPSTR szLegalDSNName, LPCSTR szDSNName);
    // main routine: Iterate through the user and system DSNs, creating a pointer
    // to each.
    void FAR PASCAL DisplayError(SQLRETURN nResult, HWND hWnd, SWORD fHandleType, SQLHANDLE handle);
    void insertSelectClob();
    void checkRcCode(RETCODE rc);
    int main (int argc, char* argv[])
         insertSelectClob();
    return 0;
    void FAR PASCAL DisplayError(SQLRETURN nResult, HWND hWnd, SWORD fHandleType, SQLHANDLE handle)
         UCHAR szErrState[SQL_SQLSTATE_SIZE+1]; // SQL Error State string
         UCHAR szErrText[SQL_MAX_MESSAGE_LENGTH+1]; // SQL Error Text string
         char szBuffer[SQL_SQLSTATE_SIZE+SQL_MAX_MESSAGE_LENGTH+MAXBUFLEN+1];
         // formatted Error text Buffer
         SWORD wErrMsgLen; // Error message length
         UDWORD dwErrCode; // Native Error code
         int iSize; // Display Error Text size
         SQLRETURN nErrResult; // Return Code from SQLGetDiagRec
         SWORD sMsgNum = 1;
         SWORD fFirstRun = TRUE;
         char szDispBuffer[MAXDISPLAYSIZE+1]; // Display Buffer
         szBuffer[0] = '\0';
         do
              // continue to bring messageboxes till all errors are displayed.
              // more than one message box may be reqd. as err text has fixed
              // string size.
              // initialize display buffer with the string in error text buffer
              strcpy(szDispBuffer, szBuffer);
              // call SQLGetDiagRec function with proper ODBC handles, repeatedly until
              // function returns SQL_NO_DATA. Concatenate all error strings
              // in the display buffer and display all results.
              while ((nErrResult = SQLGetDiagRec(fHandleType, handle, sMsgNum++,
                   szErrState, &dwErrCode, szErrText,
                   SQL_MAX_MESSAGE_LENGTH-1, &wErrMsgLen)) != SQL_NO_DATA)
                   if(nErrResult == SQL_ERROR || nErrResult == SQL_INVALID_HANDLE)
                   break;
                   wsprintf(szBuffer, SQLERR_FORMAT, (LPSTR)szErrState, dwErrCode, (LPSTR)szErrText);
                   iSize = strlen(szDispBuffer);
                   if (iSize && (iSize+strlen(szBuffer)+1) >= MAXDISPLAYSIZE)
                   break;
                   if (iSize)
                   strcat(szDispBuffer, "\n");
                   strcat(szDispBuffer, szBuffer);
              // display proper ERROR or WARNING message with proper title
              if (nResult == SQL_SUCCESS_WITH_INFO)
                   MessageBox(hWnd, szDispBuffer, (fFirstRun? SQLWRNMSGTITLE : SQLWRNCNTDTITLE),
                   MB_OK | MB_ICONINFORMATION);
              else
                   MessageBox(hWnd, szDispBuffer, (fFirstRun? SQLERRMSGTITLE : SQLERRCNTDTITLE),
                   MB_OK | MB_ICONEXCLAMATION);
              if (fFirstRun)
                   fFirstRun = FALSE;
         while (!(nErrResult == SQL_NO_DATA || nErrResult == SQL_ERROR || nErrResult == SQL_INVALID_HANDLE));
    void insertSelectClob()
    SQLCHAR clobdata[1001];
    SQLCHAR resultdata[1001];
    SQLINTEGER ind = SQL_DATA_AT_EXEC;
    SQLCHAR *bufp;
         SQLINTEGER cbOrderID = sizeof(SQLSMALLINT);
         SQLSMALLINT sTmp=13;
         SQLCHAR *sqlStmt1  = _T("INSERT INTO clobtbl(id, clob1) VALUES(?, ?)");
         SQLCHAR *sqlStmt2  = _T("SELECT id, clob1 FROM clobtbl");
    //     SQLCHAR *sqlStmt1  = _T("INSERT INTO testInsert(id, clob1) VALUES(?, ?)");
    // SQLCHAR *sqlStmt2  = _T("SELECT id, clob1 FROM testInsert");
    int clobdatalen, chunksize, dtsize, retchklen;
         HENV envHnd;
    HDBC conHnd;
    HSTMT stmtHnd;
    RETCODE rc;
         int nRowcnt=0;
         SQLPOINTER pToken = NULL;
    rc = SQL_SUCCESS;
    // ENV is allocated
    rc = SQLAllocEnv(&envHnd);
    // Connection Handle is allocated
    rc = SQLAllocConnect(envHnd, &conHnd);
    rc = SQLConnect(conHnd, T("testd734"), SQLNTS, T("ipathdba"), SQLNTS, T("ipathdba"), SQLNTS);
    printf(_T("Insert CLOB1 using SQLPutData...\n[%s]\n"), sqlStmt1);
    // Set CLOB Data
    int i;
    SQLCHAR ch;
    for (i=0, ch=_T('A'); i< sizeof(clobdata)/sizeof(SQLCHAR); ++i, ++ch)
    if (ch > _T('Z'))
    ch = _T('A');
    clobdata[i] = ch;
    clobdata[sizeof(clobdata)/sizeof(SQLCHAR)-1] = _T('\0');
    clobdatalen = lstrlen(clobdata); // length of characters
    chunksize = clobdatalen / 7; // 7 times to put
         rc = SQLAllocHandle(SQL_HANDLE_STMT, conHnd, &stmtHnd);
    // Step 1: Prepare
    rc = SQLPrepare(stmtHnd, sqlStmt1, SQL_NTS);
    // checkSQLErr(envHnd, conHnd, stmtHnd, rc);
    // Step 2: Bind Parameter with SQL_DATA_AT_EXEC
    rc = SQLBindParameter(stmtHnd,
    1,
    SQL_PARAM_INPUT,
    SQL_C_SSHORT,
    SQL_INTEGER,
    0,
    0,
    &sTmp,
    0,
    &cbOrderID);
    rc = SQLBindParameter(stmtHnd,
    2,
    SQL_PARAM_INPUT,
    SQL_C_CHAR,
    SQL_LONGVARCHAR,
    clobdatalen*sizeof(CHAR),
    0,
    (SQLPOINTER)clobdata,
    clobdatalen*sizeof(CHAR),
    &ind);
    // checkSQLErr(envHnd, conHnd, stmtHnd, rc);
    // Step 3: Execute
    rc = SQLExecute(stmtHnd);
         while (rc == SQL_NEED_DATA) {
              rc = SQLParamData(stmtHnd, &pToken);
              if (rc == SQL_NEED_DATA) {
                   for (dtsize=0, bufp = clobdata;
                        dtsize < clobdatalen;
                        dtsize += chunksize, bufp += chunksize)
                   int len;
                   if (dtsize+chunksize < clobdatalen)
                        len = chunksize;
                        rc = SQLPutData(stmtHnd, bufp, len*sizeof(SQLCHAR));
                   else
                        len = clobdatalen-dtsize;
                        rc = SQLPutData(stmtHnd, bufp, SQL_NTS);
              rc = SQLParamData(stmtHnd, &pToken);
    // Fails as row count retrieved is zero.
         rc = SQLRowCount(stmtHnd, &nRowcnt);
         if(rc != SQL_SUCCESS)
              DisplayError(rc, NULL, SQL_HANDLE_ENV, conHnd);
    rc = SQLFreeStmt(stmtHnd, SQL_CLOSE);
    printf(_T("Finished Update\n\n"));
    rc = SQLAllocStmt(conHnd, &stmtHnd);
    if (rc != SQL_SUCCESS)
    printf(_T("Failed to allocate STMT\n"));
    exit(-1);
    // Clear Result Data
    memset(resultdata, 0, sizeof(resultdata));
    chunksize = clobdatalen / 15; // 15 times to gut
    rc = SQLExecDirect(stmtHnd, sqlStmt2, SQL_NTS); // select
         if(rc != SQL_SUCCESS)
              DisplayError(rc, NULL, SQL_HANDLE_ENV, conHnd);
    // Step 2: Fetch
    rc = SQLFetch(stmtHnd);
    for(dtsize=0, bufp = resultdata;
    dtsize > sizeof(resultdata)/sizeof(CHAR) && rc != SQL_NO_DATA;
    dtsize += chunksize-1, bufp += chunksize-1)
    int len; // len should contain the space for NULL termination
    if (dtsize+chunksize<sizeof(resultdata)/sizeof(CHAR))
    len = chunksize;
    else
    len = sizeof(resultdata)/sizeof(CHAR)-dtsize;
    // Step 3: GetData
    rc = SQLGetData(stmtHnd,
    2,
    SQL_C_CHAR,
    (SQLPOINTER)bufp,
    len*sizeof(CHAR),
    &retchklen);
    if (!_tcscmp(resultdata, clobdata))
    printf(_T("Succeeded!!\n\n"));
    else
    printf(_T("Failed!!\n\n"));
         if (conHnd)
              SQLFreeConnect(conHnd);
         if (envHnd)
              SQLFreeEnv(envHnd);
    }

    Hi,
    Since 9.2 has been desupported for error correction you will not be able to download that version from OTN. You should ask whoever is providing the training if their is an alternate version you can use. The only versions that you will be able to download from oracle.com is 10.2 11.1, and 11.2.

  • Convert sql select statement to oracle

    Hi All,
    Can anyone help me converting this Sql select statement to oracle ....
    -----------------------------------------Query--------------------------------------------------------------
    select emp_master.emp_code ,
    emp_master.dept_cd ,
    attendance_master.daily_attn_code ,
    attendance_master.linked_column ,
    case when location.payroll_status <> 'N' and eDocsNetEmployeesLeave.StartDate < dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))     
    then
    dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))
    when eDocsNetEmployeesLeave.StartDate < convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01')     
    then convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01') else eDocsNetEmployeesLeaveDetails.StartDate           
    end ,
    eDocsNetEmployeesLeaveDetails.NoOfDays,          
    case when eDocsNetEmployeesLeave.StartDate > location.next_pay_date     
    then convert(datetime , convert(varchar, dateadd(ss,-1, dateadd(mm, 1, convert(datetime , datename(yy,eDocsNetEmployeesLeave.StartDate)+ '/' + datename(mm,eDocsNetEmployeesLeave.StartDate)+ '/01') )),106) )     
    else      
    case when location.payroll_status <> 'N'
    then dateadd(mm,1,location.next_pay_date)      
    else location.next_pay_date
    end      
    end as PaymentDate               ,
    isnull(grade_master.leave_type,'C') ,
    eDocsNetEmployeesLeave.StartDate ,          
    eDocsNetEmployeesLeaveDetails.LeaveType
    from eDocsNetEmployeesLeave ,
    eDocsNetEmployeesLeaveDetails ,
    eDocsNetLeaveTypes ,
    emp_master ,
    grade_master ,
    attendance_master ,
    location
    where eDocsNetEmployeesLeaveDetails.RequestID     = eDocsNetEmployeesLeave.RequestID and
    eDocsNetEmployeesLeave.EmployeeID = emp_master.emp_code and
    eDocsNetEmployeesLeaveDetails.LeaveType = eDocsNetLeaveTypes.LeaveTypeID and
    eDocsNetLeaveTypes.loc_cd = emp_master.loc_cd and
    location.loc_cd = emp_master.loc_cd and
    attendance_master.loc_cd = emp_master.loc_cd and
    attendance_master.linked_column = eDocsNetLeaveTypes.LinkedAttendance and
    grade_master.loc_cd = emp_master.loc_cd and
    grade_master.grade_cd = emp_master.grade_cd and
    eDocsNetEmployeesLeaveDetails.RequestID      = @RequestID
    order by eDocsNetEmployeesLeaveDetails.StartDate
    Thanks in Advance
    Smiley

    Seems like you want to convert a SQL statement from the ??? dialect to the Oracle dialect. *(It would be useful to indicate the non-ANSI standard SQL you are starting with.)
    Part of the problem is that you use several date related functions. Some are unnecessary in Oracle and some need to translated into Oracle functions as found in the Functions section (chapter 5) of the SQL Reference manual at http://www.oracle.com/pls/db102/homepage
    Note that columns and expressions of type 'date' in ORacle always contain all of "yyyy mm dd hh mi ss" and you need to format and trauncate as necessary.
    Also note that '09-JAN-31' is NOT an Oracle date, but rather a character representation of a date which must be converted to/from a date expression. You will often need to use the to_date() and to_char() functions with a format mask as the second parameter. This is also descreibed in the first 2 chapters of the SQL Reference manual.

Maybe you are looking for

  • Logon and do some Work in different Domains in one Forrest dosent work...

    Hi together.. i have the Problem that i need to maintain Groups in all Sub Locations just adding on dailybase all Users to a special Group... my Problem  is that i need to maintain these Groups in 5 Domains in this Forrest.. arround 300 Groups at all

  • Trouble with 'Thank you@ page

    Hi, I'm new to web development and I am having a problem. I have created a comment form and am using PHP script for extraction. All the form info is going to the mail box and so the form and the script for it is working fine. However, I cannot get th

  • IPhoto library delete and use Lightroom

    Dear all, I've been searching for an answer to my specific issue but no luck yet. I understand iPhoto and the duplicates it collects in the iPhoto 'file'. I read a few of T Devlin's posts! However after some deliberation, I've decided to move to Ligh

  • Missing One Folder of Bookmarks

    Suddenly, an entire folder of bookmarks is gone. All my other folders are there, just one is missing. I looked in Recycle Bin, and in other folders, in case I had accidentally dragged it....nothing. I haven't upgraded Firefox recently or done any kin

  • K7T Turbo2 ver5.0 won\'t reboot

    I just recently bought a K7T Turbo2 (MS-6330) motherboard and I'm having a problem with it rebooting.  I can't get the board to do a warm reboot.  It works fine if I turn off the power and then turn it back on but even changing the BIOS settings won'