Reputation: 169
This is quite possibly a very stupid question but I've tried searching for and answer and come up empty.
I'm writing a procedure that takes a single parameter of type CHAR. i.e:
CREATE PROCEDURE Proc1 (Param1 CHAR(5))
AS
BEGIN
...
END;
This doesn't work and throws an error around the CHAR(5) area. If I don't specify a size for the parameter, so just leave it as CHAR it works fine. I've tried including the keyword IN but this makes no difference.
Is there anyway of specifying a size for parameters in PL/SQL procedures?
Upvotes: 4
Views: 11629
Reputation: 608
As a_horse_with_no_name mentioned before, you shoudn't specify parameters length in procedure definition. However, if you want to control variable length, you can try this approach :
procedure A(var CHAR) is
MAX_CHAR number := 10; -- for an instance
begin
if length(var) > MAX_CHAR then
-- here you can throw an exception
end if;
...
end A;
Upvotes: 1
Reputation:
Is there anyway of specifying a size for parameters in PL/SQL procedures?
No, as documented in the manual
Quote from http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/subprograms.htm#sthref1640
For each parameter, you specify:
- Its name.
- Its parameter mode (...)
- Its datatype. You specify only the type, not any length or precision constraints
(Emphasis mine)
Upvotes: 11