Validating in PL/SQL using associative arrays

From: Rich Jesse <rjoralist3_at_society.servebeer.com>
Date: Tue, 14 Jan 2014 11:23:41 -0600 (CST)
Message-ID: <6ba93e5ccb65360d809a16a64b243680.squirrel_at_society.servebeer.com>



Hey all,

In 11.2, I thought I'd try to validate parameters to a procedure using an associative array:

CREATE OR REPLACE PROCEDURE test_assoc (p_owner IN VARCHAR2) AS

	TYPE tt_valid_schema IS TABLE OF BINARY_INTEGER INDEX BY VARCHAR2(30);
	t_valid_schema		tt_valid_schema;

BEGIN
	t_valid_schema('TEST01') := 1;
	t_valid_schema('TEST02') := 1;
	t_valid_schema('TEST08') := 1;
	t_valid_schema('TEST135') := 1;


-- IF t_valid_schema(p_owner)%NOTFOUND THEN
-- RETURN;
-- END IF;

END test_assoc;
/

I'm trying to do what's commented out, but that (obviously) won't work. It seems like I should be able to handle the ORA-1403 with an exception without spinning through the entire array (part of the whole idea of the array being associative), but I can't seem to find an example for this.

Ideas anyone? (other than to put the data in a database table)

TIA!
Rich

--

http://www.freelists.org/webpage/oracle-l Received on Tue Jan 14 2014 - 18:23:41 CET

Original text of this message