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.

Similar Messages

  • How to tune the Update statement for 20 million rows

    Hi,
    I want to update 20 million rows of a table. I wrote the PL/SQL code like this:
    DECLARE
    v1
    v2
    cursor C1 is
    select ....
    BEGIN
    Open C1;
    loop
    fetch C1 bulk collect into v1,v2 LIMIT 1000
    exit when C1%NOTFOUND;
    forall i in v1.first..v1.last
    update /*+INDEX(tab indx)*/....
    end loop;
    commit;
    close C1;
    END;
    The above code took 24 mins to update 100k records, so for around 20 million records it will take 4800 mins (80 hrs).
    How can I tune the code further ? Will a simple Update statement, instead of PL/SQL make the update faster ?
    Will adding few more hints help ?
    Thanks for your suggestions.
    Regards,
    Yogini Joshi

    Hello
    You have implemented this update in the slowest possible way. Cursor FOR loops should be absolute last resort. If you post the SQL in your cursor there is a very good chance we can re-code it to be a single update statement with a subquery which will be the fastest possible way to run this. Please remember to use the {noformat}{noformat} tags before and after your code so the formatting is preserved.
    David                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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;

  • 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 generate the insert staments of all schema tables with one DBPROC

    [code]CREATE DBPROC SCHEMA_INSERT_SCRIPT
    AS
    VAR L_STATEMENT VARCHAR(500) ;
    L_COL_NAME VARCHAR(50);
    L_ALL_TAB_COLS VARCHAR(400);
    L_TAB_NAME VARCHAR(50);
    L_SQL VARCHAR(1000);
    TRY
          SET L_ALL_TAB_COLS = ' ';
          DECLARE C_TAB_CUR CURSOR
          FOR
            SELECT T.TABLENAME,C.COLUMNNAME
            FROM DOMAIN.TABLES T, DOMAIN.COLUMNS C
            WHERE T.OWNER='SCOTT2'
            AND T.TABLENAME = C.TABLENAME
            AND  T.TABLENAME='DEPT';
          WHILE $RC = 0 DO
          BEGIN
          FETCH C_TAB_CUR INTO :L_TAB_NAME, :L_COL_NAME;
    SET L_ALL_TAB_COLS = L_ALL_TAB_COLS || L_COL_NAME || ',';
          DELETE FROM SCOTT2.QUERY;
    INSERT INTO SCOTT2.QUERY VALUES
    ('insert  into '||TRIM( :L_TAB_NAME) ||
    '(' || SUBSTR(:L_ALL_TAB_COLS,1,LENGTH(:L_ALL_TAB_COLS)-1)||
    INSERT INTO SCOTT2.QUERY VALUES( 'values (');
       END;
        CATCH   
        CLOSE C_TAB_CUR;[/code]
    till now i am getting output as
    insert into DEPT(DEPTNO,DNAME,LOC)
    values (
    but i want output from this procedure as
    insert into DEPT(DEPTNO,DNAME,LOC)
    values (10,'SALES','NEWYORK')
    so kindly help me out how can i access the data from tables and create the insert statements of the table.
    with this above Procedure,i want to generate the insert statments of the table.
    please advice me how can i go.
    thanks,Bhupinder

    Hi,
    from what I understand from your post, the thing that's missing is the retrieval of the data from the tables and its types. This could be done very similar to your already done tablespecs, just perform a select, use a cursor again and in there, make sure that character (etc.) fields get surrounded by '' and integers not.
    Regards,
    Roland

  • How to test the select statement.

    Hi All,
    How to test the select statement.
    Is there any Oracle sqlplus  or toad kind of tool to  test the query.
    thanks
    siva

    Use SQL Trace (ST05) and choose 'Explain one SQL Request'. Enter your SQL command as it should be executed in the underlying database. e.g. if the db is Oracle, the statement should be entered as:
    SELECT matnr,werks,lvorm,dispo
    FROM marc
    WHERE mandt = :a AND
                 matnr = :b AND
                 werks = :c
    In the above :a, :b and :c are place holders for the actual comparison values. You dont have to enter those values. When you choose 'Explain' button, you will find the 'Execution Plan'. The important parameter which denotes the efficiency of the SQL statement is the 'Cost'. The cost should be as low as possible. The table access should be through INDEX UNIQUE SCAN. If you get a FULL TABLE SCAN and higher cost, you need to fine-tune your statement by modifying the where clause.
    If you dont know Oracle SQL statements, execute the program in trace mode and go to the trace and you will find the underlying SQL statements issued to the database.
    Regards
    Suresh Radhakrishnan

  • How to Tune the Transactions/ Z - reports /Progr..of High response time

    Dear friends,
    in <b>ST03</b> work load anlysis menu.... there are some z-reports, transactions, and some programmes are noticed contineously that they are taking the <b>max. response time</b> (and mostly >90%of time is  DB Time ).
    how to tune the above situation ??
    Thank u.

    Siva,
    You can start with some thing like:
    ST04  -> Detail Analysis -> SQL Request (look at top disk reads and buffer get SQL statements)
    For the top SQL statements identified you'd want to look at the explain plan to determine if the SQL statements is:
    1) inefficient
    2) are your DB stats up to date on the tables (note up to date stats does not always means they are the best)
    3) if there are better indexes available, if not would a more suitable index help?
    4) if there are many slow disk reads, is there an I/O issue?
    etc...
    While you're in ST04 make sure your buffers are sized adequately.
    Also make sure your Oracle parameters are set according to this OSS note.
    Note 830576 - Parameter recommendations for Oracle 10g

  • How to tune the query...?

    Hi all,
    I am having a table with millions of records and the query is taking hours
    time. How to tune the query apart from doing the following things.
    1. Creating or Deleting indexes.
    2. Using Bind variables.
    3. Using Hints.
    4. Updating the Statitics regurarly.
    Actually, i have asked this question in interview how to tune the query.
    I told him the above 4 things. Then he told, these are not working, then
    how you will tune this query.
    Thanks in advance,
    Pal

    user546710 wrote:
    Actually, i have asked this question in interview how to tune the query.
    I told him the above 4 things. Then he told, these are not working, then
    how you will tune this query.It actually depends on the scenario/problem given.
    You may want to read this first.
    When your query takes too long ...
    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting
    HOW TO: Post a SQL statement tuning request - template posting

  • How to generate the insert script of the  tables data present  in an entire

    How to generate the insert script of the tables data present in an entire schema in sqlplus environment
    with out toad can you please help me please!!!!!!!!!!!!!

    HI,
    First create this function to get insert scripts.
    /* Formatted on 2012/01/16 10:41 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE FUNCTION extractdata (v_table_name VARCHAR2)
       RETURN VARCHAR2
    AS
       b_found   BOOLEAN         := FALSE;
       v_tempa   VARCHAR2 (8000);
       v_tempb   VARCHAR2 (8000);
       v_tempc   VARCHAR2 (255);
    BEGIN
       FOR tab_rec IN (SELECT table_name
                         FROM user_tables
                        WHERE table_name = UPPER (v_table_name))
       LOOP
          b_found := TRUE;
          v_tempa := 'select ''insert into ' || tab_rec.table_name || ' (';
          FOR col_rec IN (SELECT   *
                              FROM user_tab_columns
                             WHERE table_name = tab_rec.table_name
                          ORDER BY column_id)
          LOOP
             IF col_rec.column_id = 1
             THEN
                v_tempa := v_tempa || '''||chr(10)||''';
             ELSE
                v_tempa := v_tempa || ',''||chr(10)||''';
                v_tempb := v_tempb || ',''||chr(10)||''';
             END IF;
             v_tempa := v_tempa || col_rec.column_name;
             IF INSTR (col_rec.data_type, 'CHAR') > 0
             THEN
                v_tempc := '''''''''||' || col_rec.column_name || '||''''''''';
             ELSIF INSTR (col_rec.data_type, 'DATE') > 0
             THEN
                v_tempc :=
                      '''to_date(''''''||to_char('
                   || col_rec.column_name
                   || ',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
             ELSE
                v_tempc := col_rec.column_name;
             END IF;
             v_tempb :=
                   v_tempb
                || '''||decode('
                || col_rec.column_name
                || ',Null,''Null'','
                || v_tempc
                || ')||''';
          END LOOP;
          v_tempa :=
                v_tempa
             || ') values ('
             || v_tempb
             || ');'' from '
             || tab_rec.table_name
             || ';';
       END LOOP;
       IF NOT b_found
       THEN
          v_tempa := '-- Table ' || v_table_name || ' not found';
       ELSE
          v_tempa := v_tempa || CHR (10) || 'select ''-- commit;'' from dual;';
       END IF;
       RETURN v_tempa;
    END;
    SET PAUSE OFF
    SET LINESIZE 1200
    SET PAGESIZE 100
    SET TERMOUT OFF
    SET HEAD OFF
    SET FEED OFF
    SET ECHO OFF
    SET VERIFY OFF
    SPOOL  GET_INSERTS.SP REP
    SELECT EXTRACTDATA('EMP') FROM DUAL;
    SPOOL OFF
    SET PAUSE  ON
    SET LINESIZE 120
    SET PAGESIZE 14
    SET TERMOUT ON
    SET HEAD ON
    SET FEED 5
    SET ECHO ON
    SET VERIFY ON
    SELECT    'insert into EMP ('
           || CHR (10)
           || 'EMPNO,'
           || CHR (10)
           || 'ENAME,'
           || CHR (10)
           || 'JOB,'
           || CHR (10)
           || 'MGR,'
           || CHR (10)
           || 'HIREDATE,'
           || CHR (10)
           || 'SAL,'
           || CHR (10)
           || 'COMM,'
           || CHR (10)
           || 'DEPTNO) values ('
           || DECODE (empno, NULL, 'Null', empno)
           || ','
           || CHR (10)
           || ''
           || DECODE (ename, NULL, 'Null', '''' || ename || '''')
           || ','
           || CHR (10)
           || ''
           || DECODE (job, NULL, 'Null', '''' || job || '''')
           || ','
           || CHR (10)
           || ''
           || DECODE (mgr, NULL, 'Null', mgr)
           || ','
           || CHR (10)
           || ''
           || DECODE (hiredate,
                      NULL, 'Null',
                         'to_date('''
                      || TO_CHAR (hiredate, 'mm/dd/yyyy hh24:mi')
                      || ''',''mm/dd/yyyy hh24:mi'')'
           || ','
           || CHR (10)
           || ''
           || DECODE (sal, NULL, 'Null', sal)
           || ','
           || CHR (10)
           || ''
           || DECODE (comm, NULL, 'Null', comm)
           || ','
           || CHR (10)
           || ''
           || DECODE (deptno, NULL, 'Null', deptno)
           || ');'
      FROM emp;
    SELECT '-- commit;'
      FROM DUAL;now run the baove select statement you will get the following insert statements
    /* Formatted on 2012/01/16 10:57 (Formatter Plus v4.8.8) */
    --'INSERT INTO EMP('||CHR(10)||'EMPNO,'||CHR(10)||'ENAME,'||CHR(10)||'JOB,'||CHR(10)||'MGR,'||CHR(10)||'HIREDATE,'||CHR(10)||'SAL,'||CHR(10)||'COMM,'||CHR(10)||'DEPTNO)VALUES('||DECODE(EMPNO,NULL,'NULL',EMPNO)||','||CHR(10)||''||DECODE(ENAME,NULL,'NULL',''''|
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7369, 'SMITH', 'CLERK', 7902,
                 TO_DATE ('12/17/1980 00:00', 'mm/dd/yyyy hh24:mi'), 800, NULL, 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7499, 'ALLEN', 'SALESMAN', 7698,
                 TO_DATE ('02/20/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1600, 300, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7521, 'WARD', 'SALESMAN', 7698,
                 TO_DATE ('02/22/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 500, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7566, 'JONES', 'MANAGER', 7839,
                 TO_DATE ('04/02/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2975, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7654, 'MARTIN', 'SALESMAN', 7698,
                 TO_DATE ('09/28/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 1400,
                 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7698, 'BLAKE', 'MANAGER', 7839,
                 TO_DATE ('05/01/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2850, NULL,
                 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7782, 'CLARK', 'MANAGER', 7839,
                 TO_DATE ('06/09/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2450, NULL,
                 10
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7788, 'SCOTT', 'ANALYST', 7566,
                 TO_DATE ('04/19/1987 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7839, 'KING', 'PRESIDENT', NULL,
                 TO_DATE ('11/17/1981 00:00', 'mm/dd/yyyy hh24:mi'), 5000, NULL,
                 10
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7844, 'TURNER', 'SALESMAN', 7698,
                 TO_DATE ('09/08/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1500, 0, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7876, 'ADAMS', 'CLERK', 7788,
                 TO_DATE ('05/23/1987 00:00', 'mm/dd/yyyy hh24:mi'), 1100, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7900, 'JAMES', 'CLERK', 7698,
                 TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 950, NULL, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7902, 'FORD', 'ANALYST', 7566,
                 TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7934, 'MILLER', 'CLERK', 7782,
                 TO_DATE ('01/23/1982 00:00', 'mm/dd/yyyy hh24:mi'), 1300, NULL,
                 10
                );i hope this helps .
    Thanks,
    P Prakash
    Edited by: prakash on Jan 15, 2012 9:21 PM
    Edited by: prakash on Jan 15, 2012 9:22 PM

  • How to use the Include Statement in the BADI

    Dear All,
            I am trying to implement the BADI. So i need to use the Include in the BADI.
    How to use the Include statement in the BADI. I cant able to use it in the Public, Private and protected statement.
    Where should i mention that,,,,
    Thanks
    Yogesh

    Hi Sharat,
      Thanks for your reply.
    I need to use the BADI HRWPC_PCR_APPR_FORM. In which the values are available in the Container. So if i need to use the container values then i need to use that include <cntain>.
    Is there any possible ways to make it.
    Thanks
    Yogesh

  • How to include the insert picture option in the PDF form?

    Hi, Can some one please help How to include the insert picture option in the PDF form? I am using acrobat XI pro and trying to use an evaluation form which requires to insert product pictures.

    Here's a link to a previous topic where this was discussed: http://forums.adobe.com/message/6050458

  • How to organize the import statements in FXML Files?

    Hello,
    I'm a user of NetBeans IDE and it can organize the import statements in *.java files. Now, I'm using JavaFX and editing the *.fxml files as well. I want to know how to organize the import statements in *.fxml files?
    Thanks a lot.

    You should use Scene Builder, it will make all these import statements for you.
    Moreover, it will greatly simplify the writing of your FXML files, since you only have to Drag&Drop JavaFX objects on the scene. Then, it automatically generates FXML files.

  • How to get the previous state of my data after issuing coomit method

    How to get the previous state of some date after issuing commit method in entity bean (It should not use any offline storage )

    >
    Is there any way to get the state apart from using
    offline storage ?As I said the caller keeps a copy in memory.
    Naturally if it is no longer in memory then that is a problem.
    >
    and also what do you mean by auditlog?
    You keep track of every change to the database by keeping the old data. There are three ways:
    1. Each table has a version number/delete flag for each record. A record is never updated nor deleted. Instead a new record is created with a new version number and with the new data.
    2. Each table has a duplicate table which has all of the same columns. When the first table is modified the old data is moved to the duplicate table.
    3. A single table is used which has columns for 'table', 'field', 'data' and 'activity' (update, delete). When a change is made in any table then this table is updated. This is generally of limited useability due to the difficulty in recovering the data.
    All of the above can have a user id, timestamp, and/or additional information which is relevant to the data being changed.
    Note that ALL of this is persisted storage.
    I am not sure what this really has to do with "offline storage" unless you are using that term to refer to backed up data which is not readily available.

  • How to consolidate the financial statements for 3 company codes, assigned t

    Hi Friends,
    How to consolidate the financial statements for 3 company codes, assigned to 3 different companies, 3 different fiscal years, 3 different controlling areas and all the 3 Company Codes assigned to same chart of accounts in the same client?
    Can we need any ABAP program for this (or) Is it possible using Report Painter?
    Please help me.
    Thanks

    Hi friend,
    Is it a real-time situation or something you are visualising ?
    For consolidation, you can use a group chart of accounts and select that in the operative chart of accounts for consolidation purposes.  This would work provided the company codes use the same operative chart of accounts and fiscal year.
    I hope the above would be helpful to you.
    Regards,

  • How to find the inserted values in alv

    Hello All,
    How to find the inserted and deleted values in ALV.
    Regards,
    lisa.

    Hi,
    copy the output table before calling set_table_for_first_display and refresh_display
    then in your event call
    CLASS lcl_alv_handler_1100 DEFINITION.                        
      PUBLIC SECTION.
        METHODS:
          handle_data_changed                                      
             FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed,
    ENDCLASS.  
    after this here you can find modified new output table
    then compare the new output table with older one
    aRs

Maybe you are looking for