How to insert long text data in oracle for LONG column type??

Anybody who can tell me what is best way to store long text (more than 8k) in Oralce table.
I am using Long datatype for column but it still doenst let me insert longer strings.
Also I am using ODP.Net.
Anybody with a good suggestion???
Thanks in advance

Hi,
Are you getting an error? If so, what?
This works for me..
Greg
create table longtab(col1 varchar2(10), col2 long );
using System;
using System.Data;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Text;
public class longwrite
public static void Main()
// make a long string
StringBuilder sb = new StringBuilder();
for (int i=0;i<55000;i++)
sb.Append("a");
sb.Append("Z");
string indata = sb.ToString();
Console.WriteLine("string length is {0}",indata .Length);
// insert into database
OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl");
con.Open();
OracleCommand cmd = new OracleCommand();
cmd.CommandText = "insert into longtab values(1,:longparam)";
cmd.Connection = con;
OracleParameter longparam = new OracleParameter("longparam",OracleDbType.Long,indata .Length);
longparam.Direction = ParameterDirection.Input;
longparam.Value = indata ;
cmd.Parameters.Add(longparam);
cmd.ExecuteNonQuery();
Console.WriteLine("insert complete");
//now retrieve it
cmd.CommandText = "select rowid,col2 from longtab where col1 = 1";
OracleDataReader reader = cmd.ExecuteReader();
reader.Read();
string outdata = (string)reader.GetOracleString(1);
Console.WriteLine("string length is {0}",outdata.Length);
//Console.WriteLine("string is {0}",outdata);
reader.Close();     
con.Close();
con.Close();
}

