Inserting a record in an Oracle database in Teststand

I am trying to create a new record into an Oracle database table using the insert command in Teststand 2.0. I have been able to do it using LabView. The problem is that the record does not exist as yet. So I don't what I should do in the OPEN SQL statement which creates a select statement. Also, when I try to do the operations the I can only see the columns with the "set and put" condition. "Put" shows me no columns. Using set and put I recieve an error telling me that the record is not updatable.
I am not rying to update a record. I am trying to enter a new record. I do set the new record indication the data operation step.
Is there a good write-up for using TestStand 2.0 step database operations? Is there any gotch-
yous with 2.0 that were corrected in 3.0?

I think what you want to use is an INSERT statement rather than a select. See http://www.techonthenet.com/sql/insert.htm for an example. If you create an "Open SQL" step, then edit the SQL statement, you can create a string expression that has includes your parameters.
Example: "INSERT INTO supplier
(supplier_id, supplier_name)
VALUES
(" +Str(MyNumericValue)+ ", '" + MyStringValue+ "');"
Beware of single quotes (SQL string delimiter) versus double quotes (TestStand string delimiter).

Similar Messages

  • Inserting a record in an Oracle database

    Hi,
    I would appreciate if anyone could provide a code snippet showing how to insert a record into an Oracle 9i database. The columns in the database table have datatypes such as NUMBR, VACHAR2, and DATE. Some of the columns may be null. The input text is in the form of String. The string from the date fields is in the form 'YYYY-MM-DD HH:MI:SS PM' and I have converted these to java.sql.Date objects. How do I deal with nulls?
    Thanks.

    I am having a problem inserting a date field. The input string is in the form YYYY-MM-DD HH:MM PM. I converted the input string to a java.sql.Date object before trying to post the record. However, an example of what gets inserted is: '2001-12-04 12:00 AM' even if the input date string is: "2001-12-04 04:40". In other words, the hour and minute portions do not get inserted correctly.
    Why is this and how can I resovle this? My code is as follows: (try/catch blocks are not shown)
    String m_HireDate = "2001-12-04 04:40 PM"; // Input string.
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm a");
    java.utilDate m_UtilDate = sdf.parse(URLDecoder.decode(m_HireDate);
    java.sql.Date m_SQLDate = new java.sql.Date(m_UtilDate);
    Connection con = DriverManager.getConnection(url,"abc"," abc") ;
    Statement stmt =
    con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
    ResultSet.CONCUR_UPDATABLE) ;
    String sqlselect = "SELECT EMP_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, HIRE_DATE, FROM EMP" ;
    ResultSet rs = stmt.executeQuery(sqlselect) ;
    // EMP_ID is the primary key. It has a datatype of NUMBER in the database tabe
    int EMP_ID1 = Integer.parseInt(EMP_ID);
    rs.moveToInsertRow() ;
    rs.updateInt("EMP_ID", EMP_ID1) ;
    rs.updateString("FIRST_NAME", "John" );
    rs.updateString("MIDDLE_NAME", "M" );
    rs.updateString("LAST_NAME", "Smith");
    rs.updateDate("HIRE_DATE" , m_SQLDate); //m_SQLDate is a java.sql.Date object
    rs.insertRow() ;
    Now get the inserted value from SQLPLUS:
    SELECT TO_CHAR(HIRE_DATE, 'YYYY-MM-DD HH:MI PM') FROM EMP WHERE EMP_ID =EMP_ID1;
    The output is: "2001-12-04 12:00 AM"
    Thanks.

  • 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 Insert a record into a MySql database.

    Hi,
    In an earlier question I was advised to use the Adobe extension to get access to database connectivity and server behaviours.
    That extension is now installed. Whether it is functional is another question.
    To chewck it out I follwed exactly the steps set out in Lessons 5 and 6 of Dreamweaver CS5 with PHP
    When trying to make a database connection I am still getting the 404 error I mentioned in an earlier email. However if I type the database name (phpcs5) into the “select database” box and test it says I connected successfully and I can see the user’s table in the database panel.
    So far apparently so good.
    I have created the cs5wtite and cs5read connections to the phpcs5 database
    I set up the insert record behaviour using “Form1!, “cs5write”, “users”,
    Everything went as per the manual, the file turned aqua in Live view.
    I entered data and ctrl/clicked “Sign me up” button and nothing happened.
    No data was entered into the database and I was not passed to login.php.
    I deleted everything from the computer, restarted the pc and started again from scratch.
    The result was the same. Nothing
    My one concern was line 49  $insertGoTo = " login.php";
    The file is in registration so I changed to $insertGoTo = "registration/login.php";
    but that made no difference.
    Is there any logging or error reporting I can use to see where it is going wrong?
    This is the add user page generated
    <?php require_once('../Connections/cs5write.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
      $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO users (first_name, family_name, username, password) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['first_name'], "text"),
                           GetSQLValueString($_POST['surname'], "text"),
                           GetSQLValueString($_POST['username'], "text"),
                           GetSQLValueString($_POST['password'], "text"));
      mysql_select_db($database_cs5write, $cs5write);
      $Result1 = mysql_query($insertSQL, $cs5write) or die(mysql_error());
      $insertGoTo = "login.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Add new user</title>
    <link href="../../styles/users.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <h1>Sign Up Now</h1>
    <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
      <fieldset>
        <legend>Just a few details and you&rsquo;re in</legend>
        <p>
          <label for="first_name">First name:</label>
          <input type="text" name="first_name" id="first_name" />
        </p>
        <p>
          <label for="surname">Family name:</label>
          <input type="text" name="surname" id="surname" />
        </p>
        <p>
          <label for="username">Username:</label>
          <input type="text" name="username" id="username" />
        </p>
        <p>
          <label for="password">Password:</label>
          <input type="password" name="password" id="password" />
        </p>
        <p>
          <label for="conf_password">Confirm password:</label>
          <input type="password" name="conf_password" id="conf_password" />
        </p>
        <p>
          <input type="submit" name="add_user" id="add_user" value="Sign me up!" />
        </p>
      </fieldset>
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
    </body>
    </html>
    This is the connection page
    <?php
    # FileName="Connection_php_mysql.htm"
    # Type="MYSQL"
    # HTTP="true"
    $hostname_cs5write = "localhost";
    $database_cs5write = "phpcs5";
    $username_cs5write = "cs5write";
    $password_cs5write = "Smp??2014";
    $cs5write = mysql_pconnect($hostname_cs5write, $username_cs5write, $password_cs5write) or trigger_error(mysql_error(),E_USER_ERROR);
    ?>
    I understand this solution is a wokraround Adobe privided whist deprecating its use.
    In the earlier question I asked if there was another way to work with a database. Someone posted a link to an Object orientated solution but It was way beyond my coding abilities. I wonder are there any other solutions out there?
    Thanks for any input

    Hi,
    Thanks for the test.
    I used your amendment but still got nothing, no record in database and not sent to login page..
    I also tried this code below. It returns "Record added to database" but it was not.
    Something strange going on.
    <?PHP
    $user_name = "cs5write";
    $password = "Smp??2014";
    $database = "phpcs5";
    $server = "127.0.0.1";
    $db_handle = mysql_connect($server, $user_name, $password);
    $db_found = mysql_select_db($database, $db_handle);
    if ($db_found) {
    $SQL = "INSERT INTO users (first_name, surame, username, password) VALUES) VALUES ('Albert', 'Dent', 'hitchiker', 'space')";
    $result = mysql_query($SQL);
    mysql_close($db_handle);
    print "Records added to the database";
    else {
    print "Database NOT Found ";
    mysql_close($db_handle);
    ?>

  • How to insert data type information to 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!!

    I don't have time to read thru all your code, but I hope this information will help you.
    It depends on how the Oracle database was set up. Usually, the date format is something like this: '27-MAY-2003 22:10:00'. A quick check will be to run this SQL script in SQLPlus:
    select sysdate from dual;
    You have to convert the date from textbox or whatever to this exact Oracle format. Otherwise, Oracle will not accept it. It is very picky on that. I found the best way is to do the conversion inside the SQL statement. It makes life so much easier.
    Hope this helps.

  • Import/insert data from XML into Oracle database tables?

    Hi. (I am using JDeveloper 10.1.3.3.0 and Oracle 10g)
    I have been able to export the data from one of my database tables by using a View Object and .writeXML.
    Now, I want to take an xml file that is formatted in the same way as what is spit out by the writeXML and put that info in my database table. I followed online examples and have tried using .readXML like so:
    Element element = XMLDoc.getDocumentElement();
    vo.readXML(element, -1);
    I know it is sort of working, because at first I got an error message that one of the required attributes was missing. So, I added that attribute to my xml file and ran my code. No errors. But, I checked my database, and the new records were not added.
    Is there something I have done wrong? Or is there perhaps something I left out? I also noticed there were several versions of readXML like readFromXML. Which one should I use and how?
    Thanks.

    KUBA, I changed my code to match your example:
    DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    File xmlFile = new File("C:/myfilehere.xml");
    Document doc = db.parse(xmlFile);
    Element element = doc.getDocumentElement();
    vo.readXML(element, -1);
    vo.getDBTransaction().commit();
    I still get no errors, but my database table has no new records.
    Any ideas why?
    Thanks.

  • 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

  • Last or oldest record in a oracle database table

    I want to fetch oldest record in database table based on llast updated date ; I tried following queries..it gave me different results
    SELECT EVENT_ID, RETENTION_TS
    FROM ( SELECT EVENT_ID, RETENTION_TS, RANK() OVER (ORDER BY RETENTION_TS) RETENTION_TS_RANK
    FROM EVENT )
    WHERE RETENTION_TS_RANK <= 1;
    select * from EVENT where rowid=(select min(rowid) from EVENT);
    SELECT *
    FROM (select * from EVENT ORDER BY RETENTION_TS) EVENT2
    WHERE rownum <= 1
    ORDER BY rownum DESC;
    Above query takes like 10 to 20 mins to return me the record.
    Thanks in advance..

    feritz wrote:
    I want to fetch oldest record in database table based on llast updated date ; I tried following queries..it gave me different results
    SELECT EVENT_ID, RETENTION_TS
    FROM ( SELECT EVENT_ID, RETENTION_TS, RANK() OVER (ORDER BY RETENTION_TS) RETENTION_TS_RANK
    FROM EVENT )
    WHERE RETENTION_TS_RANK <= 1;
    select * from EVENT where rowid=(select min(rowid) from EVENT);
    THAT surely won't give a correct result. Rowid is the address of the row ... it has nothing to do with the age of the row.
    What is the datatype of RETENTION_TS?
    SELECT *
    FROM (select * from EVENT ORDER BY RETENTION_TS) EVENT2
    WHERE rownum <= 1
    ORDER BY rownum DESC;
    Above query takes like 10 to 20 mins to return me the record.
    Thanks in advance..See "how can I improve he performance of my query" in the FAQ at https://forums.oracle.com/forums/ann.jspa?annID=1535

  • How to insert a record in to oracle table from Java which has a oracle LONG Field?

    The problem is only 80 char's inserted in to the LONG FIELD which happend to me when i run the same insert statement from SQL plus.
    Here is the code....
    java.io.File inputFile = new java.io.File("input.txt");
    int inputFileLen = (int) inputFile.length();
    java.io.InputStream ipStream = new java.io.FileInputStream(inputFile);
    System.out.println(inputFileLen);
    PreparedStatement myStmt = conn.prepareStatement("insert into LONG_EXAMPLE (notes,name)values(?,?)");
    myStmt.setAsciiStream(1, ipStream, inputFileLen);
    myStmt.setString(2,"Steve");
    int res = myStmt.executeUpdate();
    myStmt.close();
    Note : Here the size of the input.txt 250 bytes , 1KB.
    Thanks in advance......:-)
    Cheers,
    Vetri !

    Hien
    I had a similar requirement to you and put the code on a push button. In my case the reports are being run interactively to the screen and then printed, and I have no way to know whether the report had actually been printed, so we rely on the user pressing the button. Of course there is a danger that the user forgets to press the button, but in our situation that would not be disasterous. Whatever method is used, I don't think there is any way to be sure that it has actually come out of the printer.

  • Sequence on Oracle Database column

    Hi All,
    In my scenario I have to insert data/records into a Oracle Database.The Database table has primary key with Sequence(sequence will generate next unique value for the new record to be inserted). So how can I insert the records into that table. I have created JDBC receiver message type for that particular table.
    Please let me know the possible ways.
    Thanks
    Praveen Kumar

    Using Stored Proecdure is one option.Write a stored procedure that takes the rest of the column values as inputs and then uses the sequencne plus these values to insert data into the datbase.
    Can you provide an example of how the insert query with the Call to the Sequence looks so that a standard insert option can also be looked into?
    Regards
    Bhavesh

  • Auto Increment ID Field Table in the Oracle Database (insert new record)

    I have been using the MySQL. And the ID field of the database table is AUTO INCREMENT. When I insert a new record into a database table, I can have a statement like:
       public void createThread( String receiver, String sender, String title,
                                 String lastPostMemberName, String threadTopic,
                                 String threadBody, Timestamp threadCreationDate,
                                 Timestamp threadLastPostDate, int threadType,
                                 int threadOption, int threadStatus, int threadViewCount,
                                 int threadReplyCount, int threadDuration )
                                 throws MessageDAOSysExceptionand I do not have to put the ID variable in the above method. The table will give the new record an ID number that is equivalent to the ID number of the last record plus one automatically.
    Now, I am inserting a new record into an Oracle database table. I am told that I cannot do what I am used to doing with the MySQL database.
    How do I revise the createThread method while I have no idea about what the next sequence number shall be?

    I am still very confused; in particular, the Java part. Let me try again.
    // This part is for the database table creation
    -- Component primary key sequence
    CREATE SEQUENCE dhsinfo_page_content_seq
        START WITH 0;
    -- Trigger for updating the Component primary key
    CREATE OR REPLACE TRIGGER DHSInfoPageContent_INSERT_TRIGGER
        BEFORE INSERT ON DHSInfoPageContent //DHSInfoPageContent is the table name
        FOR EACH ROW WHEN (new.ID IS NULL) // ID is the column name for auto increment
        BEGIN
            SELECT dhsinfo_page_content_seq.Nextval
            INTO :ID
            FROM DUAL;
        END;/I am uncertain what to do with my Java code. (I have been working with the MySQL. Changing to the Oracle makes me very confused.
       public void updateContent( int groupID, String pageName, int componentID,
                                  String content, Timestamp contentCreationDate )
                                   throws contentDAOSysException
       // The above Java statement does not have a value to insert into the ID column
       // in the DHSInfoPageContent table
          Connection conn = null;
          PreparedStatement stmt = null;
          // what to do with the INSERT INTO below.  Note the paramether ID.
          String insertSQL = "INSERT INTO DHSInfoPageContent( ID, GroupID, Name, ComponentID, Content, CreationDate ) VALUES (?, ?, ?, ?, ?, ?)";
          try
             conn = DBConnection.getDBConnection();
             stmt = conn.prepareStatement( insertSQL );
             stmt.setInt( 1, id ); // Is this Java statement redundant?
             stmt.setInt( 2, groupID );
             stmt.setString( 3, pageName );
             stmt.setInt( 4, componentID );
             stmt.setString( 5, content );
             stmt.setTimestamp( 6, contentCreationDate );
             stmt.executeUpdate();
           catch
           finally

  • How to find out insertion time of records in an oracle table

    Hi everybody,
    I have a table with about 50,000 records in my Oracle database and there is a date column which shows the date that each record get inserted to the table, for example 04-Aug-13.
    Is there any way that I can find out what time each record has been inserted?
    For example: 04-Aug-13 4:20:00 PM. (For my existing records not future ones)
    I searched over the internet and find some results but none of them seem to be practical.
    Thanks for your help.

    I have a table with about 50,000 records in my Oracle database and there is a date column which shows the date that each record get inserted to the table, for example 04-Aug-13.
    Is there any way that I can find out what time each record has been inserted?
    For example: 04-Aug-13 4:20:00 PM. (For my existing records not future ones)
    First you need to clarify what you mean by 'the date that each record get inserted'.  A row is not permanent and visible to other sessions until it has been COMMITTED and that commit may happen seconds, minutes, hours or even days AFTER a user actually creates the row and puts a date in your 'date column'.
    Second - your date column, and ALL date columns, includes a time component. So just query your date column for the time.
    The only way that time value will be incorrect is if you did something silly like TRUNC(myDate) when you inserted the value. That would use a time component of 00:00:00 and destroy the actual time.

  • Insert multiple records into Oracle using Java

    Hi,
    Has anyone tried to insert multiple records into an Oracle table from Java? I have my data in a Java collection.Can I send a Java Collection to an Oracle Package as a PL/SQL Table Type? My problem is I dont want to instantiate a CallableStatement object everytime I do an insert. Instead I want to do that only once and then insert multiple records in one operation.
    Any suggestions will be appreciated,
    Thanks,
    Alex

    Hi Mensa,
    I went thru the code example in your book in chapter 8 (downloaded it from OTN). It looks like the java code for "public class myPLSQLIndexTab" might be a java stored procedure stored in the oracle database?
    Pardon my ignorance because I've never worked on java code in the oracle database itself but how would I call such a program outside the oracle database? For example say I have a batch job that downloads data from a webservice and that batch job is written in java and its sitting on a batch server somewhere on the network. But the java program that inserts data into the database is sitting in the oracle database (also somewhere in the same network). How can the java code sitting on the batch server talk to the java code sitting on the oracle server? Is it the same as calling a pl/sql package using CallableStatement?
    Thanks
    Alex

  • Inserting a record in database using Java

    Hello All,
    i have connected a Java Application to the SAP BO Database using DI API and would like to insert a record in the demo database without using an SQL Query "Insert into table1...." but using the following snippet though i dont know if am using the right classes :
                                    ICompany company = conn.getCompany();
                                     IItems items = SBOCOMUtil.newItems(company);
                        items.setItemCode("124");
                        items.setItemName("VXC");
                        items.setItemsGroupCode(1);
                        items.setItemType(0);
                        items.add();
    What i am trying to do here is insert a new record but i dont know where i should mention the table name for e.g. there is table called OITM in the demo database from BO where i would like to create a new Item.
    Could anyone help me here.
    Regards,
    Amit Hingher

    Hi Amit,
    You don't need to reference the destination tables as there is a class for each data object in the DI API and the data tables associated with the object are hardcoded in the class.
    The Items class is the correct one for adding item master data (ie data in OITM, OITW etc).
    I'm not very familiar with these Java objects but I think the add method should return an integer value (as it does with the COM objects used by .NET). If the return value is zero then the add was successful. If the add failed then you'll get a non-zero value which is the SBO error code.
    Kind Regards,
    Owen

Maybe you are looking for