4 Replies Latest reply on Feb 14, 2013 5:14 PM by shawkins

    Insert multiple rows to datasource through Teiid

    jane_lj

      Hi,

       

      If I run SQL like:

       

      INSERT INTO tablename SELECT * from tablename2.....

       

      insert multiple rows to data source through Teiid, how does Teiid handle this SQL?  Run multiple INSERT statement or some other way?  I need to understand it to write my translator for INSERT.

       

      Thanks.

        • 1. Re: Insert multiple rows to datasource through Teiid
          rareddy

          It if translator supports Bulk Inserts then it pushes as single command, if not supported then executed as multiple commands. See "supportsBulkUpdate" on ExecutionFactory class. Also see TestJDBCUpdateExecution class for example as to how JDBC translator is supporting it.

          • 2. Re: Insert multiple rows to datasource through Teiid
            shawkins

            bulk is the prefered, but if supportsBatchedUpdates is supported the engine will issue a org.teiid.language.BatchedUpdates command that contains multiple inserts, and then as Ramesh says it will revert to single row inserts.

             

            When bulk is supported the pushdown insert will contain org.teiid.language.Parameter expressions in place of the values, which will reference the rows available from the org.teiid.language.BatchedCommand.getParameterValues().

            1 of 1 people found this helpful
            • 3. Re: Insert multiple rows to datasource through Teiid
              jane_lj

              Thanks a lot, Ramesh and steven.

               

              I have taken a look at the code of TestJDBCUpdateExecution, it helps.

               

              One more question here, if I set both supportsBatchedUpdates and supportBulkUpdate to false, what will happen? For this case, can my tranlator just handle single row insert?

               

              Thanks.

              • 4. Re: Insert multiple rows to datasource through Teiid
                shawkins

                Yes, single row is the default.

                 

                Steve