user3235613
user3235613

Reputation: 1

PLS-00306 while trying to run an oracle stored procedure

I'm kind of new to this so forgive me if i made a mess here. I created the following procedure -

create or replace procedure perform_trade
(p_trade_id number,
p_trade_amount number,
p_balances_id number,
v_out_random_coinid out number,
v_out_random_userid out number,
v_out_random_tradetype out varchar2,
v_out_current_balance out number
)
IS
BEGIN
SELECT ID into v_out_random_coinid from
(SELECT ID
FROM SQL_COINS_VIEW
ORDER BY dbms_random.value)
WHERE rownum = 1;
SELECT ID into v_out_random_userid from
(SELECT ID
FROM USERS
ORDER BY dbms_random.value)
WHERE rownum = 1;
SELECT TYPE into v_out_random_tradetype from
(SELECT TYPE
FROM TRADETYPES
ORDER BY dbms_random.value)
WHERE rownum = 1;
SELECT AMOUNT into v_out_current_balance from
BALANCES
WHERE USERID=v_out_random_userid
and COINID=v_out_random_coinid;
Insert into COINTRADER.trades (ID,USERID,COINID,AMOUNT,ACTIONTYPE,RATE)
Values (p_trade_id, v_out_random_userid, v_out_random_coinid, p_trade_amount, v_out_random_tradetype, (select value from SQL_COINS_VIEW where id=v_out_random_coinid ));
Commit;
Insert into COINTRADER.balances
Values (p_balances_id, v_out_random_userid, v_out_random_coinid, v_out_current_balance+(select total from trades where id=p_trade_id  ));
Commit;
End;

And tried to run it this way through PL/SQL developer-

DECLARE
v_num NUMBER:=1;
BEGIN
LOOP
DBMS_OUTPUT.PUT_LINE(v_num);
v_num := v_num + 1;
perform_trade
(TRADES_ID_SEQ.NEXTVAL,
DBMS_RANDOM.VALUE(1, 10),
BALANCES_ID_SEQ.NEXTVAL);
DBMS_LOCK.SLEEP(1);
EXIT WHEN v_num > 5;
END LOOP;
END;

But i get this error -

Error starting at line 45 in command:
DECLARE
v_num NUMBER:=1;
BEGIN
LOOP
DBMS_OUTPUT.PUT_LINE(v_num);
v_num := v_num + 1;
perform_trade
(TRADES_ID_SEQ.NEXTVAL,
DBMS_RANDOM.VALUE(1, 10),
BALANCES_ID_SEQ.NEXTVAL);
DBMS_LOCK.SLEEP(1);
EXIT WHEN v_num > 5;
END LOOP;
END;
Error report:
ORA-06550: line 7, column 1:
PLS-00306: wrong number or types of arguments in call to 'PERFORM_TRADE'
ORA-06550: line 7, column 1:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

Can someone tell me what's wrong?

Thanks in advance.

Upvotes: 0

Views: 790

Answers (1)

kevinskio
kevinskio

Reputation: 4551

Your out variables are not present in the statement that calls the procedure. Should be something like

perform_trade
(TRADES_ID_SEQ.NEXTVAL,
DBMS_RANDOM.VALUE(1, 10),
BALANCES_ID_SEQ.NEXTVAL,
v_out_random_coinid ,
v_out_random_userid ,
v_out_random_tradetype,
v_out_current_balance);

Upvotes: 1

Related Questions