Published on InterSystems Developer Community (https://community.intersystems.com)

Home > How to perform multiple row SQL insert to a Linked Oracle Database record using DLLImport

Question
Dom GMMH NHS Trust · Mar 17, 2022

How to perform multiple row SQL insert to a Linked Oracle Database record using DLLImport

Hi, we are trying to run a dynamically generated Oracle Insert SQL script using Do $SYSTEM.SQL.DDLImport("Oracle",""," sql.txt",[Error Log]) to insert multiple rows into a Linked Table within HealthConnect to an Oracle database.


We have tried using statements that are accepted within Oracle but not when using Intersystems DLL along the lines of :

INSERT  INTO mytable (column1, column2, column_n)
  SELECT expr1, expr2, expr_n FROM Dual  UNION ALL
   SELECT expr1, expr2, expr_n FROM Dual;
  
SELECT mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
  INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
  INTO mytable (column1, column2, column_n) VALUES (expr1, expr2, expr_n)
  SELECT * FROM Dual;

However, this produces error since Dual is not a recognised table.

We would prefer not to use multiple INSERT statements due to the overheads of running what would be a large number of records.

Is there a recommended solution to achieve this? Many thanks

#SQL #InterSystems IRIS
Product version: IRIS 2020.1

Source URL:https://community.intersystems.com/post/how-perform-multiple-row-sql-insert-linked-oracle-database-record-using-dllimport