Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to test stored procedure in SQL Developer or SQL Plus

912201Jan 26 2012 — edited Jan 26 2012
Hello,

This is baby steps but I'm baffled. Can someone provide me with the EXACT command to run to test my stored procedure presented below. Please don't refer me to the documentation or offer some kind of pseudo code. I've been through the documentation - and through it again - and I am just not getting it. I know that the procedure works in general because I'm calling it from ColdFusion but I want to test it from SQL Developer or SQL Plus before I call it from my ColdFusion page - this only makes sense. I am probably not initializing the variables right or something - not sure.

You'll see that it is a straight ahead insert into the database of a firstname and lastname and there are 2 IN OUT values as well. Please use some bogus name for the firstname and lastname values to demonstrate. I appreciate it!

create or replace
procedure sp_insertDirector_A (
vFirstname IN Directors.Firstname%TYPE,
vLastname IN Directors.Lastname%TYPE,
vInsertStatus IN OUT NUMBER,
vNewDirectorID IN OUT NUMBER
)
IS
row_count NUMBER;
BEGIN
SELECT Count(*) INTO row_count FROM Directors WHERE Lastname = vLastname;
IF row_count > 0 THEN
vInsertStatus := -1;
RETURN;
END IF;

INSERT INTO Directors (
Firstname, Lastname)
VALUES (
vFirstname, vLastname
);

SELECT Directors_Seq.CURRVAL INTO vNewDirectorID FROM DUAL;
vInsertStatus := 1;
END;

If someone can tell me exactly how to test I would appreciate it. I asked this on another site and got back lots of answers that I tried and did not work due to different errors. Once I get one working example, I'm sure I can get the idea and continue on. I am using SQL Developer mainly.

Thanks, mallethead

p.s. I think my IF - THEN followed by the INSERT statement is correc - it is woring. Looks a bit strange to me though.
This post has been answered by SomeoneElse on Jan 26 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 23 2012
Added on Jan 26 2012
11 comments
20,595 views