Reputation: 77
HELLO I'm student and I'm new with oracle I trying somethings but have a problem with this procedure and I didnt find the where is it.I hope you can help me Thank you in advance..
error msg : [Error] Execution (23: 7): ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'URUNNOGEN' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
create or replace procedure ariciaykut.URUNNOGEN
(KATA in NVARCHAR2,MARK in NVARCHAR2,URNO out NVARCHAR2)as
K NVARCHAR2(3);
M NVARCHAR2(3);
U NUMBER;
BEGIN
K:=KATA;
M:=MARK;
U:=0;
FOR U IN 1..999 LOOP
IF U BETWEEN '-1'AND'10' THEN
URNO:=K||'00'||U||M;
ELSIF U BETWEEN '9'AND'99' THEN
URNO:=K||'0'||U||M;
ELSE
URNO:=K||U||M;
INSERT INTO ARICIAYKUT.PROGOSTER VALUES(URNO);
END IF;
END LOOP;
END;
calling line:
EXEC ARICIAYKUT.URUNNOGEN('ICK','COC');
Upvotes: 0
Views: 445
Reputation: 50017
You're comparing numeric values in U
to strings ('-1', '10'
, etc). This is very likely to end up doing something that you don't want. You're also counting on the default conversion of number to character to behave as you expect; you may be surprised.
Further, you've used the same name (U
) for a variable and a loop control value, which will probably cause some confusion. (Inside the loop U
will refer to the loop control value; outside the loop U
will refer to the variable). I suggest you re-code your procedure to compare numbers to numbers, and to use the TO_CHAR
function to convert numbers to character strings, similar to the following:
create or replace procedure ariciaykut.URUNNOGEN
(KATA in NVARCHAR2,MARK in NVARCHAR2,URNO out NVARCHAR2)
as
K NVARCHAR2(3);
M NVARCHAR2(3);
BEGIN
K:=KATA;
M:=MARK;
FOR U IN 1..999 LOOP
URNO := K || TO_CHAR(U, '009') || M;
IF U >= 100 THEN
INSERT INTO ARICIAYKUT.PROGOSTER VALUES(URNO);
END IF;
END LOOP;
END URUNNOGEN;
Upvotes: 0
Reputation: 5072
Remove the out variable and declare as local variable
create or replace procedure ariciaykut.URUNNOGEN
(KATA in NVARCHAR2,MARK in NVARCHAR2)as
K NVARCHAR2(3);
M NVARCHAR2(3);
U NUMBER;
Urno nvarchar2(100);
BEGIN
K:=KATA;
M:=MARK;
U:=0;
FOR U IN 1..999 LOOP
IF U BETWEEN -1 AND 9 THEN
URNO:=K||'00'||U||M;
ELSIF U BETWEEN 9 AND 99 THEN
URNO:=K||'0'||U||M;
ELSE
URNO:=K||U||M;
END IF;
INSERT INTO ARICIAYKUT.PROGOSTER VALUES(URNO);
END LOOP;
END;
Upvotes: 0
Reputation: 77
I solved problem like this and thank you everyone who wanted to help me..
create or replace procedure ariciaykut.URUNNOGEN2 (KATA in NVARCHAR2,MARK in NVARCHAR2)as
K NVARCHAR2(3);
M NVARCHAR2(3);
U NUMBER;
BEGIN
K:=KATA;
M:=MARK;
FOR U IN 1..999 LOOP
IF U BETWEEN '-1'AND'9' THEN
INSERT INTO ARICIAYKUT.PROGOSTER VALUES(K||'00'||U||M);
ELSIF U BETWEEN '9'AND'99' THEN
INSERT INTO ARICIAYKUT.PROGOSTER VALUES(K||'0'||U||M);
ELSE
INSERT INTO ARICIAYKUT.PROGOSTER VALUES(K||U||M);
END IF;
END LOOP;
END;
Upvotes: 0
Reputation: 43523
You're missing one of your arguments to the procedure. You define 3, but only specify 2 on the EXEC statement.
Upvotes: 1