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.

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();

  • Using insert statements for creating objects..pls help

    Hello all,
    I have 2 databases DB1 (which is running on 8i) and DB2( Running on 10G).
    How can I copy all the objects of a particular schema (user1) from DB1 to DB2, only by using INSERT statements. I do not want to use import/export since it is taking huge time for the operation.
    Could anybody help me on this?
    Regards,
    chotu

    Since I have allready imported indexes,procedures etc , now I need only to copy tables from DB1 to DB2.
    I have truncated all the tables of user1 in DB2
    Now I am using,
    insert into my_tab as select * from user1.my_tab@DB2_db_link;
    Thanks for the help...
    chotu.

  • Using SQL view object to create ADF table

    Hi,
    I have created a column called "Month" (which extracts month from the date column) and another column to count the no. of requests.
    i want to create an ADF table with 2 columns, a column showing the month and another is showing the no. of requests for that month.
    However, now I only managed to achieve the ADF table to show the overall total requests, which means if i add up all the requests for all the months and i get 500
    My ADF table shows this:
    Jan: 500
    Feb: 500
    Mar: 500
    How should I create the view or what should I do to make it such that the no. of request is based on the month?
    Please advice.
    Thanks (:

    Hi,
    For the given situation you can create a Query Based View Object with the following query
    SELECT
    COUNT(TEMP1.DT) REQUEST,
    TO_CHAR(TEMP1.DT, 'Mon') MONTH
    FROM
    TEMP1
    GROUP BY
    TO_CHAR(TEMP1.DT, 'Mon')
    where DT is the date column and temp1 is the name of the database table.
    Following are the steps that i followed to get this query :
    i have taken the following sample table :
    create table temp1
    (srno number primary key,
    dt date)
    *Note you may use any existing column instead of srno or use dt only (i took an extra column as u know we need a primary key /row id)
    the following is the sample data
    insert into temp1 values (1,sysdate);
    insert into temp1 values (2,sysdate);
    insert into temp1 values (3,add_months(sysdate,1));
    insert into temp1 values (4,add_months(sysdate,1));
    insert into temp1 values (5,add_months(sysdate,3));
    insert into temp1 values (6,add_months(sysdate,5));
    the table appears as follows
    SRNO DT
    1 22-JUN-12
    2 22-JUN-12
    3 22-JUL-12
    4 22-JUL-12
    5 22-SEP-12
    6 22-NOV-12
    To start with ADF View Object Creation (Using Jdeveloper 11.1.2):
    Create the view object using Create View Object wizard
    In Step 1. Name window
    set the value for Name : Viewab (you can use any of ur choice)
    In the data source section : select query
    In Step 2. Query window
    a. Click Query builder (it will pop up sql statment window)
    b. In the SQL Statement window
    in quick-pick objects section -> select temp1 table -> shuttle the columns from available list to selected list
    in select clause section -> select srno column from select list-> choose count() function from function drop down list -> insert function -> set alias to REQUEST-> click validate
    now select dt column from select list -> choose to_char() function -> click insert function -> alter the function to to_Char(temp1.DT,'Mon') -> set alias to Month -> click validate
    in the group by clause section -> Click the green symbol to add -> from the expression palette insert dt column -> insert the to_char function -> alter the function to to_char(temp1.DT,'Mon') -> click validate
    in the Entire SQL Query section -> click test query -> in the test query window -> click query result-> you will see the result -> click close -> click ok
    Click next
    Step 3: Bind Variables
    Click Next
    Step 4: Attribute Mappings
    click Finish
    So the view object is ready :)

  • Is it possible to use a case statement when joining different tables based on input parameters?

    Hi,
    I have a scenario where my stored procedure takes 5 parameters and the users can pass NULL or some value to these parameters and based on the parameters, I need to pull data from various tables.
    Is it possible to use a case statement in the join, similar the one in the below example. I'm getting error when I use the below type of statement.
    select a.*
    from a
    case
    when parameter1=1 then
    inner join a on a.id = b.id
    when parameter1=2 then
    inner join a on a.id = c.id
    end;
    Please let me know, if this type of statement works, and if it works will it create any performance issues?. If the above doesn't work, could you please give me some alternate solutions?
    Thanks.

    Here's a technique for joining A to B or C depending on the input parameters. In theory, you are joining to both tables but the execution plan includes filters to skip whichever join is not appropriate. The drawback is that you have to do outer joins, not inner ones.
    CREATE TABLE A AS SELECT LEVEL ak FROM dual CONNECT BY LEVEL <= 100;
    CREATE TABLE b AS SELECT ak, bk
    FROM A, (SELECT LEVEL bk FROM dual CONNECT BY LEVEL <= 10);
    CREATE TABLE c(ak, ck) AS SELECT ak, bk*10 FROM b;
    variable p1 NUMBER;
    variable p2 NUMBER;
    exec :p1 := 1;
    exec :p2 := 20;
    SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
    LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
    LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
    WHERE A.ak <= 9;
    SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
    | Id  | Operation             | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers |
    |   0 | SELECT STATEMENT      |                 |      1 |        |      9 |00:00:00.01 |       7 |
    |*  1 |  HASH JOIN OUTER      |                 |      1 |      9 |      9 |00:00:00.01 |       7 |
    |*  2 |   HASH JOIN OUTER     |                 |      1 |      9 |      9 |00:00:00.01 |       7 |
    |*  3 |    TABLE ACCESS FULL  | A               |      1 |      9 |      9 |00:00:00.01 |       3 |
    |   4 |    VIEW               | VW_DCL_5532A50F |      1 |      9 |      9 |00:00:00.01 |       4 |
    |*  5 |     FILTER            |                 |      1 |        |      9 |00:00:00.01 |       4 |
    |*  6 |      TABLE ACCESS FULL| B               |      1 |      9 |      9 |00:00:00.01 |       4 |
    |   7 |   VIEW                | VW_DCL_5532A50F |      1 |      9 |      0 |00:00:00.01 |       0 |
    |*  8 |    FILTER             |                 |      1 |        |      0 |00:00:00.01 |       0 |
    |*  9 |     TABLE ACCESS FULL | C               |      0 |      9 |      0 |00:00:00.01 |       0 |
    Predicate Information (identified by operation id):
       1 - access("A"."AK"="ITEM_0")
       2 - access("A"."AK"="ITEM_1")
       3 - filter("A"."AK"<=9)
      5 - filter(:P1 IS NOT NULL)
       6 - filter(("B"."AK"<=9 AND "B"."BK"=:P1))
       8 - filter((:P2 IS NOT NULL AND :P1 IS NULL))
       9 - filter(("C"."AK"<=9 AND "C"."CK"=:P2))
    You can see that table C was not really accessed: the buffer count is 0.
    exec :p1 := NULL;
    SELECT /*+ gather_plan_statistics */ A.ak, nvl(b.bk, c.ck) otherk FROM A
    LEFT JOIN b ON A.ak = b.ak AND :p1 IS NOT NULL AND b.bk = :p1
    LEFT JOIN c ON A.ak = c.ak AND :p1 is null and :p2 IS NOT NULL and c.ck = :p2
    WHERE A.ak <= 9;
    SELECT * FROM TABLE(dbms_xplan.display_cursor(NULL,NULL,'IOSTATS LAST'));
    Now table B is not accessed.
    | Id  | Operation             | Name            | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |
    |   0 | SELECT STATEMENT      |                 |      1 |        |      9 |00:00:00.02 |       7 |      2 |
    |*  1 |  HASH JOIN OUTER      |                 |      1 |      9 |      9 |00:00:00.02 |       7 |      2 |
    |*  2 |   HASH JOIN OUTER     |                 |      1 |      9 |      9 |00:00:00.01 |       3 |      0 |
    |*  3 |    TABLE ACCESS FULL  | A               |      1 |      9 |      9 |00:00:00.01 |       3 |      0 |
    |   4 |    VIEW               | VW_DCL_5532A50F |      1 |      9 |      0 |00:00:00.01 |       0 |      0 |
    |*  5 |     FILTER            |                 |      1 |        |      0 |00:00:00.01 |       0 |      0 |
    |*  6 |      TABLE ACCESS FULL| B               |      0 |      9 |      0 |00:00:00.01 |       0 |      0 |
    |   7 |   VIEW                | VW_DCL_5532A50F |      1 |      9 |      9 |00:00:00.01 |       4 |      2 |
    |*  8 |    FILTER             |                 |      1 |        |      9 |00:00:00.01 |       4 |      2 |
    |*  9 |     TABLE ACCESS FULL | C               |      1 |      9 |      9 |00:00:00.01 |       4 |      2 |

  • Use Multiple Insert Statements in Prepared Statements

    Hi Friends
    i am stuck in a problem for which i need your help.i will brief you about the issue below.
    I am having Multiple Insert Statements which i need to execute to put the data in the database.i have a doubt about the use of the executeUpdate() function in the statement interface. sample code is as below.
    stmt = conn.prepareStatement("INSERT INTO Client ( clientPk, provincePk, countryPk, statusPk, branchPk, salutation, ) VALUES(PID, 2, '123123123', '123', '66', 1, 1 );");
    int n =stmt.executeUpdate();
    Now the problem is how do i insert multiple Insert statements using the conn.prepareStatement().should i do like
    stmt = conn.prepareStatement("")
    int n =stmt.executeUpdate();
    stmt = conn.prepareStatement("")
    int n =stmt.executeUpdate();
    stmt = conn.prepareStatement("")
    int n =stmt.executeUpdate(); ..................................
    should i use the same steps to execute each individual query and then use executeUpdate().
    Please let me know the correct procedure to be followed to execute these tasks.waiting for a positive reply from your side.
    Thanks & Regards
    Vikram K

    Hi
    Thanks a lot once agin for the reply.
    I think i have figured out the solution. I am using SQL statements in the Prepared statements(""). But now i have dropped the idea of using the prepared statement and decided to use the simple Statement instead.
    what i have done is as below.
    conn = ConnectionFactory.getInstance().getConnection();
    stmt = conn.createStatement();
    stmt.executeUpdate("INSERT INTO Client ( clientPk, provincePk, countryPk, statusPk, branchPk, salutation, heightMeasurementType, weightMeasurementType ) VALUES(PID, '1', '1', '0', '1', 'Mr', CONCAT('Jason ', PID), 'R', 'Mawdsley', '123', '66', 1, 1 );");
    stmt.executeUpdate("INSERT into Cp () Values ()");
    stmt.executeUpdate("INSERT into gp () Values ()");
    stmt.executeUpdate("INSERT into jk () Values ()");
    I think this makes sense to use the Statement and execute all the queries in one shot rather than using PS.
    thanks a lot for your help.
    Regards
    Vikram K

  • Functions used in INSERT statement

    i created 10 functions,eg, get_value(p_code, p_date). Each function only runs a very simple SELECT sql to retrieve the value from an individual mapping table based on 2 parameters input.
    I want to transform the records from TABLE_B to TABLE_A for 2 million records as follows:
    INSERT INTO TABLE_A
    (EVENT_DATE
    A_FIELD_01_CDE,
    A_FIELD_01_VAL,
    A_FIELD_02_CDE,
    A_FIELD_02_VAL,
    A_FIELD_10_CDE,
    A_FIELD_10_VAL)
    SELECT sysdate,
    B_FIELD_01_CDE,
    get_value(B_FIELD_01_CDE, sysdate),
    B_FIELD_02_CDE,
    get_value(B_FIELD_02_CDE, sysdate),
    B_FIELD_10_CDE,
    get_value(B_FIELD_10_CDE, sysdate)
    FROM TABLE_B
    Is this a good way to do so? Or I should write in another approach, eg, UPDATE each field one by one?
    Thanks.

    If just a table transformation has to be done, the first thing I would consider would be:
    insert into table_a
    select sysdate
           b_field_01_cde,
           (select single_value from mapping_table <using b_field_01_cde and sysdate>),
           b_field_02_cde,
           (select single_value from mapping_table <using b_field_02_cde and sysdate>),
           b_field_10_cde,
           (select single_value from mapping_table <using b_field_10_cde and sysdate>)
      from table_bJust a materialization of proposals by Sailaja Pasupuleti (insert into as select -> the fastest) and Daniel A. Morgan (plain SQL i.e. no SQL <-> PL/SQL context switching)
    No need for deep elaboration as a transformation is a one time job to be done fast (we always try to be that way) and with minimal "collateral damage" (no-more-for-any-use functions scattered around for example, just a single script to be stored just in case ...)
    Regards
    Etbin

  • Insert Statement for Form on Table with Report

    I'm using a 'getID' process On Load Before Header to make sure I get an ID for my form per suggestion from blarman here. The form has many fields from one table and four collections. If I let the process run as I think it should (when the ID is null) the link to the report does not fetch any field except the id. If I set the process to never run everything loads but my update process doesn't run. What am I doing wrong? Advance thanks...
    Alexandra
    Get ID Process
    declare
      new_id   NUMBER;   --gets the next sequence number for new record ID
    begin
    INSERT INTO DOC_INFO (DOC_INFO_ID,OWNER_ID,STATUS_ID, DOCNO, DOC_TITLE, REVISION, STATUS_DT,ISSUE_DT, REVIEW_DT, ECRNO,  ECR_LINK, DOC_LINK, COMMENTS, KEYWORDS, DOC_TYPE, ASSOC_ITEMNO, FILE_TYPE, FILE_NAME, CHANGE_TYPE, NEW_DOCNO) values(new_id, 0, 0, '', '', '', '','', '', '', '', '', '', '', '', '', '', '', '','');
      :P26_DOC_INFO_ID  := new_id;
    end;Update Process (On Submit/After Comp...)
    Update DOC_INFO
    SET
    DOC_INFO_ID   = :P26_DOC_INFO_ID,
    OWNER_ID  = :P26_OWNER_ID,
    STATUS_ID  = :P26_STATUS_ID,
    DOCNO  = :P26_DOCNO,
    DOC_TITLE  = :P26_DOC_TITLE,
    REVISION  = :P26_REVISION,
    STATUS_DT  = :P26_STATUS_DT,
    ISSUE_DT  = :P26_ISSUE_DT,
    REVIEW_DT  = :P26_REVIEW_DT,
    ECRNO  = :P26_ECRNO,
    ECR_LINK  = :P26_ECR_LINK,
    DOC_LINK  = :P26_DOC_LINK,
    COMMENTS  = :P26_COMMENTS,
    KEYWORDS  = :P26_KEYWORDS,
    DOC_TYPE  = :P26_DOC_TYPE,
    ASSOC_ITEMNO  = :P26_ASSOC_ITEMNO,
    FILE_TYPE  = :P26_FILE_TYPE,
    FILE_NAME  = :P26_FILE_NAME,
    CHANGE_TYPE  = :P26_CHANGE_TYPE,
    NEW_DOCNO = :P26_NEW_DOCNO
    WHERE DOC_INFO_ID = :P26_DOC_INFO_ID;

    Got it...I think it had to do with the use of my 'Create' and 'Apply Changes' buttons.
    Thanks for your time anyway.

  • Insert statement in to internal table

    I have an editable ALV LIST report with the check box to it. When the user checks the check box on the report and hits a push Button it should copy the row from the internal table and insert the row to the same internal table in the next line.
    I had my code in this way,
        WHEN 'COPY'.
          LOOP AT t_output INTO wa_output.
            IF wa_output-chkbox = 'X'.
              wa_output-zactual = 0.
              wa_output-zqty = 0.
              INSERT wa_output INTO t_output INDEX sy-tabix.
            ENDIF.
          ENDLOOP.
    However the problem was,
    For e.g. let say I have only 3 rows in the internal table. So when the user selects the last, 3rd row and hits the push button the 3rd row copied and is inserted in the 3rd row. The user wanted the copied row in the next row, ie the 4th row.
    SO I changed the above code as below and now it goes to an endless loop.
        WHEN 'COPY'.
          LOOP AT t_output INTO wa_output.
            IF wa_output-chkbox = 'X'.
              wa_output-zactual = 0.
              wa_output-zqty = 0.
              Sy-tabix = sy-tabix + 1.
              INSERT wa_output INTO t_output INDEX sy-tabix.
            ENDIF.
          ENDLOOP.
    <b>I dont want to use another internal table.</b>
    I hope I am clear.
    Please suggest,
    Ster.

    Hi,
    Change the code as follows.
      data: lv_cnt type i.
        describe table t_output lines lv_cnt.
         LOOP AT t_output INTO wa_output where wa_output-chkbox = 'X'          
                                                                and  wa_output-zactual = 0
                                                                and  wa_output-zqty = 0.
              lv_cnt = lv_cnt + 1.
              INSERT wa_output INTO t_output INDEX lv_cnt.
          ENDLOOP.
    Regards
    Sailaja.

  • Error while creating partition table

    Hi frnds i am getting error while i am trying to create a partition table using range
    getting error ORA-00906: missing left parenthesis.I used the following statement to create partition table
    CREATE TABLE SAMPLE_ORDERS
    (ORDER_NUMBER NUMBER,
    ORDER_DATE DATE,
    CUST_NUM NUMBER,
    TOTAL_PRICE NUMBER,
    TOTAL_TAX NUMBER,
    TOTAL_SHIPPING NUMBER)
    PARTITION BY RANGE(ORDER_DATE)
    PARTITION SO99Q1 VALUES LESS THAN TO_DATE(‘01-APR-1999’, ‘DD-MON-YYYY’),
    PARTITION SO99Q2 VALUES LESS THAN TO_DATE(‘01-JUL-1999’, ‘DD-MON-YYYY’),
    PARTITION SO99Q3 VALUES LESS THAN TO_DATE(‘01-OCT-1999’, ‘DD-MON-YYYY’),
    PARTITION SO99Q4 VALUES LESS THAN TO_DATE(‘01-JAN-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q1 VALUES LESS THAN TO_DATE(‘01-APR-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q2 VALUES LESS THAN TO_DATE(‘01-JUL-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q3 VALUES LESS THAN TO_DATE(‘01-OCT-2000’, ‘DD-MON-YYYY’),
    PARTITION SO00Q4 VALUES LESS THAN TO_DATE(‘01-JAN-2001’, ‘DD-MON-YYYY’)
    ;

    More than one of them. Try this instead:
    CREATE TABLE SAMPLE_ORDERS
    (ORDER_NUMBER NUMBER,
    ORDER_DATE DATE,
    CUST_NUM NUMBER,
    TOTAL_PRICE NUMBER,
    TOTAL_TAX NUMBER,
    TOTAL_SHIPPING NUMBER)
    PARTITION BY RANGE(ORDER_DATE) (
    PARTITION SO99Q1 VALUES LESS THAN (TO_DATE('01-APR-1999', 'DD-MON-YYYY')),
    PARTITION SO99Q2 VALUES LESS THAN (TO_DATE('01-JUL-1999', 'DD-MON-YYYY')),
    PARTITION SO99Q3 VALUES LESS THAN (TO_DATE('01-OCT-1999', 'DD-MON-YYYY')),
    PARTITION SO99Q4 VALUES LESS THAN (TO_DATE('01-JAN-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q1 VALUES LESS THAN (TO_DATE('01-APR-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q2 VALUES LESS THAN (TO_DATE('01-JUL-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q3 VALUES LESS THAN (TO_DATE('01-OCT-2000', 'DD-MON-YYYY')),
    PARTITION SO00Q4 VALUES LESS THAN (TO_DATE('01-JAN-2001', 'DD-MON-YYYY')))In the future, if you are having problems, go to Morgan's Library at www.psoug.org.
    Find a working demo, copy it, then modify it for your purposes.

  • Using sqlerrm in insert statement in 10g

    Hi,
    I do not have 10g to test the following snippet, which tries to use sqlerrm in an insert statement:
    -- start testcase
    drop table tbl;
    drop table err;
    create table tbl (x number);
    create table err (a number, b varchar2(4000));
    declare
      n_tmp   tbl.x%type;
    begin
      select x into n_tmp from tbl;
    exception
      when others then
        -- the line below works in 9i
        -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
        -- but the insert statement doesn't work in 9i, how about 10g ?
        insert into err(a,b) values (1,sqlerrm);
        commit;
    end;
    declare
      n_tmp   tbl.x%type;
    begin
      select x into n_tmp from tbl;
    exception
      when others then
        -- the line below works in 9i
        -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
        -- the insert statement works in 9iR2 but the error message is
        -- not the one sought, how about 10g ?
        insert into err(a,b) values (1,sys.standard.sqlerrm);
        commit;
    end;
    /Can someone test it on any release/edition of 10g please ?
    The tests on 9iR2 below behave predictably:
    SQL>
    SQL> @ver
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE    9.2.0.8.0       Production
    TNS for Solaris: Version 9.2.0.8.0 - Production
    NLSRTL Version 9.2.0.8.0 - Production
    SQL>
    SQL>
    SQL> -- start testcase
    SQL> drop table tbl;
    Table dropped.
    SQL> drop table err;
    Table dropped.
    SQL>
    SQL> create table tbl (x number);
    Table created.
    SQL> create table err (a number, b varchar2(4000));
    Table created.
    SQL>
    SQL> declare
      2    n_tmp   tbl.x%type;
      3  begin
      4    select x into n_tmp from tbl;
      5  exception
      6    when others then
      7      -- the line below works in 9i
      8      -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
      9      -- but the insert statement doesn't work in 9i, how about 10g ?
    10      insert into err(a,b) values (1,sqlerrm);
    11      commit;
    12  end;
    13  /
        insert into err(a,b) values (1,sqlerrm);
    ERROR at line 10:
    ORA-06550: line 10, column 36:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 10, column 5:
    PL/SQL: SQL Statement ignored
    SQL>
    SQL> --
    SQL> declare
      2    n_tmp   tbl.x%type;
      3  begin
      4    select x into n_tmp from tbl;
      5  exception
      6    when others then
      7      -- the line below works in 9i
      8      -- dbms_output.put_line('Sqlerrm: '||sqlerrm);
      9      -- the insert statement works in 9iR2 but the error message is
    10      -- not the one sought, how about 10g ?
    11      insert into err(a,b) values (1,sys.standard.sqlerrm);
    12      commit;
    13  end;
    14  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select * from err;
             A B
             1 ORA-0000: normal, successful completion
    SQL>
    SQL>The behavior of the second pl/sql block was mentioned by Nicolas:
    Re: INSERT INTO ..VALUES (SQLERRM, SQLCODE, SYSDATE) doesn't work?
    Is there any change in 10g ?
    Thanks in advance,
    pratz
    (Sorry, the hyperlink is getting modified automatically; remove the backslash ("\") immediately before the ampersand ("&") character.)
    Message was edited by:
    pratz

    Same in 10.2.0.3.0
    SQL*Plus: Release 10.1.0.4.2 - Production on Thu Jan 24 11:55:53 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> drop table tbl;
    Table dropped.
    SQL>
    SQL> drop table err;
    Table dropped.
    SQL> 
    SQL> create table tbl (x number);
    Table created.
    SQL>
    SQL> create table err (a number, b varchar2(4000));
    Table created.
    SQL> declare 
      2  n_tmp   tbl.x%type;
      3  begin  select x into n_tmp from tbl;
      4  exception  when others then  
      5  -- the line below works in 9i    
      6  --dbms_output.put_line('Sqlerrm: '||sqlerrm);   
      7  -- but the insert statement doesn't work in 9i, how about 10g ?   
      8  insert into err(a,b) values (1,sqlerrm);   
      9  commit;
    10  end;
    11  /
    insert into err(a,b) values (1,sqlerrm);
    ERROR at line 8:
    ORA-06550: line 8, column 32:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 8, column 1:
    PL/SQL: SQL Statement ignored
    SQL>  declare 
      2   n_tmp   tbl.x%type;
      3   begin 
      4   select x into n_tmp from tbl;
      5   exception  when others then   
      6   -- the line below works in 9i    
      7   --dbms_output.put_line('Sqlerrm: '||sqlerrm);   
      8   -- the insert statement works in 9iR2 but the error message is    -- not the one sought, how a
    bout 10g ?    i
      9   insert into err(a,b) values (1,sys.standard.sqlerrm);   
    10   commit;
    11   end;
    12   /
    PL/SQL procedure successfully completed.
    SQL> select * from err;
             A
    B
             1
    ORA-0000: normal, successful completion
    SQL>

  • Using System::ErrorDescription in Insert statement

    Hello,
    I want to insert System::ErrorDescription to store the error in the customized log table. When I use the following statement, it does not insert anything. What am i doing wrong. Please advice.
    create table dbo.load_err(load_err_id integer(PK),load_err_Dtl,loadtime)
    INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,
     @[System::ErrorDescription] ,
    getdate())
    I see the row inserted but nothing in the Load_ERR_DTL column.

    Where are you using the insert statement? The ErrorDescription  variable is only available inside OnError,OnWarning and OnInformation event handlers
    http://msdn.microsoft.com/en-IN/library/ms141788.aspx
    Also you need to use insert statement as below
    INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,
    getdate())
    and map parameter0 to  @[System::ErrorDescription] in parameters tab
    another way is to set SQLSourceType
    as Variable and set a variable for the query with below expression as
    "INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,'" +
    @[System::ErrorDescription] + "',
    getdate())"
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • 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 package call in insert statement.

    insert into
    as_portal_credentials_test
    values('id', 'key','expid',UTL_RAW.CAST_TO_RAW('zTMwv2.[[?~d'))                                                                                                                                                                                                               

    Where are you using the insert statement? The ErrorDescription  variable is only available inside OnError,OnWarning and OnInformation event handlers
    http://msdn.microsoft.com/en-IN/library/ms141788.aspx
    Also you need to use insert statement as below
    INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,
    getdate())
    and map parameter0 to  @[System::ErrorDescription] in parameters tab
    another way is to set SQLSourceType
    as Variable and set a variable for the query with below expression as
    "INSERT INTO dbo.LOAD_ERR (LOAD_ERR_ID,
    LOAD_ERR_DTL,
    loadtime)
    VALUES (NEXT VALUE FOR dbo.LOAD_ERR_SEQ,'" +
    @[System::ErrorDescription] + "',
    getdate())"
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Create target table using ODI model

    Hi all,
    I am new to ODI. I am trying export RDBMS table to RDBMS table from source to target.
    whether we need to create target table structure in trg schema or we can create using obi trg model by selecting new datastore.
    In owb while loading target tables are created and data will be loaded.
    Pls help me regarding this.
    thanks in advance.

    Hi
    You can create it in both ways.if you create datastore by using ODI you must select create target table option in flow while loading to target.

Maybe you are looking for

  • Pictures not displaying in received email.

    I receive frequent emails from SweetJack.com. There are descriptions of their offers over gray blank boxes. I opened the same mail from Outlook.com's website and they display correctly. I am stumped. I have a screenshot of the problem but don't know

  • Load balancing Http/https requests of SRM

    Hi all, we are on SRM 5.0 with CI and one DI , we don't have any web dispatcher for routing http/https requests. Currently CI is flooded with all requests and DI is sitting idle no routing  is  going on.... and users are experiencing Time out expcept

  • [solved] Interpreting gdb errors for bin32 application

    Hi all, I have a 32-bit app which I've happily run till about 2 weeks back on 64-bit Arch, called OpenSong. Its open source but uses RealBasic to compile cross-architecture, and realbasic doesn't support 64-bit on Linux. Anyway, I started getting seg

  • How to 'group' my many Podcast Channels?

    Hi all, I have so many different Podcast Channels that I'd like to be able to group them so that when I'm in a certain mood (Sci-Fi, Science, Greenie, History, etc), I can click on the 'group's column and it will sort according to that category or gr

  • Nesting error when re-using groups

    JDev 11.1.1.4, JHS 11.1.1.3.35 I have two related objects, ObjectA and ObjectB. In my app I need a primary form for ObjectA, with ObjectB on a detail group, plus a primary form for ObjectB with ObjectA as a detail group. I create re-usable groups, Gr