0

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

marc_s
9,0626 gold badges46 silver badges52 bronze badges
asked Mar 19, 2014 at 20:00

1 Answer 1

3

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;
answered Mar 19, 2014 at 20:08
2
  • 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 correct Commented Mar 19, 2014 at 20:26
  • 1
    @joe - Assuming that the caller also defines rec as table_name%rowtype, then yes. Commented Mar 19, 2014 at 20:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.