PL-SQL - Table pointers?

From: Bryan Dollery <Bryan_at_Bryan.prestel.co.uk>
Date: 1997/04/05
Message-ID: <334666C6.7A30_at_Bryan.prestel.co.uk>#1/1


Hi,

[Quoted] I have a number of tables all related by the same two field composite primary key. My requirement is that I delete a record from each table which matches a given primary key. I have done this thusly:

	DELETE 
	FROM tableA
	WHERE	keyA = A AND
		keyB = B ;

	DELETE 
	FROM tableB
	WHERE	keyA = A AND
		keyB = B ;

	DELETE
	FROM tableC
	WHERE	keyA = A AND
		keyB = B ;

This is of course an abstracted example. There are actually twenty tables and the key is six fields long.

It would be neated if I could write something like this (I know that TABLE has a specific purpose, I am only using it for an example of what I would like to do):

        PROCEDURE DeleteX(table_name TABLE, A keytable.A%TYPE, B keytable.B%TYPE) IS

	BEGIN
		DELETE
		FROM table_name
		WHERE	keyA = A AND
			keyB = B ;
	END DeleteX ;

which I could then call like this:

	DeleteX(tableA, A, B) ;
	DeleteX(tableB, A, B) ;
	DeleteX(tableC, A, B) ;

which is much better as it gives me the ability to place other code within the delete function, rather than write a lot of triggers to achieve the same functionallity, and slow down the system.

Does anyone have any idea how to achieve this passing of table pointers in PL-SQL, or even if it is possible.

All answers greatfully received.

Bryan.

-- 
Bryan Dollery BSc(Hons)
ByteSmart Systems Ltd.
Received on Sat Apr 05 1997 - 00:00:00 CEST

Original text of this message