Similar Messages

  • How to insert java.util.Date to Oracle by OraclePrepaidStatement

    Hi all,
    I am trying to insert the date data to oracle a lot. But all of them works wrong???
    Here's a code:
    package main;
    import oracle.jdbc.driver.*;
    import oracledb.OraCon;
    import java.text.SimpleDateFormat;
    public class inmain {
          * @param args
         public static void main(String[] args)
              OraCon conn = new OraCon();
              conn.alloc();
              String sql = "insert into test(c_Date, c_Float, c_Int, c_String) values (?,?,?,?)";
              java.text.SimpleDateFormat MMddyyyyHHmmss = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
              try
                   OraclePreparedStatement ps = (OraclePreparedStatement)conn.oraconnection.prepareStatement(sql);
                   String date = "12/12/2006 17:33:01";
                   java.util.Date ud = MMddyyyyHHmmss.parse(date);
                   java.sql.Date dd = new java.sql.Date(ud.getTime());
                   float ff = Integer.parseInt("1");
                   ps.setDate(1, dd);
                   ps.setFloat(2, ff);
                   ps.setInt(3, 4);
                   ps.setString(4, "This is test");
                   ps.executeUpdate();
              catch(Exception e)
                   e.printStackTrace();
    }Then I select from the table.
    select to_char(test.C_DATE, 'yyyy-MM-dd HH24:mi:ss')
    from test
    Its result is:
    2006-12-12 00:00:00
    I wanna to show 2006-12-12 17:33:01.
    How?

    Dear NiallMcG,
    Thank you very much, It now works fine.
    package main;
    import oracle.jdbc.driver.*;
    import oracledb.OraCon;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    public class inmain {
          * @param args
         public static void main(String[] args)
              OraCon conn = new OraCon();
              conn.alloc();
              String sql = "insert into test(c_Date, c_Float, c_Int, c_String) values (?,?,?,?)";
              java.text.SimpleDateFormat MMddyyyyHHmmss = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
              try
                   OraclePreparedStatement ps = (OraclePreparedStatement)conn.oraconnection.prepareStatement(sql);
                   String date = "12/12/2006 17:33:01";
                   java.util.Date ud = MMddyyyyHHmmss.parse(date);
                   float ff = Integer.parseInt("1");
                   Timestamp ts = new java.sql.Timestamp(ud.getTime());
                   ps.setTimestamp(1,ts);
                   ps.setFloat(2, ff);
                   ps.setInt(3, 4);
                   ps.setString(4, "This is test");
                   ps.executeUpdate();                    
              catch(Exception e)
                   e.printStackTrace();
              conn.release();
    }

  • How to insert XML/dtd data into oracle db

    Hi,
    I have posted this question on couple
    sites and unfortunately I haven't received
    any response. Hopefully this time,
    someone can at least direct me to the
    website/document/sample codes which can provide me solutions of my question.
    My question is:
    Given a DTD, can the XML SQL Utility generate
    the database schema?
    I am trying to find out how the XML data can
    be loaded into the oracle database.
    Thanks in advance,
    Judy
    null

    A DTD does not contain enough information to do a good job at creating a database schema. It contains no datatype information, no field length information for starters, so a table created by a hypothetical DTD->to->Tables utility would be at best able to create a table with all VARCHAR2(4000) columns. Not that useful.
    My book contains lots of examples of techniques for loading XML data into Oracle, include lots of sample code and a whole chapter devoted to building a flexible "XMLLoader" utility for loading XML of arbitrary size into the database.
    Steve Muench
    Development Lead, Oracle XSQL Pages Framework
    Lead Product Manager for BC4J and Lead XML Evangelist, Oracle Corp
    Author, Building Oracle XML Applications
    null

  • How to insert multi language data to oracle database

    Hi ,
    Can any one suggest the steps involved in implementing storage/retrieval of data in the language otherthan english on the database?. I am using Oracle 9i database.
    I want to write sql scripts to insert data to the database.How can i insert the data in the language otherthan english i.e hindi. ensuring storage and display of data is fine at the backend.
    CHARACTERSET is set AL32UTF8 and need to insert the data in the NVARCHAR2 datatype enabled column.
    Any suggestions would be greatly appreciated.
    Thanks and Regards,
    Poornima

    If you can write the text in Notepad, then enter the text and save the file with the encoding "Unicode big endian". Then, open the file in a hex editor. The first two bytes will be 0xFE and 0xFF (this is the Byte Order Mark). This code should be skipped for database storage as it is relevant to flat files only. What follows are two-byte character codes that you can put into UNISTR calls. The file with the word "Patra" will show up in the hex editor as:
    FE FF 09 2a 09 24 09 4d 09 30
    If you can enter the characters in your HTML browser, you can use the very useful conversion page at http://rishida.net/tools/conversion/ (this is not an official endorsement from Oracle but my personal advice). Enter the characters into the "Characters" text area and click on the corresponding [Convert] button. The "Hexadecimal code points" field will tell you the codes that you need to prefix with backslash and put into the UNISTR call.
    If you are unable to enter the characters on your workstation, then you can identify each letter in the text and look it up in the Unicode character database at http://www.unicode.org/Public/UNIDATA/Index.txt or http://www.unicode.org/Public/UNIDATA/NamesList.txt. The four-digit hexadecimal codes listed there are what you are looking for. Unfortunately, such lookup will not work for Chinese Han and Japanese Kanji characters as they have no names in Unicode.
    Another method is to use files in another language-specific encoding and convert them to Unicode before loading them into the AL32UTF8 database.
    -- Sergiusz

  • How to insert sales text (MM02) into a single record of a Ztable.

    Hi,
    I'm extracting data from different data base tables and populating a Ztable which has Matnr as primary key and sales text as a field.
    I have already used READ_TEXT to display the text and it is displayed in multiple records which in turn leads to duplication of Material numbers.
    Now I want to avoid duplication of records (Matnr) as this being a primary record, and display the sales text of a particular material number into one single record.
    Can anyone tell me how to insert sales text (MM02) transaction into one single record.
    Thanks,
    Govind

    sorry i am not enough clear about your requirement...
    as i can understand i am explaining to you.
    suppose your itab contains repaeating matnr.
    matnr
    1
    1
    2
    2
    2
    3
    3
    like this.
    data : text(200),
             matnr like mara-matnr.
    loop at itab.
    call READ_TEXT fnmodule.
    loop at tline.
    concatenate text tline-tdline into text.
    endloop.
    matnr = itab-matnr.
    at end of matnr.
    itab1-matnr = matnr.
    itab1-text = text.
    append itab1.
    clear text.
    endat.
    endloop.
    NB change the code as per your requirement
    regards
    shiba dutta

  • How to insert an image file in Oracle database

    hi
    can you please tell me how to insert an image file into oracle database????
    suppose there is one image file in c:\pictures\rose.jpg. how to insert that file into database? theoretically i know that will be BFILE type but i dont know how to insert that.
    will be waiting for your reply........
    thanks & regards,
    Priyatosh

    Hello,
    The easiest way to load a blob is to use SQL loader.
    This example comes from the utilities guide:
    LOAD DATA
    INFILE 'sample.dat'
    INTO TABLE person_table
    FIELDS TERMINATED BY ','
    (name CHAR(20),
    1 ext_fname FILLER CHAR(40),
    2 "RESUME" LOBFILE(ext_fname) TERMINATED BY EOF)
    Datafile (sample.dat)
    Johny Quest,jqresume.txt,
    Speed Racer,'/private/sracer/srresume.txt',
    Secondary Datafile (jqresume.txt)
    Johny Quest
    500 Oracle Parkway
    Secondary Datafile (srresume.txt)
    Loading LOBs
    10-18 Oracle Database Utilities
    Speed Racer
    400 Oracle Parkway
    regards,
    Ivo

  • How to insert a image file into oracle database

    hi all
    can anyone guide me how to insert a image file into oracle database now
    i have created table using
    create table imagestore(image blob);
    but when inserting i totally lost don't know what to do how to write query to insert image file

    Hi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
    Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
    out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
    out.println("   <input type='submit' name='submit' value='Submit' class='smalltext'>");
    out.println("</form>"); Import this once you have the jar file:
    import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
    private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
            boolean result = true;
            String fileName = null;
            byte fileData[] = null;
            String fileUploadError = null;
            String imageType = "";
            String error = "";
            DiskFileUpload fb = new DiskFileUpload();
            List fileItems = fb.parseRequest(request);
            Iterator it = fileItems.iterator();
            while(it.hasNext()){
                FileItem fileItem = (FileItem)it.next();
                if (!fileItem.isFormField()) {
                    fileName = fileItem.getName();
                    fileData = fileItem.get();
                    // Get the imageType from the filename extension
                    if (fileName != null) {
                        int dotPos = fileName.indexOf('.');
                        if (dotPos >= 0 && dotPos != fileName.length()-1) {
                            imageType = fileName.substring(dotPos+1).toLowerCase();
                            if (imageType.equals("jpg")) {
                                imageType = "jpeg";
            String filePath = request.getParameter("FILE_PATH");
            session.setAttribute("filePath", filePath);
            session.setAttribute("fileData", fileData);
            session.setAttribute("fileName", fileName);
            session.setAttribute("imageType", imageType);
            return result;  
         } And now finally the method to actually write the file to the database:
    private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
            //If the previous code found a file that can be uploaded then
            //save it into the database via a pstmt
            String sql = "";
            UtilDBquery udbq = getUser(request).connectToDatabase();
            Connection con = null;
            int signatureID = 0;
            PreparedStatement pstmt = null;
            try {
                udbq.setUsePreparedStatements(true);
                con = udbq.getPooledConnection();
                con.setAutoCommit(false);
                if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
                    sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
                    pstmt = con.prepareStatement(sql);
                    ResultSet rs = pstmt.executeQuery();
                    while(rs.next()) {
                       signatureID = rs.getInt(1);
                    if (fileName != null && imageType != null) {
                        sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setInt(1, signatureID);
                        pstmt.setBinaryStream(2, is2, (int)(fileData.length));
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
                if(mode.equals("U") && signatureIDIn != 0) {
                    signatureID = signatureIDIn.intValue();
                    if (fileName != null && imageType != null) {
                        sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setBinaryStream(1, is2, (int)(fileData.length));
                        pstmt.setInt(2, signatureID);
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
            } catch (Exception e) {
                con = null;
                throw new Exception(e.toString());
            return signatureID;
       }

  • "how to load a text file to oracle table"

    hi to all
    can anybody help me "how to load a text file to oracle table", this is first time i am doing, plz give me steps.
    Regards
    MKhaleel

    Usage: SQLLOAD keyword=value [,keyword=value,...]
    Valid Keywords:
    userid -- ORACLE username/password
    control -- Control file name
    log -- Log file name
    bad -- Bad file name
    data -- Data file name
    discard -- Discard file name
    discardmax -- Number of discards to allow (Default all)
    skip -- Number of logical records to skip (Default 0)
    load -- Number of logical records to load (Default all)
    errors -- Number of errors to allow (Default 50)
    rows -- Number of rows in conventional path bind array or between direct path data saves (Default: Conventional path 64, Direct path all)
    bindsize -- Size of conventional path bind array in bytes (Default 256000)
    silent -- Suppress messages during run (header, feedback, errors, discards, partitions)
    direct -- use direct path (Default FALSE)
    parfile -- parameter file: name of file that contains parameter specifications
    parallel -- do parallel load (Default FALSE)
    file -- File to allocate extents from
    skip_unusable_indexes -- disallow/allow unusable indexes or index partitions (Default FALSE)
    skip_index_maintenance -- do not maintain indexes, mark affected indexes as unusable (Default FALSE)
    commit_discontinued -- commit loaded rows when load is discontinued (Default FALSE)
    readsize -- Size of Read buffer (Default 1048576)
    external_table -- use external table for load; NOT_USED, GENERATE_ONLY, EXECUTE
    (Default NOT_USED)
    columnarrayrows -- Number of rows for direct path column array (Default 5000)
    streamsize -- Size of direct path stream buffer in bytes (Default 256000)
    multithreading -- use multithreading in direct path
    resumable -- enable or disable resumable for current session (Default FALSE)
    resumable_name -- text string to help identify resumable statement
    resumable_timeout -- wait time (in seconds) for RESUMABLE (Default 7200)
    PLEASE NOTE: Command-line parameters may be specified either by position or by keywords. An example of the former case is 'sqlldr scott/tiger foo'; an example of the latter is 'sqlldr control=foo userid=scott/tiger'. One may specify parameters by position before but not after parameters specified by keywords. For example, 'sqlldr scott/tiger control=foo logfile=log' is allowed, but 'sqlldr scott/tiger control=foo log' is not, even though the position of the parameter 'log' is correct.
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\PFS2004.CTL LOG=D:\PFS2004.LOG BAD=D:\PFS2004.BAD DATA=D:\PFS2004.CSV
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\CLAB2004.CTL LOG=D:\CLAB2004.LOG BAD=D:\CLAB2004.BAD DATA=D:\CLAB2004.CSV
    SQLLDR USERID=GROWSTAR/[email protected] CONTROL=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CTL LOG=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.LOG BAD=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.BAD DATA=D:\GROW\DEACTIVATESTAFF\DEACTIVATESTAFF.CSV

  • How to insert one table data into multiple tables by using procedure?

    How to insert one table data into multiple tables by using procedure?

    Below is the simple procedure. Try the below
    CREATE OR REPLACE PROCEDURE test_proc
    AS
    BEGIN
    INSERT ALL
      INTO emp_test1
      INTO emp_test2
      SELECT * FROM emp;
    END;
    If you want more examples you can refer below link
    multi-table inserts in oracle 9i
    Message was edited by: 000000

  • How to Insert the Text in Selected Text Frame-Reg.

    Dear all,
    I am using the SnipperRunner - SDK, and create the TextFrame, but I can't insert the Text in the Particular Frame. so please give me the soultions,
    (*) Create TextFrame is ok,
    (*) Select TextFrame is also ok,
    (*) now, my Query ->
    How to Insert the Text in the Selected Frame?. (or)
    How to Link the Selectable Frame and my Text.? (or)
    How come to know the TextFrame is select?.
    Please any one can suggest me through the Coding....I will appreciate you...
    Thanks & Regards,
    T.R.Harihara SudhaN

    Hi,
    you have to get the TextModel associated with the textframe. Once you got that, ITextModel has an Insert()-method. You could also process kInsertTextCmdBoss - there are quite a few examples around. I believe WriteFishPrice also inserts text into a frame, just as an example. Good luck ...
    Bernt

  • How to insert vietnameese text in a form

    Hi all,
    How to insert Vietnamese text in a smartform since it is not supported by SAP.

    You can insert using standard text So10 call the standard text in your form where every it is required.
    Download text/language converter using google search. Convert text to your desired language and place it in SO10.
    close the thread once your question is answered.
    Regards,
    SaiRam

  • JTable: HOW TO INSERT ROWS AND DATA?

    I have one JFrame on screen and inside of this i have a JTable, the question is how to insert rows and data into the JTable?

    [http://java.sun.com/docs/books/tutorial/uiswing/components/table.html]
    In future, please post Swing questions to the [Swing Forum.|http://forums.sun.com/forum.jspa?forumID=57]
    In short, your TableModel is probably a DefaultTableModel . Study its API.

  • How to add custom texts in Office Templates   for  the COBRA form set up

    Hi,
    How to insert custom texts in the copied BDS form from COBRA set up. I could not edit the text. I can edit the contact numbers in the standard text and displaying after saving the document.
    I do not know how to proceed for this.
    Please share your valuable experience in this regard.
    Thank you,
    Ravi.

    Structure Ptk03 ,Ptk33 needs to be enhanced

  • How do I justify text at the end of a column

    How do I justify text at the end of a column In Pages?
    Also, is there any way to sort a document (alphabetically by the first word of each paragraph) that is not in a table?

    RTPLaw writes:
    How do I justify text at
    the end of a column In
    P    a    g    e    s     ?
    Also, is there any way
    to   sort  a  document
    (alphabetically by the
    first   word   of   each
    paragraph) that is not
    in         a         table?
    No. Like Peter and Walt, I wonder why you'd want to, considering the appearance of such manipulation, illustrated above. Is this a requirement for some specific type of document?
    Regarding your second question, there's no way to do this using Pages as it comes out-of-the-box (or in the downloaded edition). But you can sort the paragraphs of a document alphabetically using WordService, freeware from Devon Technologies. The link will take you to their download page. Scroll down to the Freeware section and the download link for WordService.
    Regards,
    Barry

  • How can I recover my data in notes for iPhone 4s thats without iTune backup

    How can I recover my data in notes for iPhone 4s thats without iTune backup.

    Sorry saker, but if you have not backed up your data anywhere, and you told the computer, in essence to clear the data and restore it with your iPod data, then you are pretty much out of luck....
    Cheers,
    GB

Maybe you are looking for