Handle the Insert statement my self.

Hi
I am looking to handle the insert statement myself via a page process. The user is only required to populate 3 fields, and I want to insert the others with clock numbers and sysdate. In forms I would have block_name.field_name is there something similar in APEX.
Insert into institution
(ID ,
CLOCK_NO ,
INSTITUTION ,
MEMBERSHIP_NO ,
MENTOR,
USER_NAME ,
UPDATE_DATE )
values
(institution_seq.next_val,
:p_clock_no,
institution,
membership_no,
mentor,
:p_clock_no,
sysdate);
Thanks
Fiona

Fiona,
Do you mean you want to pickup values from page items, which have been populated by the User? If so you reference the page items with :PX_PAGE_ITEM_NAME
Cheers,
Mike

Similar Messages

  • Using the Insert statement in a Java program without hardcoding the data

    hello.
    this is james mcfadden. i have developed a program called Demo.java, which is used with another program called QueryTableModel.java (a program that allows data to be viewed in a JTable). The Demo.java program displays a menu, connects to a database, allows the user to add data into the database and allows the user to view data that is already in the database. I have a problem with the Demo.java program. I have hardcoded the Insert statement in it. How do you use the Insert statement to put data into a database without hardcoding the data?
    import java.awt.*;//Contains all of the classes for creating user interfaces and for painting graphics and images
    import java.awt.event.*;//Provides interfaces and classes for dealing with different types of events fired by AWT components
    import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
    import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable
    import javax.swing.JOptionPane;//provides a class that makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something
    import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language
    public class Demo extends JFrame{
       static String url = "jdbc:odbc:VideoLibrary";//a static variable that allows a connection to be made to a database called VideoLibrary
       static Statement stmt;//a static variable that allows a statement to be made once a connection is set up
       static Connection con;//a static interface that allows a connection to be made to a database
         //global variables
         JTextField hostField;//a class that allows a line of text to be changed
       JTextField queryField;//a class that allows a line of text to be changed
       QueryTableModel qtm;//a class that shows and changes regular two-dimensional tables of cells
       JComboBox comboBox;//a class that puts a button or editable field and a drop-down list together 
       public static void main(String args[]){     
          int choice=-1;//a variable of type int that is set to -1
              do{
             choice=getChoice();//invokes the method getChoice()
             if(choice!=0){
                getSelected(choice);//invokes the method getSelected(choice)
             }//end if
                   //if the user chooses 5, it will cause him or her to exit the system
          }while(choice!=5);//end do-while
          System.exit(0);//closes down the menu screen
       }//end main
       public static int getChoice(){
          String choice;//a variable of type string
          int ch;//a variable of type int
          choice = JOptionPane.showInputDialog(null,"1. Maintain product details\n"+"2. Maintain member details\n"+"3. Maintain rental details\n"+"4. View product, member and rental details\n"+"5. Log Off\n\n"+"Enter your choice");//asks the user for some input   
              ch = Integer.parseInt(choice);//a class that wraps a value of the primitive type int in an object     
              return ch;//a method that returns an integer value
       }//end getChoice
       public static void getSelected(int choice){   
              if(choice==1){
             maintainProductDetails();//invokes the method maintainProductDetails()
          }//end if
          if(choice==2){
             maintainMemberDetails();//invokes the method maintainMemberDetails()
          }//end if
              if(choice==3){
             maintainRentalDetails();//invokes the method maintainRentalDetails()
          }//end if
              if(choice==4){
                 Demo test = new Demo();//invokes the constructor Demo()
             test.setVisible(true);//shows the JTable component by marking it as visible
              }//end if
       }//end getSelected
       public static Connection getConnection(){
          try {
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used to create a JDBC connection using a database
          }//end try
              catch(java.lang.ClassNotFoundException e){//causes an exception to be thrown when an application tries to load in a class through its string name
             System.err.print("ClassNotFoundException: ");//displays an error message
             System.err.println(e.getMessage());//returns the exception that was raised if an error occurred while attempting to load the ClassNotFoundException class
          }//end catch
          try {
             con=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
          return con;
       }//end getConnection
       public static void maintainProductDetails(){
          Connection con = getConnection();//creates a connection with the database
          String  addProduct1, addProduct2, addProduct3, addProduct4, addProduct5, addProduct6, addProduct7, addProduct8, addProduct9, addProduct10;//string variables that represent information about the different types of product data that will be stored in the database
          addProduct1 = "insert into Product values (110001, 'The Killers - Sams Town', 5.00, 'G', 'CD', 2006)";
          addProduct2 = "insert into Product values (110002, 'Robbie Williams - Rudebox', 5.00, 'G', 'CD', 2006)";
          addProduct3 = "insert into Product values (110003, 'Razorlight - Razorlight', 5.00, 'G', 'CD', 2006)";
          addProduct4 = "insert into Product values (110004, 'My Chemical Romance - The Black Parade', 5.00, 'G', 'CD', 2006)";
          addProduct5 = "insert into Product values (110005, 'Snow Patrol - Eyes Open', 5.00, 'G', 'CD', 2006)";
          addProduct6 = "insert into Product values (110006, 'Scissor Sisters - Ta-Dah!', 5.00, 'G', 'CD', 2006)";
              addProduct7 = "insert into Product values (110007, 'Lovesounds - Justin Timberlake', 5.00, 'G', 'CD', 2006)";
          addProduct8 = "insert into Product values (110008, 'Director - We thrive on big cities', 5.00, 'G', 'CD', 2006)";
          addProduct9 = "insert into Product values (110009, 'Roxette - Roxette hits', 5.00, 'G', 'CD', 2006)";
          addProduct10 = "insert into Product values (110010, 'Pussy Cat Dolls - PCD', 5.00, 'G', 'CD', 2006)";
              try {
             stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
                 //statements are allowed to be made once a connection is set up
                 stmt.executeUpdate(addProduct1);
             stmt.executeUpdate(addProduct2);
             stmt.executeUpdate(addProduct3);
             stmt.executeUpdate(addProduct4);
                   stmt.executeUpdate(addProduct5);
             stmt.executeUpdate(addProduct6);
                 stmt.executeUpdate(addProduct7);
             stmt.executeUpdate(addProduct8);
             stmt.executeUpdate(addProduct9);
             stmt.executeUpdate(addProduct10);
             stmt.close();//closes the Statement object
             con.close();//terminates the connection with the database
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
       }//end maintainProductDetails
       public static void maintainMemberDetails(){
          Connection con = getConnection();//creates a connection with the database
          String addMember1, addMember2, addMember3, addMember4, addMember5, addMember6, addMember7, addMember8, addMember9, addMember10;//string variables that represent information about the member data that will be stored in the database
          addMember1 = "insert into Member values (1234, 'Ann', 'Smyth', 'Upper Killult, Falcarragh, Co. Donegal', '(074)-9135210', '(087)-2030172', #5/11/85#, #5/12/06#)";
          addMember2 = "insert into Member values (2345, 'John', 'Murphy', 'Lower Killult, Falcarragh, Co. Donegal', '(074)-9135211', '(087)-2030173', #4/12/85#, #6/13/06#)";
          addMember3 = "insert into Member values (1324, 'James', 'McFadden', 'Lower Ardsbeg, Gortahork, Co. Donegal', '(074)-9165314', '(087)-2030171', #4/11/85#, #6/14/06#)";
          addMember4 = "insert into Member values (1235, 'Frankie', 'Ferry', 'Ardsmore, Gortahork, Co. Donegal', '(074)-9165325', '(087)-2031234', #6/13/60#, #6/15/06#)";
          addMember5 = "insert into Member values (1236, 'Daniel', 'McKimm', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135212', '(087)-2030184', #5/14/73#, #6/16/06#)";
          addMember6 = "insert into Member values (2346, 'Stephen', 'Doohan', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135213', '(087)-2030185', #6/13/85#, #5/13/06#)";
          addMember7 = "insert into Member values (2347, 'James', 'Ferry', 'Meenlaragh, Gortahork, Co.Donegal', '(074)-9165360', '(087)-2031345', #9/12/85#, #5/14/06#)";
          addMember8 = "insert into Member values (2348, 'Liam', 'Cannon', 'Derryconner, Gortahork, Co.Donegal', '(074)-9165324', '(087)-2031456', #4/11/86#, #5/15/06#)";
          addMember9 = "insert into Member values (2401, 'Ciaran', 'Ferry', 'Brinalack, Gweedore, Co.Donegal', '(074)-9176425', '(087)-2030282', #9/12/85#, #5/16/06#)";
          addMember10 = "insert into Member values (2402, 'Ciaran', 'McGee', 'Derrybeg, Gweedore, Co.Donegal', '(074)-9176536', '(087)-2030393', #9/14/85#, #5/18/06#)";
          try{
             stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
                   //statements are allowed to be made once a connection is set up
                   stmt.executeUpdate(addMember1);
             stmt.executeUpdate(addMember2);
             stmt.executeUpdate(addMember3);
                   stmt.executeUpdate(addMember4);
                   stmt.executeUpdate(addMember5);
                   stmt.executeUpdate(addMember6);
                   stmt.executeUpdate(addMember7);
                   stmt.executeUpdate(addMember8);
                   stmt.executeUpdate(addMember9);
                   stmt.executeUpdate(addMember10);
             stmt.close();//closes the Statement object
             con.close();//terminates the connection with the database
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
       }//end maintainMemberDetails
         public static void maintainRentalDetails(){
          Connection con = getConnection();//creates a connection with the database
          String addRental1, addRental2, addRental3, addRental4, addRental5, addRental6, addRental7, addRental8, addRental9, addRental10;//string variables that represent information about the loan data that will be stored in the database
          addRental1 = "insert into Rental values (110001, 'The Killers - Sams Town', 1234, 'Ann', 'Smyth', #9/01/06#, #9/10/06#, 'Yes', 2.00)";
          addRental2 = "insert into Rental values (120001, 'Mission Impossible 3', 2345, 'John', 'Murphy', #9/02/06#, #9/09/06#, 'No', 0.00)";
          addRental3 = "insert into Rental values (130001, 'Need for Special Carbon', 1324, 'James', 'McFadden', #9/03/06#, #9/12/06#, 'Yes', 2.00)";
          addRental4 = "insert into Rental values (110002, 'Robbie Williams - Rudebox', 1235, 'Frankie', 'Ferry', #9/04/06#, #9/11/06#, 'No', 0.00)";
          addRental5 = "insert into Rental values (120015, 'Prime', 1236, 'Daniel', 'McKimm', #9/05/06#, #9/14/06#, 'Yes', 2.00)";
          addRental6 = "insert into Rental values (130015, 'FIFA 07', 2346, 'Stephen', 'Doohan', #9/06/06#, #9/13/06#, 'No', 0.00)";
          addRental7 = "insert into Rental values (110009, 'Roxette - Roxette hits', 2347, 'James', 'Ferry', #9/07/06#, #9/16/06#, 'Yes', 2.00)";
          addRental8 = "insert into Rental values (120003, 'The Break Up', 2348, 'Liam', 'Cannon', #9/08/06#, #9/15/06#, 'No', 0.00)";
          addRental9 = "insert into Rental values (130027, 'Gears of War', 2401, 'Ciaran', 'Ferry', #9/09/06#, #9/18/06#, 'Yes', 2.00)";
          addRental10 = "insert into Rental values (110021, 'Scooter - Mind the Gap', 2402, 'Ciaran', 'McGee', #9/10/06#, #9/17/06#, 'No', 0.00)";
          try{
             stmt = con.createStatement();//Creates a Statement object for sending SQL statements to the database
                   //statements are allowed to be made once a connection is set up
                   stmt.executeUpdate(addRental1);
             stmt.executeUpdate(addRental2);
             stmt.executeUpdate(addRental3);
                   stmt.executeUpdate(addRental4);
                   stmt.executeUpdate(addRental5);
                   stmt.executeUpdate(addRental6);
                   stmt.executeUpdate(addRental7);
                   stmt.executeUpdate(addRental8);
                   stmt.executeUpdate(addRental9);
                   stmt.executeUpdate(addRental10);
             stmt.close();//closes the Statement object
             con.close();//terminates the connection with the database
          }//end try
              catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());//returns an SQL error message
          }//end catch
       }//end maintainRentalDetails
       public Demo(){//a constructor
          super("Demo Test Frame");//overrides the constructor
          setSize(350, 200);//Resizes this component so that it has width of 350 and height of 200 
          comboBox = new JComboBox();//invokes the class JComboBox
          comboBox.addItem("jdbc:odbc:VideoLibrary");//adds the specified item to the end of the scrolling list
          qtm = new QueryTableModel();//invokes the class QueryTableModel
          JTable table = new JTable(qtm);//a class that shows and changes regular two-dimensional tables of cells
          JScrollPane scrollpane = new JScrollPane(table);//a class that provides a scrollable view of a lightweight component
          JPanel p1 = new JPanel();//a class that puts the combo box and query field in a panel
          p1.setLayout(new GridLayout(3, 2));//Sets the layout manager for this container
          p1.add(comboBox);//Appends the specified component to the end of this container
          p1.add(new JLabel("Enter your query: "));//Appends the specified component to the end of this container
          p1.add(queryField = new JTextField());//Appends the specified component to the end of this container
          p1.add(new JLabel("Click here to send: "));//Appends the specified component to the end of this container
          JButton jb = new JButton("Search");//a class that is an implementation of a "push" button
          jb.addActionListener(new ActionListener(){//Adds an ActionListener to the button
             public void actionPerformed(ActionEvent e){
                qtm.setHostURL();//invokes the method setHostURL
                qtm.setQuery(queryField.getText().trim());//invokes the method setQuery; and returns the text that is presented by this text component and returns a copy of the string, with leading and trailing whitespaces omitted
          } );//end addActionListener
          p1.add(jb);//Appends the specified component to the end of this container
          getContentPane().add(p1, BorderLayout.NORTH);//Returns the content pane
          getContentPane().add(scrollpane, BorderLayout.CENTER);//Returns the content pane
       }//end Demo
    }//end class Demo
    import java.sql.*;//Provides the API for accessing and processing data stored in a data source using the Java programming language
    import java.io.*;//Provides for system input and output through data streams, serialization and the file system
    import java.util.Vector;//provides a class that implements a growable array of objects
    import javax.swing.*;//Provides a set of lightweight components that, to the maximum degree possible, work the same on all platforms
    import javax.swing.table.*;//Provides classes and interfaces for dealing with javax.swing.JTable
    public class QueryTableModel extends AbstractTableModel{
         Vector cache;//a class that constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero 
         int colCount;//a variable that counts the number of columns in the three tables
         String[] headers;//a class that represents character strings and all string literals in this program are implemented as instances of the String class
         Connection db;//an interface that allows a connection to be made to a database
         Statement statement;//an interface that allows executes the given SQL statement, which returns a single ResultSet object
         String currentURL;//a variable that allows the URL to be displayed in a combo box
         public QueryTableModel(){//a constructor
              cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
              try{
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//used by opening a JDBC connection using an URL
              }//end try
              catch(Exception e){
                   System.out.println("problem loading the driver ");//an error message
              }//end catch
         }//end QueryTableModel
         public String getColumnName(int i){//Returns the designated column's name
            return headers;//returns the name of each column in the three table
         }//end getColumnName
         public int getColumnCount(){//Returns the number of columns in the column model
         return colCount;//returns the number of columns in the three tables
         }//end getColumnCount
         public int getRowCount(){//Returns the number of rows in this table's model
         return cache.size();//returns the number of components in the vector
         }//end getRowCount
         public Object getValueAt(int row, int col){//Returns the cell value at row and column
              return ((String[])cache.elementAt(row))[col];//Returns the component at the specified index
         }//end getValueAt
         public void setHostURL(){//sets the URL for the database
         String url = "jdbc:odbc:VideoLibrary";//a variable that allows a connection to be made to a database called VideoLibrary
         closeDB();//invokes the method closeDB()
              try{
    db=DriverManager.getConnection(url,"","");//tries to create a connection with the database using the DriverManager class
    statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database
    }//end try
    catch(Exception e){
    System.out.println("Could not initialize the database.");//an error message
    e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
    }//end catch
         }//end setHostURL
    public void setQuery(String q){//sets the kind of query that is to be sent to the database
              cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
    String s="select * from Product";//a variable that causes all the data that is in the product table to be displayed in a JTable, which also means that all the data that is in both the member and rental tables can also be displayed in a JTable
              try{
                   ResultSet rs=statement.executeQuery(q);//an interface that is used to generate a database result set by executing a statement that queries the database
                   ResultSetMetaData meta=rs.getMetaData();//an interface that is used to get information about the types and properties of the columns in a ResultSet object
                   colCount=meta.getColumnCount();//Returns the number of columns in this ResultSet object
                   headers=new String[colCount];//gets the name of each column in the three tables
                   for(int h=1;h<=colCount;h++){
                        headers[h-1]=meta.getColumnName(h);//Get the designated column's name
                   }//end for
                   while(rs.next()){
                        String[] record=new String[colCount];//stores the name of each column in the three tables in memory
                        for(int i=0;i<colCount;i++){
                             record[i]=rs.getString(i+1);//Retrieves the value of the designated column in the current row of this ResultSet object as a String
                        }//end for
                        cache.addElement(record);//Adds the specified component to the end of this vector, increasing its size by one
                   }//end while
                   fireTableChanged(null);//Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model
              }//end try
              catch(Exception e){
                   cache=new Vector();//constructs an empty vector so that its internal data array has size 10 and its standard capacity increment is zero
                   e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
              }//end catch
         }//end setQuery
         public void initDB(String url){
              try{
                   db=DriverManager.getConnection(url);//tries to create a connection with the database using the DriverManager class
                   statement=db.createStatement();//Creates a Statement object for sending SQL statements to the database
              }//end try
              catch(Exception e){
                   System.out.println("Could not initialize the database.");//an error message
                   e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
              }//end catch
         }//end initDB
         public void closeDB(){
              try{
                   if(statement!=null){
                   statement.close();//Releases this Statement object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed
                   }//end if
                   if(db!=null){
                   db.close();//Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released
                   }//end if
              }//end try
              catch(Exception e){
                   System.out.println("Could not close the current connection.");//an error message
                   e.printStackTrace();//a Throwable method that prints this throwable and it's backtrace to the standard error stream
              }//end catch
         }//end closeDB
    }//end class QueryTableModel

    here's an uncommented version of the code.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.JOptionPane;
    import java.sql.*;
    public class Demo extends JFrame{
       static String url = "jdbc:odbc:VideoLibrary";
       static Statement stmt;
       static Connection con;
       JTextField hostField;
       JTextField queryField;
       QueryTableModel qtm;
       JComboBox comboBox;
       public static void main(String args[]){
          int choice=-1;
          do{
             choice=getChoice();
             if(choice!=0){
                getSelected(choice);
          }while(choice!=5);
          System.exit(0);
       public static int getChoice(){
          String choice;
          int ch;
          choice = JOptionPane.showInputDialog(null,"1. Maintain product details\n"+"2. Maintain member details\n"+"3. Maintain rental details\n"+"4. View product, member and rental details\n"+"5. Log Off\n\n"+"Enter your choice"); 
          ch = Integer.parseInt(choice);    
          return ch;
       public static void getSelected(int choice){   
          if(choice==1){
             maintainProductDetails();
          if(choice==2){
             maintainMemberDetails();
          if(choice==3){
             maintainRentalDetails();
          if(choice==4){
             Demo test = new Demo();
             test.setVisible(true);
       public static Connection getConnection(){
          try {
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
          catch(java.lang.ClassNotFoundException e){
             System.err.print("ClassNotFoundException: ");
             System.err.println(e.getMessage());
          try {
             con=DriverManager.getConnection(url,"","");
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
          return con;
       public static void maintainProductDetails(){
          Connection con = getConnection();
          String  addProduct1, addProduct2, addProduct3, addProduct4, addProduct5, addProduct6, addProduct7, addProduct8, addProduct9, addProduct10;
          addProduct1 = "insert into Product values (110001, 'The Killers - Sams Town', 5.00, 'G', 'CD', 2006)";
          addProduct2 = "insert into Product values (110002, 'Robbie Williams - Rudebox', 5.00, 'G', 'CD', 2006)";
          addProduct3 = "insert into Product values (110003, 'Razorlight - Razorlight', 5.00, 'G', 'CD', 2006)";
          addProduct4 = "insert into Product values (110004, 'My Chemical Romance - The Black Parade', 5.00, 'G', 'CD', 2006)";
          addProduct5 = "insert into Product values (110005, 'Snow Patrol - Eyes Open', 5.00, 'G', 'CD', 2006)";
          addProduct6 = "insert into Product values (110006, 'Scissor Sisters - Ta-Dah!', 5.00, 'G', 'CD', 2006)";
          addProduct7 = "insert into Product values (110007, 'Lovesounds - Justin Timberlake', 5.00, 'G', 'CD', 2006)";
          addProduct8 = "insert into Product values (110008, 'Director - We thrive on big cities', 5.00, 'G', 'CD', 2006)";
          addProduct9 = "insert into Product values (110009, 'Roxette - Roxette hits', 5.00, 'G', 'CD', 2006)";
          addProduct10 = "insert into Product values (110010, '***** Cat Dolls - PCD', 5.00, 'G', 'CD', 2006)";
          try {
             stmt = con.createStatement();
             stmt.executeUpdate(addProduct1);
             stmt.executeUpdate(addProduct2);
             stmt.executeUpdate(addProduct3);
             stmt.executeUpdate(addProduct4);
             stmt.executeUpdate(addProduct5);
             stmt.executeUpdate(addProduct6);
             stmt.executeUpdate(addProduct7);
             stmt.executeUpdate(addProduct8);
             stmt.executeUpdate(addProduct9);
             stmt.executeUpdate(addProduct10);
             stmt.close();
             con.close();
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
       public static void maintainMemberDetails(){
          Connection con = getConnection();
          String addMember1, addMember2, addMember3, addMember4, addMember5, addMember6, addMember7, addMember8, addMember9, addMember10;
          addMember1 = "insert into Member values (1234, 'Ann', 'Smyth', 'Upper Killult, Falcarragh, Co. Donegal', '(074)-9135210', '(087)-2030172', #5/11/85#, #5/12/06#)";
          addMember2 = "insert into Member values (2345, 'John', 'Murphy', 'Lower Killult, Falcarragh, Co. Donegal', '(074)-9135211', '(087)-2030173', #4/12/85#, #6/13/06#)";
          addMember3 = "insert into Member values (1324, 'James', 'McFadden', 'Lower Ardsbeg, Gortahork, Co. Donegal', '(074)-9165314', '(087)-2030171', #4/11/85#, #6/14/06#)";
          addMember4 = "insert into Member values (1235, 'Frankie', 'Ferry', 'Ardsmore, Gortahork, Co. Donegal', '(074)-9165325', '(087)-2031234', #6/13/60#, #6/15/06#)";
          addMember5 = "insert into Member values (1236, 'Daniel', 'McKimm', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135212', '(087)-2030184', #5/14/73#, #6/16/06#)";
          addMember6 = "insert into Member values (2346, 'Stephen', 'Doohan', 'Ballyness, Falcarragh, Co. Donegal', '(074)-9135213', '(087)-2030185', #6/13/85#, #5/13/06#)";
          addMember7 = "insert into Member values (2347, 'James', 'Ferry', 'Meenlaragh, Gortahork, Co.Donegal', '(074)-9165360', '(087)-2031345', #9/12/85#, #5/14/06#)";
          addMember8 = "insert into Member values (2348, 'Liam', 'Cannon', 'Derryconner, Gortahork, Co.Donegal', '(074)-9165324', '(087)-2031456', #4/11/86#, #5/15/06#)";
          addMember9 = "insert into Member values (2401, 'Ciaran', 'Ferry', 'Brinalack, Gweedore, Co.Donegal', '(074)-9176425', '(087)-2030282', #9/12/85#, #5/16/06#)";
          addMember10 = "insert into Member values (2402, 'Ciaran', 'McGee', 'Derrybeg, Gweedore, Co.Donegal', '(074)-9176536', '(087)-2030393', #9/14/85#, #5/18/06#)";
          try{
             stmt = con.createStatement();
             stmt.executeUpdate(addMember1);
             stmt.executeUpdate(addMember2);
             stmt.executeUpdate(addMember3);
             stmt.executeUpdate(addMember4);
             stmt.executeUpdate(addMember5);
             stmt.executeUpdate(addMember6);
             stmt.executeUpdate(addMember7);
             stmt.executeUpdate(addMember8);
             stmt.executeUpdate(addMember9);
             stmt.executeUpdate(addMember10);
             stmt.close();
             con.close();
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
       public static void maintainRentalDetails(){
          Connection con = getConnection();
          String addRental1, addRental2, addRental3, addRental4, addRental5, addRental6, addRental7, addRental8, addRental9, addRental10;
          addRental1 = "insert into Rental values (110001, 'The Killers - Sams Town', 1234, 'Ann', 'Smyth', #9/01/06#, #9/10/06#, 'Yes', 2.00)";
          addRental2 = "insert into Rental values (120001, 'Mission Impossible 3', 2345, 'John', 'Murphy', #9/02/06#, #9/09/06#, 'No', 0.00)";
          addRental3 = "insert into Rental values (130001, 'Need for Special Carbon', 1324, 'James', 'McFadden', #9/03/06#, #9/12/06#, 'Yes', 2.00)";
          addRental4 = "insert into Rental values (110002, 'Robbie Williams - Rudebox', 1235, 'Frankie', 'Ferry', #9/04/06#, #9/11/06#, 'No', 0.00)";
          addRental5 = "insert into Rental values (120015, 'Prime', 1236, 'Daniel', 'McKimm', #9/05/06#, #9/14/06#, 'Yes', 2.00)";
          addRental6 = "insert into Rental values (130015, 'FIFA 07', 2346, 'Stephen', 'Doohan', #9/06/06#, #9/13/06#, 'No', 0.00)";
          addRental7 = "insert into Rental values (110009, 'Roxette - Roxette hits', 2347, 'James', 'Ferry', #9/07/06#, #9/16/06#, 'Yes', 2.00)";
          addRental8 = "insert into Rental values (120003, 'The Break Up', 2348, 'Liam', 'Cannon', #9/08/06#, #9/15/06#, 'No', 0.00)";
          addRental9 = "insert into Rental values (130027, 'Gears of War', 2401, 'Ciaran', 'Ferry', #9/09/06#, #9/18/06#, 'Yes', 2.00)";
          addRental10 = "insert into Rental values (110021, 'Scooter - Mind the Gap', 2402, 'Ciaran', 'McGee', #9/10/06#, #9/17/06#, 'No', 0.00)";
          try{
             stmt = con.createStatement();
             stmt.executeUpdate(addRental1);
             stmt.executeUpdate(addRental2);
             stmt.executeUpdate(addRental3);
             stmt.executeUpdate(addRental4);
             stmt.executeUpdate(addRental5);
             stmt.executeUpdate(addRental6);
             stmt.executeUpdate(addRental7);
             stmt.executeUpdate(addRental8);
             stmt.executeUpdate(addRental9);
             stmt.executeUpdate(addRental10);
             stmt.close();
             con.close();
          catch(SQLException ex) {
             System.err.println("SQLException: " + ex.getMessage());
       public Demo(){
          super("Demo Test Frame");
          setSize(350, 200);
          comboBox = new JComboBox();
          comboBox.addItem("jdbc:odbc:VideoLibrary");
          qtm = new QueryTableModel();
          JTable table = new JTable(qtm);
          JScrollPane scrollpane = new JScrollPane(table);
          JPanel p1 = new JPanel();
          p1.setLayout(new GridLayout(3, 2));
          p1.add(comboBox);
          p1.add(new JLabel("Enter your query: "));
          p1.add(queryField = new JTextField());
          p1.add(new JLabel("Click here to send: "));
          JButton jb = new JButton("Search");
          jb.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e){
                qtm.setHostURL();
                qtm.setQuery(queryField.getText().trim());
          p1.add(jb);
          getContentPane().add(p1, BorderLayout.NORTH);
          getContentPane().add(scrollpane, BorderLayout.CENTER);
    import java.sql.*;
    import java.io.*;
    import java.util.Vector;
    import javax.swing.*;
    import javax.swing.table.*;
    public class QueryTableModel extends AbstractTableModel{
         Vector cache; 
         int colCount;
         String[] headers;
         Connection db;
         Statement statement;
         String currentURL;
         public QueryTableModel(){
              cache=new Vector();
              try{
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              catch(Exception e){
                   System.out.println("problem loading the driver ");
         public String getColumnName(int i){
            return headers;
         public int getColumnCount(){
         return colCount;
         public int getRowCount(){
         return cache.size();
         public Object getValueAt(int row, int col){
              return ((String[])cache.elementAt(row))[col];
         public void setHostURL(){
         String url = "jdbc:odbc:VideoLibrary";
         closeDB();
              try{
    db=DriverManager.getConnection(url,"","");
    statement=db.createStatement();
    catch(Exception e){
    System.out.println("Could not initialize the database.");
    e.printStackTrace();
    public void setQuery(String q){
              cache=new Vector();
    String s="select * from Product";
              try{
                   ResultSet rs=statement.executeQuery(q);
                   ResultSetMetaData meta=rs.getMetaData();
                   colCount=meta.getColumnCount();
                   headers=new String[colCount];
                   for(int h=1;h<=colCount;h++){
                        headers[h-1]=meta.getColumnName(h);
                   while(rs.next()){
                        String[] record=new String[colCount];
                        for(int i=0;i<colCount;i++){
                             record[i]=rs.getString(i+1);
                        cache.addElement(record);
                   fireTableChanged(null);
              catch(Exception e){
                   cache=new Vector();
                   e.printStackTrace();
         public void initDB(String url){
              try{
                   db=DriverManager.getConnection(url);
                   statement=db.createStatement();
              catch(Exception e){
                   System.out.println("Could not initialize the database.");
                   e.printStackTrace();
         public void closeDB(){
              try{
                   if(statement!=null){
                   statement.close();
                   if(db!=null){
                   db.close();
              catch(Exception e){
                   System.out.println("Could not close the current connection.");
                   e.printStackTrace();

  • How to tune the Insert statement?

    Hi ,
    I am using 10.2.0.4.0 version of oracle.
         i am having one insert statement , which comes almost all the time in the TOP of my AWR elapsed time section.
         And its somewhat similar to as below.
    Query:
    INSERT INTO a (InvoicePK, CheckPK)
    SELECT DISTINCT ih.InvoicePK, cd.CheckPK
    FROM at,
    cd,
    ih,
    rd
    WHERE at.AttachmentPK = :1
    AND cd.CheckPK = at.CheckPK
    AND at.AttachmentPK = rd.AttachPK
    AND ih.PAYPK = cd.PAYEEPAYPK
    AND ih.PayerNS = cd.PayerNS
    AND ih.PayerPayId = cd.PayerPayId
    AND ih.UpperInvoiceNum = rd.UPPERINVNUM
    AND ih.InvoiceStatusCD NOT IN ('REJ', 'DNY');
    Below is the plan for the 'Select ' statement i.e. used in the insert statement.
    Execution Plan:
    Plan hash value: 2232002808
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
    | 0 | SELECT STATEMENT | | 1 | 193 | 9 (23)| 00:00:01 | | |
    | 1 | HASH UNIQUE | | 1 | 193 | 9 (23)| 00:00:01 | | |
    |* 2 | HASH JOIN | | 1 | 193 | 8 (13)| 00:00:01 | | |
    | 3 | NESTED LOOPS | | 10 | 1740 | 4 (0)| 00:00:01 | | |
    | 4 | NESTED LOOPS | | 1 | 85 | 3 (0)| 00:00:01 | | |
    | 5 | TABLE ACCESS BY INDEX ROWID | at | 1 | 16 | 2 (0)| 00:00:01 | | |
    |* 6 | INDEX UNIQUE SCAN | atpk1 | 1 | | 1 (0)| 00:00:01 | | |
    | 7 | TABLE ACCESS BY INDEX ROWID | cd | 7359K| 484M| 1 (0)| 00:00:01 | | |
    |* 8 | INDEX UNIQUE SCAN | cdpk1 | 1 | | 1 (0)| 00:00:01 | | |
    |* 9 | TABLE ACCESS BY GLOBAL INDEX ROWID| ih | 10 | 890 | 2 (0)| 00:00:01 | ROWID | ROWID |
    |* 10 | INDEX RANGE SCAN | IH_PAYPK_PAYERNS_PAYID | 5 | | 1 (0)| 00:00:01 | | |
    | 11 | TABLE ACCESS BY INDEX ROWID | rd | 9 | 171 | 3 (0)| 00:00:01 | | |
    |* 12 | INDEX RANGE SCAN | IDX_rd | 9 | | 2 (0)| 00:00:01 | | |
    Predicate Information (identified by operation id):
    2 - access("IH"."UPPERINVOICENUM"="RD"."UPPERINVNUM")
    6 - access("AT"."ATTACHMENTPK"=7794833983)
    8 - access("CD"."CHECKPK"="AT"."CHECKPK")
    9 - filter("IH"."INVOICESTATUSCD"<>'REJ' AND "IH"."INVOICESTATUSCD"<>'DNY')
    10 - access("IH"."PAYPK"="CD"."PAYEEPAYPK" AND "IH"."PAYERNS"="CD"."PAYERNS" AND "IH"."PAYERPAYID"="CD"."PAYERPAYID")
    12 - access("RD"."ATTACHPK"=7794833983)
    Statistics
    1 recursive calls
    0 db block gets
    71 consistent gets
    0 physical reads
    0 redo size
    316 bytes sent via SQL*Net to client
    240 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    3 rows processed
    The 'select' Statement executes with in seconds resulting 3 distinct records, but the insert statement takes ~20sec(Elaps time per execution
    as shown in AWR report) for one time execution, so what must be the reason , and how should i proceed to resolve this performance issue?

    You can do as follows:
    - Enable trace
    - execute the insert statement
    - use tkprof (and put the results here) to see where's its taking long
    Also, while insert is being executed, what are the wait events you see ?
    I dont think there is problem with plan.

  • Convert the insert statement of an MS SQL server into an oracle statement

    Hi ,
    The insert statement in the ms sql server is
    INSERT INTO #temp EXEC Procedurename @Id OUTPUT
    where table temp
    CREATE TABLE #temp(
              Id varchar(10),
              FNa varchar(40),
              LNa varchar(40),
              SId varchar(20),
              Aid varchar(20),
              Did varchar(20),
              CCNa varchar(255),
              CCId int,
              ISu char(1),
              IA char(1),
              Dir char(1),
              Ema varchar(60),
              St char(2),
              DId char(3)
    I converted the insert statement like this
    Procedurename(Id);
    LOOP
    FETCH cv_1 INTO v_temp;
    EXIT WHEN cv_1%NOTFOUND;
    INSERT INTO TEMP VALUES v_temp;
    END LOOP;
    CLOSE cv_1;
    But i am receiving PL/SQL: ORA-00947: not enough values
    Can anyone help on this?
    Thanks

    1) Are you sure that you even need a temp table? Fetching all the rows from a cursor 1-by-1 and then inserting them into a temp table (I'm assuming the Oracle table TEMP is declared as a global temporary table) would seem rather unusual and most likely pointless. In Oracle, readers don't block writers, so there is generally no need to use temp tables to hold intermediate results.
    2) If you do need to store a set of results into a table, it's going to be more efficient to do this in a single SQL statement rather than using a cursor. Something like
    INSERT INTO my_table ( <<list of columns>> )
      SELECT <<list of columns>>
        FROM <<other tables>>
       WHERE <<some conditions>>The SELECT part of the statement here is likely whatever SQL you use in declaring the cursor.
    Justin

  • How to combine both values and subquery in the insert statement

    Hi everybody,
    This is a case of inserting rows into a final results table from a temporary one. Actually, one of the fields is not always given in the temporary table. Thus, when inserting the rows into the final results table, an error message comes up to.
    More clarification:
    final results table(F_RESULT): field1, field2, field3 ( they are also primary keys with not null constraint)
    temporary table(TEMP): field2, filed3
    Is it possible to combine both values and subquery branchs of the insert statement:
    Insert into F_RESULT (field2,field3) select field2,field3 from TEMP;
    Insert into F_RESULT (field1) values (0);
    into only one like this:
    Insert into F_RESULT (field1,field2,field3) values (0, select field2 form Temp, select field3 from Temp);
    Or there is another more effective solution. The main problem for me is the message that doesn't accept the null value. From the data integrity point of view, it is accepted to set field1 to zero.
    Any hints?
    Thanks for your reply.

    That's easy, you can select any value from a table:
    Insert into F_RESULT (field1,field2,field3)
    select 0, field2, field3 from Temp;

  • Exception handling for all the insert statements in the proc

    CREATE PROCEDURE TEST (
    @IncrStartDate DATE
    ,@IncrEndDate DATE
    ,@SourceRowCount INT OUTPUT
    ,@TargetRowCount INT OUTPUT
    ,@ErrorNumber INT OUTPUT
    ,@ErrorMessage VARCHAR(4000) OUTPUT
    ,@InsertCase INT --INSERT CASE INPUT
    WITH
    EXEC AS CALLER AS
    BEGIN --Main Begin
    SET NOCOUNT ON
    BEGIN TRY
    DECLARE @SuccessNumber INT = 0
    ,@SuccessMessage VARCHAR(100) = 'SUCCESS'
    ,@BenchMarkLoadFlag CHAR(1)
    ,@BenchmarkFlow INT
    ,@MonthYearStart DATE
    ,@MonthYearEnd DATE
    ,@StartDate DATE
    ,@EndDate DATE
    /* Setting the default values of output parameters to 0.*/
    SET @SourceRowCount = 0
    SET @TargetRowCount = 0
    /*Setting the Start and end date for looping */
    SET @MonthYearStart = @IncrStartDate;
    SET @MonthYearEnd = @IncrEndDate;
    /* Setting the @InsertCase will ensure case wise insertion as this sp will load data in different tables
    @InsertCase =0 means data will be inserted in the target TAB1
    @InsertCase =1 means data will be inserted in the target TAB2
    @InsertCase =2 means data will be inserted in the target TAB3
    @InsertCase =3 means data will be inserted in the target TAB4
    @InsertCase =4 means data will be inserted in the target TAB5
    @InsertCase =5 means data will be inserted in the target TAB6
    if @InsertCase =0
    WHILE (@MonthYearStart <= @MonthYearEnd)
    BEGIN
    SET @StartDate = @MonthYearStart;
    SET @EndDate = @MonthYearEnd;
    /* Delete from target where date range given from input parameter*/
    DELETE FROM TAB1
    WHERE [MONTH] BETWEEN MONTH(@StartDate) AND MONTH(@EndDate)
    AND [YEAR] BETWEEN year(@StartDate) and year(@EndDate)
    /*Insert data in target-TAB1 */
    BEGIN TRANSACTION
    INSERT INTO TAB1
    A,B,C
    SELECT
    A,BC
    FROM XYZ
    COMMIT TRANSACTION
    SET @MonthYearStart = DATEADD(MONTH, 1, @MonthYearStart)
    SELECT @TargetRowCount = @TargetRowCount + @@ROWCOUNT;
    END -- End of whileloop
    END TRY
    BEGIN CATCH
    IF @@TRANCOUNT>0
    ROLLBACK TRANSACTION
    SELECT @ErrorNumber = ERROR_NUMBER() ,@ErrorMessage = ERROR_MESSAGE();
    END CATCH
    END--End of Main Begin
    I have the above proc inserting data based on parameters  where in @InsertCase  is used for case wise execution.
     I have written the whole proc with exception handling using try catch block.
    I have just added one insert statement here for 1 case  now I need to add further insert  cases
    INSERT INTO TAB4
                    A,B,C
    SELECT
                                    A,BC
    FROM XYZ
    INSERT INTO TAB3
                    A,B,C
    SELECT
                                    A,BC
    FROM XYZ
    INSERT INTO TAB2
                    A,B,C
    SELECT
                                    A,BC
    FROM XYZ
    I will be using following to insert further insert statements 
    if @InsertCase =1 
    I just needed to know where will be my next insert statement should be fitting int his code so that i cover exception handling for all the code
    Mudassar

    Hi Erland & Mudassar, I have attempted to recreate Mudassar's original problem..here is my TABLE script;
    USE [MSDNTSQL]
    GO
    /****** Object: Table [dbo].[TAB1] Script Date: 2/5/2014 7:47:48 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[TAB1](
    [COL1] [nvarchar](1) NULL,
    [COL2] [nvarchar](1) NULL,
    [COL3] [nvarchar](1) NULL,
    [START_MONTH] [int] NULL,
    [END_MONTH] [int] NULL,
    [START_YEAR] [int] NULL,
    [END_YEAR] [int] NULL
    ) ON [PRIMARY]
    GO
    Then here is a CREATE script for the SPROC..;
    USE [MSDNTSQL]
    GO
    /****** Object: StoredProcedure [dbo].[TryCatchTransactions1] Script Date: 2/5/2014 7:51:33 AM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[TryCatchTransactions1] (
    @IncrStartDate DATE
    ,@IncrEndDate DATE
    ,@SourceRowCount INT OUTPUT
    ,@TargetRowCount INT OUTPUT
    ,@ErrorNumber INT OUTPUT
    ,@ErrorMessage VARCHAR(4000) OUTPUT
    ,@InsertCase INT --INSERT CASE INPUT
    WITH
    EXEC AS CALLER AS
    BEGIN --Main Begin
    SET NOCOUNT ON
    BEGIN TRY
    DECLARE @SuccessNumber INT = 0
    ,@SuccessMessage VARCHAR(100) = 'SUCCESS'
    ,@BenchMarkLoadFlag CHAR(1)
    ,@BenchmarkFlow INT
    ,@MonthYearStart DATE
    ,@MonthYearEnd DATE
    ,@StartDate DATE
    ,@EndDate DATE
    /* Setting the default values of output parameters to 0.*/
    SET @SourceRowCount = 0
    SET @TargetRowCount = 0
    /*Setting the Start and end date for looping */
    SET @MonthYearStart = @IncrStartDate;
    SET @MonthYearEnd = @IncrEndDate;
    /* Setting the @InsertCase will ensure case wise insertion as this sp will load data in different tables
    @InsertCase =0 means data will be inserted in the target TAB1
    @InsertCase =1 means data will be inserted in the target TAB2
    @InsertCase =2 means data will be inserted in the target TAB3
    @InsertCase =3 means data will be inserted in the target TAB4
    @InsertCase =4 means data will be inserted in the target TAB5
    @InsertCase =5 means data will be inserted in the target TAB6
    IF @InsertCase =0
    WHILE (@MonthYearStart <= @MonthYearEnd)
    BEGIN
    SET @StartDate = @MonthYearStart;
    SET @EndDate = @MonthYearEnd;
    /* Delete from target where date range given from input parameter*/
    DELETE FROM TAB1
    WHERE START_MONTH BETWEEN MONTH(@StartDate) AND MONTH(@EndDate)
    AND START_YEAR BETWEEN year(@StartDate) and YEAR(@EndDate)
    /*Insert data in target-TAB1 */
    BEGIN TRANSACTION
    INSERT INTO TAB1 (COL1,COL2,COL3)
    VALUES ('Z','X','Y')
    SELECT COL1, COL2, COL3
    FROM TAB1
    COMMIT TRANSACTION
    SET @MonthYearStart = DATEADD(MONTH, 1, @MonthYearStart)
    SELECT @TargetRowCount = @TargetRowCount + @@ROWCOUNT;
    END -- End of whileloop
    END TRY
    BEGIN CATCH
    IF @@TRANCOUNT > 0
    ROLLBACK TRANSACTION
    SELECT @ErrorNumber = ERROR_NUMBER() ,@ErrorMessage = ERROR_MESSAGE();
    END CATCH
    PRINT @SUCCESSMESSAGE
    END--End of Main Begin
    GO
    I am just trying to help --danny rosales
    UML, then code

  • There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

    I have been looking at my code for hours now and cant figure out what is wrong. The error has kept popping up even when i thought i had fixed everything. maybe a second set of eyes could help me out here. If you could help me out it would be much appreciated.
    USE [ConorsSetKits]
    GO
    CREATE TABLE Customers (
    CustomerID Int NOT NULL IDENTITY(1000,1),
    LastName NChar(30) NOT NULL,
    FirstName NChar(30) NOT NULL,
    Address NChar(50) NOT NULL,
    City NChar(30) NOT NULL,
    State NChar(2) NOT NULL,
    Zip Numeric(5) NOT NULL,
    Email NVarChar(50) NOT NULL,
    DateOfBirth Numeric (4) NOT NULL,
    CONSTRAINT CustomersPK PRIMARY KEY(CustomerID),
    CONSTRAINT ValidZip
    CHECK ( [Zip] LIKE '[0-9][0-9][0-9][0-9][0-9]' ),
    CONSTRAINT ValidState
    CHECK( LEN([State]) = 2),
    CONSTRAINT DateOfBirth
    CHECK ([DateOfBirth] BETWEEN '1920-01-01' AND getdate() - 5844));
    CREATE TABLE Sets (
    SetID Int NOT NULL IDENTITY(1000,1) Primary Key,
    SetName NChar(20) NOT NULL,
    SetType NChar (20) NOT NULL,
    Price Numeric (20) NOT NULL,
    Quantity Numeric (50) NOT NULL,
    CONSTRAINT SetTypeCheck
    CHECK (SetType IN ('Planes','Tanks','Robots','Cars','Helicopters','Boats','Trains','Motorcycles','Jets')),
    CONSTRAINT ValidQuantity 
    CHECK (Quantity >= 0)
    CREATE TABLE Orders (
    OrderID Int NOT NULL IDENTITY(1000,1),
    CustomerID Int NOT NULL,
    OrderDate Date NOT NULL,
    CONSTRAINT CAIntPK PRIMARY KEY(OrderID, CustomerID),
    SET IDENTITY_INSERT dbo.CUSTOMER OFF
    SET IDENTITY_INSERT dbo.Sets OFF
    SET IDENTITY_INSERT dbo.Orders OFF
    SET IDENTITY_INSERT dbo.CUSTOMER ON
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1000, 'Janes', 'Jeffrey', '123 W. Elm St', 'Renton', 'WA', '98055',
    '[email protected]',1985);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1001, 'Smith', 'David', '813 Tumbleweed Lane', 'Loveland', 'CO', '81201', 
    '[email protected]',1992);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1015, 'Twilight', 'Tiffany', '88 1st Avenue', 'Langley', 'WA', '98260',
    '[email protected]',1972);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1033, 'Smathers', 'Fred', '10899 88th Ave', 'Bainbridge Island', 'WA', '98110',
    '[email protected]',1980);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1034, 'Frederickson', 'Mary Beth', '25 South Lafayette', 'Denver', 'CO', '80201',
    '[email protected]',1970);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1036, 'Warning', 'Selma', '205 Burnaby', 'Vancouver', 'BC', '80201',
    '[email protected]',1981);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1037, 'Wu', 'Susan', '105 Locust Ave', 'Atlanta', 'GA', '30322',
    '404', '653-3465', '[email protected]',1971);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1040, 'Gray', 'Donald','55 Bodega Ave', 'Bodega Bay', 'CA', '94923',
    '[email protected]',1985);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1041, 'Johnson', 'Lynda', '117 C Street', 'Washington', 'DC', '20003',
    '[email protected]',1969);
    INSERT INTO Customers
    (CustomerID, LastName, FirstName, Address, City, State, Zip,
    Email, DateOfBirth)
    VALUES (
    1051, 'Wilkens', 'Chris', '87 Highland Drive', 'Olympia', 'WA', '98508',
    '[email protected]',1994); 
    SET IDENTITY_INSERT dbo.CUSTOMER OFF
    SET IDENTITY_INSERT dbo.Sets ON
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1000, 'MysterySet1','Planes',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1001, 'MysterySet2','Planes',$19.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1002, 'MysterySet4','Tanks',$39.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1003, 'MysterySet3','Robots',$19.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1004, 'MysterySet5','Cars',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1005, 'MysterySet6','Boats',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1006, 'MysterySet7','Trains',$39.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1007, 'MysterySet8','Motorcycles',$9.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1008, 'MysterySet9','Helicopters',$29.99,10);
    INSERT INTO Sets
    (SetID, SetName, SetType, Price, Quanity)
    VALUES (
    1009, 'MysterySet10','Jets',$29.99,10);
    SET IDENTITY_INSERT dbo.Sets OFF
    SET IDENTITY_INSERT dbo.Orders ON
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1000, '2012-12-12');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1000, '2013-12-30');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1005, '2013-08-30');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1004, '2013-12-30');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1004, '2013-08-31');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1004, '2014-03-25');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1002, '2012-11-14');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1001, '2012-11-14');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1001, '2013-01-05');
    INSERT INTO Orders 
    (OrderID, OrderDate)
    VALUES 
    (1006, '2012-06-22');
    SET IDENTITY_INSERT dbo.Orders OFF

    Price Numeric (20) NOT NULL,
    I do not think you understand this datatype?  Go look at the values you are attempting to insert into this column.  For example, "$29.99".  After the insert, what value is actually stored in that column? 
    DateOfBirth Numeric (4) NOT NULL,
    No. Just No.  Either change the column name to faithfully represent what values you intend to store (and apply the appropriate constraints) or change the datatype and the values that you intend to store to match the column name.  And the constraint
    that you do have:
     CONSTRAINT DateOfBirth
     CHECK ([DateOfBirth] BETWEEN '1920-01-01' AND getdate() - 5844));
    is both logically suspect and syntactically wrong. First, the upper boundary will be computed as 1999-04-29 15:50:21.670.  But, of course, your column is a whole number of no more than 4 digits.  The same issue applies to your lower boundary. 
    A simple select statement will show you those errors
    select cast('1920-01-01' as numeric(4)), getdate() - 5844, cast(getdate() - 5844 as numeric(4));
    An insert statement fails with the same error.  Because, of course, your boundary values must actually be converted to numeric(4) in order to compare them against the value contained in the column.   Generally, you can convert from
    string to numeric - IF the content of the string actually contains a value that is numeric and can be converted into the specific type needed.  Not so in this case.  Is this 16 year period (5844 days) significant for some reason?  You should
    document it here in your DDL with a comment, because it is unlikely to be documented (and kept current) anywhere else. 
    And lastly, your script has:
    SET IDENTITY_INSERT dbo.CUSTOMER OFF
    That is not the name of your table, and therefore that statement also fails.  The table name you used is plural. 

  • Select Statement inside the insert statement

    I need to insert the values into nav_pending by selecting the values from nav table
    when i write this code its giving missing expression error
    Can i know what is the problem??
    can i use select inside insert in oracle????
    INSERT INTO NAV_PENDING (ACCOUNT_NUM,PERIOD_DTE)
    VALUES
    SELECT ACCOUNT_NUM,PERIOD_DTE
    FROM NAV where ACCOUNT_NUM=1;
    Thanks in advance

    Leave the values keyword
    INSERT INTO NAV_PENDING (ACCOUNT_NUM,PERIOD_DTE)
    SELECT ACCOUNT_NUM,PERIOD_DTE
    FROM NAV where ACCOUNT_NUM=1;

  • Unicode issue for the INSERT statement...

    Hi,
    In ECC 6.0, the following INSERT statment give short dumps:
    FIELD-SYMBOLS:
      <fs_tabname>   TYPE ANY."Dynamic table name
    DATA: t_bdi_entry  TYPE STANDARD TABLE OF bdi_entry,
    INSERT (<fs_tabname>) FROM TABLE t_bdi_entry.
    If any one know the reason, Please let me know.
    Thanks!
    Puneet.

    Hi,
    Please try this.
    FIELD-SYMBOLS:
    <fs_tabname> TYPE ANY.    "Dynamic table name
    DATA: t_bdi_entry TYPE STANDARD TABLE OF bdi_entry,
    INSERT <fs_tabname> INTO TABLE t_bdi_entry.
    Regards,
    Ferry Lianto

  • Short  Dump in Standard program for the INSERT Statement

    Hi All,
    In the Transaction FPCJ, when I click on the Button Close Cash Desk, I ma getting a short Dump.
    The problem is in the Standard SAP program 'SAPLSUU1' and the include program is 'LSUU1F01'.
    The reason is the code is trying to insert duplicate entries into a Data base table. And SAP is suggesting for a SAp NOTE.
    The problem is when I am trying with the suggested dearch terms I get very large number of notes and I am unable
    to zero down any single note.
    If someone has worked on these or have any idea on the Note number, please share that with me.
    Thans in advance.
    Thanks & regards,
    Y Gautham

    Hi Nicole,
    Thanks a lot! It actually worked.
    Thanks & regards,
    Y Gautham

  • SAP-Script; Is it possible to handle the BOX -Statement dynamic?

    Hi Scripters!
    My consultant wants a box around some information in a SAP-Script form.
    Normally this is quite easy, BUT in this case i have the information (which needs the box around) printed after the positions.
    So problem is: the box can not have a certain position in the Form since i dont know how much positions are to be printed.
    any ideas on this subject?

    Hi Florian,
    Yes it is possible to play arount with positions of Box.
    You can pass variable name in between & in place of fixed XPOS and YPOS.
    and pass value to that dynamic variable.
    You have to test a lot with different values in those variables for pefect settings.
    Hope it will solve your problem.
    Regards
    Krishnendu

  • Sql insert statement will fail if the data value has empty line

    Hi,
    I notice if the insert statement in my .sql file contains data that has new line (enter key), the insert will fail.
    For example:
    insert into mytable (message)
    values ('this is the first line
    this is the second line that will cause insert statement to fail
    so as this third line');
    commit;
    How to overcome this?
    Please advise.
    Thank you.
    Message was edited by:
    bchurn
    Message was edited by:
    bchurn

    It did not return me any error. What is the error you are receiving ??
    SQL> create table mytable (message varchar2(500));
    Table created.
    SQL> insert into mytable (message)
      2  values ('this is the first line
      3  this is the second line that will cause insert statement to fail
      4  so as this third line');
    1 row created.
    SQL> @c:\test.txt
    1 row created.contents of c:\test.txt
    <<
    insert into mytable (message)
    values ('this is the first line
    this is the second line that will cause insert statement to fail
    so as this third line');
    >>

  • Parallel Insert statements (bulk) to the same table

    Hi,
    I am in need to insert set of insert statements 50000+ in to table and wanted to split them in to tow halves and run in two SQL worksheets.
    Note that both will try to insert on the same table.
    Please let me know whether it is advisable or tell me an alternative way.
    Using...Oracle 11g DB.
    Regards
    Deep.

    935195 wrote:
    I am in need to insert set of insert statements 50000+ in to table and wanted to split them in to tow halves and run in two SQL worksheets.Small number of rows. 50,000 rows can be inserted in seconds. Not sure why you want to split it. Parallel inserts into the same table is not usually a problem. Contention could be around free lists, initrans and so on - especially if using RAC and inserting something like 50,000+ rows every second. But the table defaults usually suffice.
    Note that both will try to insert on the same table.So what? This is exactly what Oracle expects and what it is designed to do.
    Please let me know whether it is advisable or tell me an alternative way.Well, you mentioned SQL worksheets - why? Exactly how does the INSERT statements look like? Where does the data to insert come from? Is shared insert cursors used (bind variables compulsory)? The bottleneck and problem could very well be on your side and not with the actual inserts into the table.

  • Using 1million insert statement to create a table

    Dear Expert;
    Lets say someone sent you about 2 million insert statements and you want to use them to insert into a table or create a new table...How do you go about doing so...
    because I tried just highlighting all the insert statement and executing them, however that didnt work in pl/sql developer, it was crashing everytime I did so
    The other way might be to create a loop for them and inserting about 10,000 at a time...but is there a faster way to do it...
    All help is appreciated it..

    user13328581 wrote:
    Dear Expert;
    Lets say someone sent you about 2 million insert statements and you want to use them to insert into a table or create a new table...How do you go about doing so...
    because I tried just highlighting all the insert statement and executing them, however that didnt work in pl/sql developer, it was crashing everytime I did soDo it in SQL*PLUS. It can handle such large files.
    And let it run at night so that other users are not influenced that much by your session.
    You might want to add very few commits somewhere in between. However in case something breaks you then need to know which insert was still executed and which one one.

  • Relation between record in a form and insert statement written in button

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production).
    i have a master detail form with relation
    A is master of B, B is master of C and a button which resides on control block(other than A,B,C).
    so i will insert a one record into the block 'A' and i will press button which will insert particular record into particular table.
    so when i try to move to next record('A' block) it is asking for database change. when i give 'yes' everything is ok. but when i give 'no'(w.r.t that record) and moves to next record and inserts the record and insert record throguh button also, at this time user press 'yes' then the first record is not saving but what ever i have inserted through the insert statement is not rolling back.
    How can i control insert statement with the respect to datablock change in the block.
    The block 'C' data is going to the other table through insert statement the block 'C' i am posting. So due to 'post' the block is not getting cleared so insert statement is also firing.
    In other words i want to unpost the posted data when user press 'no' in the database message.
    I know there is nothing to do with the forms message. But is its possible to control when user press 'no' then the insert statement should not gets saved into the table.
    Please help.
    Thanks..
    Edited by: GD on Jun 27, 2011 5:38 AM

    First off, you need to understand how Oracle Forms interacts with an Oracle database. Forms natively handles all DML transactions for you. Meaning, if you have a Forms data block based on a database table, Forms will generate all the necessary DML to handle any changes that occur in that block. You do not need to write your own DML statements in code.
    so i will insert a one record into the block 'A' and i will press button which will insert particular record into particular table.Is Block "A" based on a table? How are you inserting the record into the table? If you are writting your own DML to insert the record this would explain why you are being prompted to save when you change records. As I mentioned, if your block is based on a table, Forms will know if you change a value within the block.
    How can i control insert statement with the respect to datablock change in the block.If your blocks are based on tables, let Forms handle the DML! don't do it yourself.
    In other words i want to unpost the posted data when user press 'no' in the database messageIf your block is based on a table, when you are prompted to save changes - answering 'NO' will automatically clear the current record of the data block (in essence - rollback the change).
    Craig...

Maybe you are looking for

  • Customer fields replication in Sales order from R/3 to CRM

    Hi all, I want to replicate, for Sales orders, one field (ZFIELD_A) on item level (VBAP) from R/3 to CRM . I used transaction EEWB on CRM with the option "Adding new fields to Business transactions" and I flagged checkbox "Also used in R/3". All work

  • Can Windows no longer read HFS volumes?

    Greetings, I have recently installed Boot Camp and Windows 7 on my new (2012) iMac.  So far, so good - no major problems in getting Windows up and running.  However, unlike my older Boot Camp installation, this one does not seem to mount, even read-o

  • Can we compress LOBs in 10g?

    Hi, Is it possible to compress LOBs in 10g? As far as I know, it isn't. But please do reply if you know otherwise. Regards, Rahul

  • Problems with file size

    There are a few discussions on this subject but I've been unable to resolve my problem. I created a 24 page catalogue in InDesign, file size c30Mb. When I export to Acrobat the resulting file is about 11.5Mb. I need to get this down to 5Mb for online

  • Can't open PageMaker file

    Using OSX 10.4.11 and ID CS2. Shouldn't we be able to open a PageMaker 5.2 document? Indesign CS2 gives the message: "Cannot open the file . . . may not support the file format, a plug-in that supports that file format may be missing." We do have "PM