Using Oracle Pro*C in C/C++, we can use host arrays for managing bulk inserts into the EMP table as per following example:
struct
{
char ename[3][10];
int eno[3];
} emp_rec1;
struct
{
int dno[3];
} emp_rec2;
...
strcpy(emp_rec1.ename[0], "e1");
strcpy(emp_rec1.ename[1], "e2");
strcpy(emp_rec1.ename[2], "e3");
emp_rec1.eno[0] = 1964; emp_rec2.dno[0] = 5;
emp_rec1.eno[1] = 1974; emp_rec2.dno[1] = 5;
emp_rec1.eno[2] = 1985; emp_rec2.dno[2] = 5;
EXEC SQL INSERT INTO emp (ename, eno, dno)
VALUES (:emp_rec1, :emp_rec2);
Can I do a MERGE using EXEC SQL MERGE
kind of to try an update first (if ename and eno exist) with dno getting updated, if does not exist then of course insert to do a bulk merge instead of trying to merge one record at a time, e,g, do a select first, of record exists, try an update else apply insert.
Please help with similar example and syntax for bulk merge as embedded SQL in Pro*C.