Inserting unicode into oracle

Hi every one ,
I need to know how to insert unicode data(data in other language) into oracle using java can any one give me hint or reference to any page
I would be thankful .... !
Regards,
Ibrahim...!
Message was edited by:
Ibrahim_coder

Firstly, I'm assuming that your database is running in a character set that supports Unicode text. If it's not, forget it. You ain't gonna put a square peg in a round hole. Check your NLS settings to confirm what language your DB is running in.
Fortunately for you, java also natively supports unicode, which means that you shouldn't have any problems. Providing, that is, that you use unicode character sets throughout your app and don't use any Reader classes that use a binary or latin charset.
Where is the data that you want to enter coming from? Keyboard? File? Web? If it is the web you will also need to ensure that the web side of your app is set to Unicode encoding.
Once you have checked that everything runs in unicode mode, you should be able to write unicode data straight to the database, without any other worries. If you need to manually enter unicode characters, you can do it using the unicode escape character ie "\u0000".
If you come across any other specific problems, post them here and we can try to resolve them - answering vauge generic qs such as this isn't easy.
If you want to be very sure about the data you are putting into the DB, you could always use RAW or BLOB datatypes in preference to VARCHAR(2) and CLOB datatypes, however you would then have to do all the charset conversion yourself.
HTH

Similar Messages

  • Insert data into oracle table from XML file

    I need to insert data into oracle table from XML file
    If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
    Thanks in advance

    The XML DB forum provides the best support for XML topics related to Oracle.
    Here's the FAQ on that forum:
    XML DB FAQ
    where there are plenty of examples of shredding XML into Oracle tables and such like. ;)

  • How to insert images into oracle databse......

    hi,
    i have to insert images into oracle database..
    but we have a procedure to insert images into oracle database..
    how to execute procedure.
    my images file is on desktop.
    i am using ubuntu linux 8.04..
    here i am attaching code of my procedure
    create or replace PROCEDURE INSERT_BLOB(filE_namE IN VARCHAR2,dir_name varchar2)
    IS
    tmp number;
    f_lob bfile;
    b_lob blob;
    BEGIN
    dbms_output.put_line('INSERT BLOB Program Starts');
    dbms_output.put_line('--------------------------');
    dbms_output.put_line('File Name :'||filE_namE);
    dbms_output.put_line('--------------------------');
    UPDATE photograph SET image=empty_blob()
    WHERE file_name =filE_namE
    returning image INTO b_lob;
    f_lob := bfilename( 'BIS_IMAGE_WORKSPACE',filE_namE);
    dbms_lob.fileopen(f_lob,dbms_lob.file_readonly);
    --dbms_lob.loadfromfile(b_lob,f_lob,dbms_lob.getlength(f_lob));              
    insert into photograph values (111,user,sysdate,b_lob);
    dbms_lob.fileclose(f_lob);
    dbms_output.put_line('BLOB Successfully Inserted');
    dbms_output.put_line('--------------------------');
    commit;
    dbms_output.put_line('File length is: '||dbms_lob.getlength( f_lob));
    dbms_output.put_line('Loaded length is: '||dbms_lob.getlength(b_lob));
    dbms_output.put_line('BLOB Committed.Program Ends');
    dbms_output.put_line('--------------------------');
    END inserT_bloB;
    warm regerds
    pydiraju
    please solve my problem
    thanks in advance.......

    thank you
    but i am getting the following errors.
    i connected as dba and created directory on /home/pydiraju/Desktop/PHOTO_DIR'
    and i gave all permissions to scott user.
    but it not working . it gives following errors.
    ERROR at line 1:
    ORA-22288: file or LOB operation FILEOPEN failed
    Permission denied
    ORA-06512: at "SYS.DBMS_LOB", line 523
    ORA-06512: at "SCOTT.LOAD_FILE", line 28
    ORA-06512: at line 1
    Warm regards,
    Pydiraju.P
    Mobile: +91 - 9912380544

  • ADF Mobile - insert data into oracle db from oracle adf mobile application

    Hi,
    I have to insert data from mobile into oracle database 11g(not in local sqlite database), can somebody tell me how to do it?
    Thanks,
    Anshul

    Hi, Anshul, one common way is to expose DB data as ADF BC, and then add a service interface on top of ADF BC. This would allow the ADF Mobile app to access server DB through ADF BC. There may be other mechanisms to access server-side DB - I think APEX also expose some REST interface to Oracle DB as well. Another option is to use TopLink - TopLink can also expose some REST services.
    Thanks,
    Joe Huang

  • How to insert data into Oracle db from MySQL db through PHP?

    Hi,
    I want to insert my MySQL data into Oracle database through PHP.
    I can access Mysql database using mysql_conect() & Oracle database using oci_connect() through PHP.
    Now How can I insert my data which is in MySQL into Oracle table. Both table structure are exactly same.
    So I can use
    insert into Oracle_Table(Oracle_columns....) values(Select * from MySQL_Table);
    But again problem is I can't open both connections at the same time.
    So has anyone done this before or anyone having any other idea..
    Plz guide me...

    You can do it if you setup a ODBC Gateway between MYSQL and Oracle DB. Then you can directly read from MySQL table using DB links and insert into Oracle table in one single SQL Statement.
    Otherwise you need to fetch the data from MySQL Into variables in your PHP Program and then insert into Oracle after binding the variables to the insert statement for Oracle. Hope that is clear enough.
    Regards
    Prakash

  • Inserting variables into oracle

    how do you creat insert statements in oracle using variables? it won't accept this statement
    stmt.executeUpdate("INSERT into T_LINKMANAGER(LMID,LMNAME,LMURL,LMFLAG,LMHITS,LMCATEG) VALUES(ct,aname,aurl,'false',0,acat)");
    giving a column not allowed here error

    If you're new to this, you should ESPECIALLY learn to use bind variables.
    There are times when experts know not to use bind variables, but for 90-99% of all SQL, and 99.9% of all inserts, bind variables should be used.
    Bind variables are what grownup developers use. They:
    1) usually make your code run much faster in the long run, most definitely so on Oracle
    2) make your code more secure; search the web for "SQL injection" to see why
    3) often make your code easier to code; you don't have to worry about embedded single-quotes in your data breaking your SQL
    Where I work, when we interview for new Java developers, if they claim any JDBC knowledge at all, we ask them to write a sample. If they don't use bind variables, they drastically reduce their chances of getting the job.
    Back to your original query:
    1) when asking help in a forum it's ALWAYS better to cut and paste the full original error message than to paraphrase it; there are often clues that get omitted in a paraphase
    2) In your SQL:"INSERT into T_LINKMANAGER(LMID,LMNAME,LMURL,LMFLAG,LMHITS,LMCATEG) VALUES(ct,aname,aurl,'false',0,acat)"ct, aname, aurl, and acat are being interpreted as Oracle column names.
    If those are supposed to be literal values, you must write them as 'ct', etc.
    If those are Java String variables that you want to embed in your SQL, you need to do: "INSERT into T_LINKMANAGER(LMID,LMNAME,LMURL,LMFLAG,LMHITS,LMCATEG) VALUES('" +ct+"','" + aname + "','"  ...If there's ever ANY chance that your Java variables will ever have a ' (single-quote) character in them, then before the SQL statement is built, you have to escape the embedded ' (convert ' to '' (single-quote single-quote) ). To avoid this common headache, use bind variables.
    Actually, for heavily used code, building up a String with "+" is also bad; it generates excessive amounts of intermediate values that have to be garbage collected, thereby slowing your throughput. If you just have to use dynamically built SQL (you should use bind variables instead), then you should build the string in a StringBuffer and convert it to a String at execution.

  • Insert data into oracle database using a PHP form

    I'm trying to enter data into my oracle database table using a php form. When I click submit no data is added. Could someone help me please. I'm new to php/oracle thing.
    NOTE: I don't have any problem connecting to the database using php.
    Here is the code I'm using:
    <?php
    // just print form asking for name if none was entered
    if( !isset($query)) {   
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Name: ";
    echo "<input type=text size=100 maxlength=200 name=data value=\"$data\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // insert client's name
    $query = "INSERT INTO client (name) VALUES ($data)";
    // connect to Oracle
    $username = "xxxx";
    $paswd = "yyyyyy";
    $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
    "(HOST=patriot.gmu.edu)(PORT=1521))".
    "(CONNECT_DATA=(SID=COSC)))";
    $db_conn = ocilogon($username, $paswd, $dbstring);
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>
    Thanks for your help. I will also appreciate a better was to do it.
    Tony

    resumption and jer,
    Sorry I cannot format the code for easy reading!
    The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
    <?php
    // connect to oracle
    $username = "xxxxx";
         $paswd = "yyyyy";
         $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
              "(HOST=patriot.gmu.edu)(PORT=1521))".
              "(CONNECT_DATA=(SID=COSC)))";
         $db_conn = ocilogon($username, $paswd, $dbstring);
    // username and password will be unset if they weren't passed,
    // or if they were wrong
    if( !isset($query)) {
    // just print form asking for account details
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Query: ";
    echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // remove unwanted slashes from the query
    $query = stripslashes($query);
    // run the query
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    // Open the HTML table.
    print '<table border="1" cellspacing="0" cellpadding="3">';
    // Read fetched headers.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
    print '</tr>';
    // Read fetched data.
    while (ocifetch($stmt))
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="v">'.ociresult($stmt,$i).'</td>';
    print '</tr>';
    // Close the HTML table.
    print '</table>';
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>

  • Native SQL: insert data into oracle database, no return message.

    hi,
    the statement : insert into <TableName> values (Source)
    how can I know if the data have already insert to the database table?
    now I have a program have this problem: the data has already exist, but there's no error message return when insert the same data again.
    data: dbs like dbcon-con_name value 'HRGK',
                       dbtype type dbcon_dbms.
    data: sqlerr_ref type ref to cx_sql_exception,
             exc_ref    type ref to cx_sy_native_sql_error,
             error_text type string.
    data: cnt type i,
            i(2) type c.
    set locale language 'E'.
    EXEC SQL.
      CONNECT TO :DBS
    ENDEXEC.
    EXEC SQL.
      SET CONNECTION :DBS
    ENDEXEC.
    EXEC SQL.
      SELECT COUNT(*) from org_unit into :cnt
    ENDEXEC.
    write: / cnt.
    *do.
    i = 'A'.               
    try.
        EXEC SQL.
          BEGIN
           insert into ORG_UNIT ( ORGAN_ID, UNIT_NO, UNIT_NAME, PARENT_ID)
                         values ( 'A', '123412', 'SDFSG', 'DDS');                     " ORGAN_ID is primary key
    " If the data 'A' has already exist in database ORG_UNIT, it will show error message
    " But if I use :I instead 'A', it will not show error message.
            IF SQL%FOUND THEN
               COMMIT;
            END IF;
          END;
        endexec.
        EXEC SQL.
          SELECT COUNT(*) from ORG_UNIT into :cnt
        ENDEXEC.
        write: / cnt.
    catch cx_sy_native_sql_error into exc_ref.
        error_text = exc_ref->get_text( ).
        write: / error_text.
      catch cx_sql_exception into sqlerr_ref.
        perform handle_sql_exception using sqlerr_ref.
    endtry.
    EXEC SQL.
      disconnect :DBS
    ENDEXEC.
    *enddo.
    *&      Form  handle_sql_exception
    form handle_sql_exception
      using p_sqlerr_ref type ref to cx_sql_exception.
      format color col_negative.
      if p_sqlerr_ref->db_error = 'X'.
        write: / 'SQL error occured:', p_sqlerr_ref->sql_code,
               / p_sqlerr_ref->sql_message.                     "#EC NOTEXT
      else.
        write:
          / 'Error from DBI (details in dev-trace):',
            p_sqlerr_ref->internal_error.                       "#EC NOTEXT
      endif.
    endform.                    "handle_sql_exception
    please help to see the words:
    *" If the data 'A' has already exist in database ORG_UNIT, it will show error message*
    *" But if I use :I instead 'A', it will not show error message.*
    in the program.
    Thanks a lot!

    resumption and jer,
    Sorry I cannot format the code for easy reading!
    The page is submitting to itself. See action = \"$uri\". I used the same logic to enter SELECT querries into the database. It pulls and displays data back on the webpage. The code I used for this is below. Compare it with the one above for inserting data into the table.
    <?php
    // connect to oracle
    $username = "xxxxx";
         $paswd = "yyyyy";
         $dbstring = "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)".
              "(HOST=patriot.gmu.edu)(PORT=1521))".
              "(CONNECT_DATA=(SID=COSC)))";
         $db_conn = ocilogon($username, $paswd, $dbstring);
    // username and password will be unset if they weren't passed,
    // or if they were wrong
    if( !isset($query)) {
    // just print form asking for account details
    echo "<form action=\"$uri\" method=post>\n";
    echo "<p>Enter Query: ";
    echo "<input type=text size=100 maxlength=200 name=query value=\"$query\">\n";
    echo "<br><input type=submit name=submit value=Submit>\n";
    echo "</form>\n";
    exit;
    // remove unwanted slashes from the query
    $query = stripslashes($query);
    // run the query
    $stmt = OCIParse($db_conn, $query);
    OCIExecute($stmt, OCI_DEFAULT);
    // Open the HTML table.
    print '<table border="1" cellspacing="0" cellpadding="3">';
    // Read fetched headers.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="e">'.ocicolumnname($stmt,$i).'</td>';
    print '</tr>';
    // Read fetched data.
    while (ocifetch($stmt))
    // Print open and close HTML row tags and columns data.
    print '<tr>';
    for ($i = 1;$i <= ocinumcols($stmt);$i++)
    print '<td class="v">'.ociresult($stmt,$i).'</td>';
    print '</tr>';
    // Close the HTML table.
    print '</table>';
    OCIFreeStatement($stmt);
    OCILogoff($db_conn);
    ?>

  • Insert data into oracle based on sql server data(here sql server acting as source to oracle and destination to oracle)

    Source is Oralce. Destination is SQL Server.
    Requirement - I have to fetch sql server server data (empid's) based emp table  and send this as input data to oracle to fetch and empid's are common.
    I cannot use merge or loopkup or for each as oracle have too many records.
    For example - In MS SQL - i have empid=1,2..Only these records, I have to fetch from oracle source into sql server destination. For this, I have adopted the below approaches...The major problem I face, when i build a empid's as a string, it is taking only
    4000 chars. My string lenght is 10000. How do I breakup this string lengh and send to data flow task till all broken strings length passed to DFT.
    Approach-1
    created two variables - oraquery string, empid string
    step1 - ms sql database - created sql task - declare @empid varchar(max)
    SELECT @empid=
    Stuff((SELECT ',' + empid
            FROM  
            (SELECT  DISTINCT  convert(varchar(10),empid ) empid FROM emp
             ) x
            For XML PATH ('')),1,1,'')
    select @empid =    '(' +  @empid + ')'
    select @empid
    resultset=singlerow
    resultset=resultname=0; variablename=User::empid (empid is declared as string)
    step2 - oracle database - created data flow task
    created oledb source
    I put  this statemnt in oraquery expression - "select * from dept where dept in  "
    +  @[User::empid] + "
    expression=true
    [OLE DB Source [1]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E14.
    An OLE DB record is available.  Source: "Microsoft OLE DB Provider for Oracle"  Hresult: 0x80040E14  Description: "ORA-00936: missing expression".
    Approach-2
    created three variables - oraquery string, empid  int, loop object--when I put int then it is automatically setting to 0
    step1 - ms sql database - created sql task - SELECT  DISTINCT  convert(varchar(10),empid ) empid FROM emp
    resultset=fullresult
    resultset=resultname=0; variablename=User::loop
    step2 - created a for each loop container
    for loop editor - for each ado ennumerator
    enumerator configuration - loop
    variablemapping - variable=empid;index=0
    step3 - oracle database - created data flow task (outside for each loop. If I put inside it is taking long time)
    created oledb source
    I put  this statemnt in oraquery expression - "select * from dept where dept in  "
    +  @[User::empid] + "
    expression=true
    Data inserting in a destination table but  empid=0.

    Sorry didnt understand if your step3 is outside loop how
    @[User::empid] will get values for the empids from User::loop. The iteration happens inside loop so you
    need to have a logic to form the delimited list inside using a script task or something and concatenating everything and storing to variable @[User::empid]
    . Then only it will have full value used to be used in step3 query
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • DB Adaptor and inserting dates into Oracle DB

    Hi,
    I'm using the Oracle DB Adaptor to poll a table in one instance (using logical delete) and to invoke a DB adaptor to insert/merge a row into a separate instance.
    NOTE :both tables have different definitions.
    I am using a BPEL transform to tfrm the data received from the poll/receive step.
    I need to transform some date variables and the target date column CreatedTs is expecting to receive the date in the Oracle DD-MON-YYYY format (can't change the NLS_DATE_FORMAT value for the target).
    I'm trying to use the provided xsl:formatDateTime function with various formats but can't get anything useful to work.
    Any ideas ?

    Hi there,
    Please see the Bpel developer's guide at otn.oracle.com/bpel. There are two troubleshooting entries of interest:
    dateTime Conversion Exceptions
    and
    Issues with Oracle DATE
    Just search on these strings.
    The xsl:formatDateTime function is for converting xs:dateTimes to strings. If you already have a value in proper ISO dateTime format do not try to convert it. The database adapter likes that format only.
    If you are starting with a string like DD-MON-YYYY and have to convert it into a legal dateTime, then that is hard as functions like xsl:formatDateTime go the opposite way only, i.e. dateTime to string, not string to dateTime.
    A few days we had a customer who needed to convert MM/DD/YYYY to a dateTime. I am copying the solution here.
    Used the expression builder in the assign to build:
    orcl:format-string('{0}-{1}-{2}T00:00:00', substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 7, 4), substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 4, 2), substring(bpws:getVariableData('Receive_1_receive_InputVariable','ReceiverDeptCollection','/ns2:ReceiverDeptCollection/ReceiverDept/receiverEmpCollection/ReceiverEmp/someDate'), 1, 2))
    That worked in converting i.e. 01/05/2005 to 2005-01-05T00:00:00.
    To convert DD-MON-YYYY that is tricky because you need to first convert DEC to 12, SEP to 09, and so on. I couldn't figure out how to do that but another on this forum may be able to help you out. If you are really stuck and you know the database accepts i.e DD-MON-YYYY, you could tell the adapter that the date field is a string, then it will simply pass the value as is which should work.
    To do that please see chapter 20 of the bpel dev guide, and search for
    Configuring Offline Database Tables
    Use that to change the type to basic varchar2 in the BPEL designer so the dbadapter will think the column is a string and not convert it.
    Thanks
    Steve

  • Insert CLOB into oracle under weblogic

    Situation: running my servlet under weblogic, want to insert more than 4000 characters into CLOB of oracle 8.1.7
    Problem: cannot be done by using code which is able to do it under tomcat
    i use this code in tomcat:
    import java.sql.*;
    import oracle.sql.CLOB;
    import oracle.jdbc.driver.OracleResultSet;
    con.setAutoCommit(false);
    Statement stmt = con.createStatement();
    rs = stmt.executeQuery("SELECT clob_field FROM table where rid=id FOR UPDATE");
    rs.next();
    CLOB clob = ((OracleResultSet)rs).getCLOB(1);
    Writer writer = clob.getCharacterOutputStream();
    writer.write(dataString);
    writer.close()l
    con.commit();
    con.setAutoCommit(true);
    stmt.close();
    after that i know that i can't use API of oracle when i'm using weblogic (e.g. oracle.sql.CLOB)
    and i find this code from other user:
    import weblogic.jdbc.vendor.oracle.OracleThinClob;
    import java.io.*;
    import java.sql.*;
    PreparedStatement stmt = con.prepareStatement ( "INSERT INTO database VALUES ( ?, EMPTY_CLOB() )" );
    stmt.setInt ( 1, 1 );
    // inserts a new entry with an empty clob object
    stmt.executeUpdate ();
    if ( stmt != null )
    stmt.close();
    // retrieves CLOB-Object
    stmt = con.prepareStatement ( "SELECT clob_field FROM database WHERE id=?" );
    stmt.setInt ( 1, 1 );
    ResultSet rs = stmt.executeQuery ( );
    if ( rs.next() )
    Clob cl = rs.getClob(1);
    Writer clobWriter = ((OracleThinClob)cl).getCharacterOutputStream();
    // Open the sample file as a stream for insertion into the Clob column
    File testFile = new File ( "file.txt" );
    FileReader testReader = new FileReader ( testFile );
    // buffer to hold data to being written to the clob.
    char[] cBuffer = new char[((OracleThinClob)cl).getBufferSize()];
    // Read data from file, write it to clob
    int iRead = 0;
    while( (iRead= testReader.read(cBuffer)) != -1 )
    clobWriter.write( cBuffer, 0, iRead);
    testReader.close();
    clobWriter.close();
    if ( rs != null )
    rs.close();
    if ( stmt != null )
    stmt.close();
    // update clob-data in database
    stmt = con.prepareStatement ( "UPDATE database SET clob_field = ? WHERE id = ?" );
    stmt.setClob ( 1, cl );
    stmt.setInt ( 2, 1 );
    stmt.executeUpdate();
    it throws java.lang.ClassCastException: oracle.sql.CLOB
    but i haven't imported or used any API from oracle.........
    please help
    thanks

    hi,
    unfortunatly, you can't do this with welbogic6.1 because it 'manage' itself oracle librairies (weblogic.jar),
    here is the way i solved the pb for BLOB :
    i replaced :
    BLOB blob = ((OracleResultSet)rs).getBLOB(1);
    by
    weblogic.jdbc.rmi.SerialOracleBlob cast1 =(weblogic.jdbc.rmi.SerialOracleBlob)rs.getBlob("myBlob");
    weblogic.jdbc.rmi.internal.OracleTBlobImpl cast2 =(weblogic.jdbc.rmi.internal.OracleTBlobImpl)cast1.getTheRealBlob();
    BLOB myBlob = (oracle.sql.BLOB)cast2.getTheRealBlob();
    it is the same for clob (i suppose ^_^)
    hope this helps !
    Badr.

  • Inserting dates into oracle

    I'm trying to insert a date into a table...I'm not getting an error - but Oracle is not inserting a record.
    string some_date = "10/27/2004";
    In Oracle I'm converting the date string using the TO_DATE function, the column is a DATE datatype.
    TO_DATE(p_some_date,'DD-MON-YYYY')
    Any suggestions?

    The format used to display or input a date has no bearing on the way it is stored. In Oracle a date is stored using 7 bytes as follows:
    yy 1 - trunc(yy / 100) + 100
    yy 2 - mod(yy, 100) + 100
    mm 3 - simple month (1-12)
    dd 4 - simple day (1-31)
    hh 5 - hh + 1
    mm 6 - mm + 1
    ss 7 - ss + 1You can see how this format relates to a "displayed date" as follows:
    SQL> connect /
    Connected.
    SQL> create table t
      2  (
      3    c date
      4  );
    Table created.
    SQL> insert into t values (sysdate);
    1 row created.
    SQL> select to_char(c, 'DD-MON-YYYY HH24:MI:SS'), dump(c) from t;
    TO_CHAR(C,'DD-MON-YY DUMP(C)
    28-OCT-2004 19:40:45 Typ=12 Len=7: 120,104,10,28,20,41,46
    1 row selected.However, you are telling Oracle that the format of the input date string is "DD-MON-YYYY" but it is not. The format of the input string is "MM/DD/YYYY". If you want to pass the string in that format just change your to_date to match that format (i.e. to_date(some_date, 'DD/MM/YYYY')
    - Mark

  • How to insert date into oracle database

    Hi, there,
    I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
    javax.servlet.jsp.JspException:
    INSERT INTO DATE_TEST
    (date_default,date_short,date_medium)
    values(?,?,?)
    : Invalid column type
    I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.util.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
    <%
    Calendar now;
    Calendar rightNow = Calendar.getInstance();
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>
    Hello World
    </title>
    </head>
    <body>
    <h2>
    The current time is:
    </h2>
    <p>
    <%= new java.util.Date() %></p>
    <%
    java.util.Date d=new java.util.Date();
    java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
    out.print(d1.toString());
    %>
    <sql:update>
    INSERT INTO DATE_TEST
    (DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
    VALUES(?,?,?)
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    </sql:update>
    </body>
    </html>
    thank you very much for the great help!!

    Hi, there,
    I want to insert date information to oracle database in a jsp page using JSTL. but always got wrong message:
    javax.servlet.jsp.JspException:
    INSERT INTO DATE_TEST
    (date_default,date_short,date_medium)
    values(?,?,?)
    : Invalid column type
    I don't know how to convert java date type to oracle date type or vice versa. the following is the source code(all the fields of DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM are oracle date type. and even I want to insert d instead d1, I got the same wrong message)
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.util.*" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
    <%
    Calendar now;
    Calendar rightNow = Calendar.getInstance();
    %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>
    Hello World
    </title>
    </head>
    <body>
    <h2>
    The current time is:
    </h2>
    <p>
    <%= new java.util.Date() %></p>
    <%
    java.util.Date d=new java.util.Date();
    java.sql.Date d1=new java.sql.Date(d.getYear(),d.getMonth(),d.getDate());
    out.print(d1.toString());
    %>
    <sql:update>
    INSERT INTO DATE_TEST
    (DATE_DEFAULT,DATE_SHORT,DATE_MEDIUM)
    VALUES(?,?,?)
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    <sql:dateParam value="${d}" type="date" />
    </sql:update>
    </body>
    </html>
    thank you very much for the great help!!

  • Error trying to insert xml into Oracle table

    Hi -
    I am trying to (a)read a row from emp table and output the results in xml format
    and (b) insert this row to another emp_new table (same structure as emp).
    When I run it here is what I get:
    OUTPUT IS:
    <?xml verions='1.0'?>
    <Employee>
    <Emp num="1">
    <EMPNO>7369</EMPNO>
    <ENAME>Smith</ENAME>
    <JOB>Clerk</JOB>
    <MGR>7902</MGR>
    <HIREDATE>12/7/1980</HIREDATE>
    <SAL>800</SAL>
    <DEPTNO>20</DEPTNO>
    </Emp>
    </Employee>
    Exception in thread "main" oracle.xml.sql.OracleXMLSQLException:
    No rows to modify -- the row enclosing tag is missing. Specify
    the correct row enclosing tag.
    etc...
    The row enclosing tag is given by setRowTag("Emp").
    What's wrong here? Any ideas?
    PS: To Ambrose Padilla: Your response was helpful. Thank you.
    Program
    import java.sql.*;
    import oracle.xml.sql.query.*;
    import oracle.jdbc.driver.*;
    import oracle.xml.sql.dml.*;
    class testXML
    public static void main(String[] args) throws SQLException
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    //initialize a JDBC connection
    Connecton conn = DriverManager.getConnection("jdbc:oracle:thin:mytest:1521:acme", "scott", "tiger");
    //initialize the OracleXMLQuery
    OracleXMLQuery qry =
    new OracleXMLQuery(conn,"select * from emp where rownum < 2");
         // set the document name
         qry.setRowsetTag("Employee");
         // set the row element name
         qry.setRowTag("Emp");
         // get the XML result
         String xmlString = qry.getXMLString();
         // print result
         System.out.println(" OUPUT IS:\n"+xmlString);
         OracleXMLSave sav = new OracleXMLSave(conn,"emp_new");
         sav.insertXML(xmlString);
         sav.close();
    }

    Try inserting
    sav.setRowTag("emp");
    before calling insertXML.

  • Unable to insert rows into ORACLE database using ABAP code

    Hai,
    I am facing problem while creating a table in Oracle database with 15 attributes in a table. To create a table I am using the classes:
                      cl_sql_connection  -
    > to create the connection           
                      cl_sql_statement  -
    > to execute the query
    This I used by reffering the SAP program ADBC_DEMO. Without any trouble I am able to create a Table with 6 attributes by following the same procedure in ABCD_DEMO program but the same is not working for the table with 15 attributes .
    Please help me.
    Regards,
    Swetha

    Hai,
    here is my code.
    DATA: V_con_name TYPE dbcon-con_name,
          con_ref TYPE REF TO cl_sql_connection,
          sqlerr_ref TYPE REF TO cx_sql_exception,
          c_tabname  TYPE string VALUE `TO_DETAILS`,
          c_coldefs  TYPE string.
    DATA: IT_ORA LIKE ZVOP_X_ORA_UPDATE OCCURS 0 WITH HEADER LINE.
       V_CON_NAME = 'TVL-DSS-01'.
       concatenate '(LGNUM CHAR(3) primary key,'
                     'TANUM VARCHAR2(10),'
                     'FLAG  CHAR(1),'
                     'BDATU timestamp(3),'
                     'TAPOS VARCHAR2(4),'
                     'MATNR CHAR(18))'
                      'VLQNR VARCHAR2(10),'
                      'VLPLA CHAR(10),'
                      'VLBER CHAR(3),'
                      'NLPLA CHAR(10),'
                      'NLBER CHAR(3),'
                      'VDATE DATE(3) ,'
                      'BNAME CHAR(12),'
                      'VTIME DATE(4),'
                      'PROTYPEFLAG CHAR(1),'
                      'PROCOMFLAG  CHAR(1))'
                into c_coldefs separated by space  .
      TRY.
        PERFORM: CONNECT USING V_CON_NAME CON_REF,
                 CREATE_TABLE USING con_ref c_tabname c_coldefs.
          CATCH cx_sql_exception INTO sqlerr_ref.
            TB_ERROR-MESSAGE = SQLERR_REF->SQL_MESSAGE.
            APPEND TB_ERROR. CLEAR TB_ERROR.
    ENDTRY.
    form create
    form CONNECT using   p_con_name TYPE dbcon-con_name
                         p_con_ref  TYPE REF TO cl_sql_connection
                 RAISING cx_sql_exception.
      p_con_ref = cl_sql_connection=>get_connection( p_con_name ).
    endform.                    " CONNECT
    form create
    form   CREATE_TABLE USING   p_con_ref TYPE REF TO cl_sql_connection
                              p_tabname TYPE string
                              p_coldefs TYPE string
                      RAISING cx_sql_exception.
       DATA:
            l_sqlerr_ref TYPE REF TO cx_sql_exception,
            l_stmt       TYPE string,
            l_stmt_ref   TYPE REF TO cl_sql_statement.
    create a statement object
       l_stmt_ref = p_con_ref->create_statement( ).
    create the statement string
       CONCATENATE
         'create table' p_tabname p_coldefs
         INTO l_stmt SEPARATED BY space.
    execute the DDL command; catch the exception in order to handle the
    case if the table already exists
        TRY.
          l_stmt_ref->execute_ddl( l_stmt ).
        CATCH cx_sql_exception INTO l_sqlerr_ref.
          IF l_sqlerr_ref->dbobject_exists = 'X'
             OR l_sqlerr_ref->internal_error = 1024.
          table already exists => drop it and try it again
            PERFORM:
              drop_table   USING p_con_ref p_tabname,
              create_table USING p_con_ref p_tabname p_coldefs.
          ELSE.
            RAISE EXCEPTION l_sqlerr_ref.
          ENDIF.
      ENDTRY.
    endform.                    " CREATE_TABLE
    please do help me
    Regards,
    Swetha

Maybe you are looking for

  • Opening Camera Raw - Windows XP

    Sorry if this seems a bit too obvious a question! I installed CS2 about 18 months ago, and never needed to use Camera Raw until now. I spent ages trying to find it on my computer, looking through photoshop, Bridge, Windows Explorer but just couldnt f

  • System Settings Reset After External Drive is Shut Down

    I have my System Settings set to have the Autosave Vault, Thumbnail Cache and Waveform Cache live on my external media drive, not my internal boot drive. However, every time I turn off my media drives, the program resets these folders onto my boot dr

  • IWeb Failure

    I am using iWeb to make a webpage and after I did so, I saved it and then proceeded to shut down my mac. Now iWeb will not start up with any templates or anything, it simply just says "opening" and then nothing happens. I cannot access the toolbar, a

  • Upgrade on mid 2012 mbp 15 inch

    i have a mid 2012 mbp and i just want to know will a apple shop ugrade my ram as i dont really want to do it myself as not really worked on macs before ?

  • Problems installing latest version Adobe Reader

    Trying to install latest version of Adobe Reader...download stops.."An error has occurred in the script on this page... Line:     1 Char:     13128 Error:     'ActionGtbCheck' is undefined Code:     0 URL:     http://127.0.0.1:1125/app/_js/adobe.js j