----------------- REPLACE statement ----------------- Function: Allow to update or insert a record based on the existence or not of it. Author: Adriano dos Santos Fernandes Syntax rules: REPLACE INTO [()] VALUES () [MATCHING ] [RETURNING [INTO ]] Scope: DSQL, PSQL Examples: 1. REPLACE INTO T1 (F1, F2) VALUES (:F1, :F2); 2. REPLACE INTO EMPLOYEE (ID, NAME) VALUES (:ID, :NAME) RETURNING ID; 3. REPLACE INTO T1 (F1, F2) VALUES (:F1, :F2) MATCHING (F1); Notes: 1. Views are only allowed if it's based on only one table (i.e. no joins or unions). 2. When MATCHING is omitted, the existence of a primary key is required. 3. INSERT and UPDATE permissions are needed on
. 4. If the RETURNING clause is present, then the statement is described as isc_info_sql_stmt_exec_procedure by the API. Otherwise it is described as isc_info_sql_stmt_insert. Limitation: 1. A singleton error will be raised if the RETURNING clause is present and more than one record match the condition.