An example of a Procedure that inserts a record into an introspected table

An example of a Procedure that inserts a record into an introspected table

book

Article ID: KB0082373

calendar_today

Updated On:

Products Versions
TIBCO Data Virtualization v 7.0.0 and higher

Description

The following procedure demonstrates how to insert a record containing two values (10, 20) into an introspected table named TESTTABLE. If the insert fails to execute because an exception was returned, the procedure displays the exception on the Studio Console using a PRINT statement. 

PROCEDURE p_insert()
 BEGIN 
 INSERT INTO /shared/DATASOURCES/Oracle_datasource1/JOE/TESTTABLE VALUES (10, 20); 
 EXCEPTION
 ELSE IF (LENGTH(CURRENT_EXCEPTION.MESSAGE) > 1 )
 THEN
 CALL PRINT ('The insert failed due to an exception : ' || CURRENT_EXCEPTION.MESSAGE);
 CALL PRINT ('----------------the trace is below -----------------------------------');
 CALL PRINT (CURRENT_EXCEPTION.TRACE);
 CALL PRINT ('---------------- end of the trace -----------------------------------');
 END IF;

END

For instance, if this is an Oracle data source and TESTTABLE no longer exists in the Oracle database , the following message will be displayed:

[11:16:52 209] ----------------the trace is below -----------------------------------
 /lib/debug/Print('/lib/util/System.SystemException (1900011): A system exception has occurred. Unable to execute "INSERT INTO "JOE"."TESTTABLE" ("ID1","ID2") VALUES (10,20)" in data source
 "/shared/DATASOURCES/Oracle_datasource1". SQL State = 42000 SQL Error Code = 942
[data-3911071]
 Caused by: ORA-00942: table or view does not exist
---------------- end of the trace -----------------------------------

Issue/Introduction

An example of a Procedure that inserts a record into an introspected table