Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overloading stored procedures possible??? 1

Status
Not open for further replies.

Netherbeast

Programmer
Jun 4, 2002
89
US
Is it possible to overload a stored procedure? What I want to do is make a procedure that will either add a person or delete a record depending on what parameter is passed.

CREATE OR REPLACE PROCEDURE ADDING(P_FIRST IN CHAR, P_LAST IN CHAR)
BLA BLA BLA
END;
/

CREATE OR REPLACE PROCEDURE ADDING(P_PURGE)
BLA BLA
END;
/

basically, I want to purge a record if the word "purge" is passed instead of values.

thanks in advance
 
Thanks Dima...

Another question.

Im getting this error and I dont know why.

CREATE OR REPLACE PROCEDURE(P_THECOMMAND CHAR) AS
THE_COMMAND CHAR;

BEGIN
THE_COMMAND:=P_THECOMMAND;

IF THE_COMMAND = "REPORT" THEN
/*SHOWS THE REPORT*/

ELSIF THE_COMMAND = "PURGE" THEN
DELETE * FROM CODETABLE;

ELSE
/*ERROR CATCH*/
END IF;
END;
/

Im getting an error that says:
invalid table name

it is refering to the table CODETABLE. I have checked the name spelling and the existance of the table, so I dont know what is wrong.

Thanks in advance.
 
Im so dumb...I figured it out. The command is
DELETE CODETABLE

and NOT
DELETE * FROM CODETABLE

sorry for the dumb post.
 
Further problem will raise when you call it. By default CHAR has length 1, so you can not assign 'REPORT' to it. Single quotes are used for string literals, not double. And after all CHAR is fixed-length, so you may have some problems with comparisons. I'd suggest you to replace CHAR with VARCHAR2.

Regards, Dima
 
Thanks Dima, you were exactly right.

I changed it to (P_THECOMMAND VARCHAR2)

also when I declared:
THE_COMMAND CHAR;

it had to be changed to:
THE_COMMAND VARCHAR2(6);

Thanks for the Help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top