I have a table with 15 columns, and trying to create a stored procedure in PL SQL that will only insert a row in a table using the INSERT
statement.
I would like to know if it is possible to declare the list of IN parameters of the stored procedure as a RECORD
structure instead of 15 parameter, so when calling this stored procedure, I will only pass a RECORD
structure instead of 15 single variables.
Is that possible in PL SQL? If no, is there any shorthand for doing this kind of declarations? Thanks
1 Answer 1
Sure. You can even use the predefined %rowtype
record.
CREATE OR REPLACE PROCEDURE insert_row( p_rec IN table_name%rowtype )
AS
BEGIN
INSERT INTO table_name
VALUES p_rec;
END;
-
thanks That's great, calling it i suppose would e as simple as referencing the rec.field := value ? and passing the rec to the stored proc? is that correctjoe– joe2014年03月19日 20:26:18 +00:00Commented Mar 19, 2014 at 20:26
-
1@joe - Assuming that the caller also defines
rec
astable_name%rowtype
, then yes.Justin Cave– Justin Cave2014年03月19日 20:27:13 +00:00Commented Mar 19, 2014 at 20:27
Explore related questions
See similar questions with these tags.