| CREATE OR REPLACE FUNCTION cash_out_ticket(party_id IN softdev.casino_users.party_id%TYPE ,session_id IN softdev.bus_session.session_id%TYPE | |
| ) RETURN NUMBER AS ret_val NUMBER; |
| |
| P_EXCHANGE_BET_CREDITS COUNTRY.EXCHANGE_BET_CREDITS%type; |
| P_EXCHANGE_VALUE | COUNTRY.EXCHANGE_VALUE%type; |
| CURSOR cur_tkt_sess (party_id IN casino_users.party_id%TYPE,session_id IN bus_session.session_id%TYPE) |
| |
| IS |
| SELECT bs.session_id |
| ,tii.status |
| ,ROW_NUMBER() OVER (PARTITION BY bs.session_id ORDER BY status ASC) rn |
| ,NVL(TO_CHAR(bs.started, 'DD.MM.YYYY HH24:MI'), 'Live') started |
| ,bs.bet bet |
| ,tii.time_p |
| ,tii.live_prematch |
| ,cash_out(bet) cash_out |
| FROM bus_session bs |
| ,ticket_items tii |
| WHERE bs.session_id | = tii.bus_session_session_id |
| AND bs.session_type | = 'TICKET SESSION' |
| AND bs.party_id | = cur_tkt_sess.party_id |
| AND bs.session_id | = cur_tkt_sess.session_id |
| AND NVL(bs.session_close, 'N') = 'N'; |
| |
| rec_tkt_sess cur_tkt_sess%ROWTYPE; |
| BEGIN |
| |
| CHAGE_CREDITS (party_id, P_EXCHANGE_BET_CREDITS, P_EXCHANGE_VALUE); |
| |
| OPEN cur_tkt_sess(cash_out_ticket.party_id, cash_out_ticket.session_id); |
| |
| FETCH cur_tkt_sess |
| INTO rec_tkt_sess; |
| |
| IF(cur_tkt_sess%FOUND) THEN |
| |
| IF( |
| (TO_DATE(rec_tkt_sess.started,'DD.MM.YYYY HH24:MI:SS') +1 <=SYSDATE) -- is it older more than 24 hours |
| OR |
| (rec_tkt_sess.live_prematch != '0') --is it live (1 live , 0 not live) |
| OR |
| (rec_tkt_sess.time_p <SYSDATE) -- is game begin |
| ) |
| THEN |
| ret_val := 0; |
| |
| ELSE |
| ret_val := rec_tkt_sess.cash_out* P_EXCHANGE_BET_CREDITS / P_EXCHANGE_VALUE; |
| | |
| update ticket_items set status = 'L' where SESSION_ID = cash_out_ticket.session_id; |
| pck_beting.end_of_ticket (cash_out_ticket.session_id , |
| rec_tkt_sess.cash_out* P_EXCHANGE_BET_CREDITS / P_EXCHANGE_VALUE , |
| cash_out_ticket.party_id ); |
| | |
| END IF; |
| ELSE | |
| ret_val := -1; |
| |
| |
| |
| END IF; |
--
Once the conditions are fulfilled , and it returns ret_val := rec_tkt_sess.cash_out* P_EXCHANGE_BET_CREDITS / P_EXCHANGE_VALUE; I want to execute update and procedure. The update doesn't update field status and procedure end_of_ticket when i run it alone works but inside this function it doesn't do what is supose to do( just some updates based on the input parameters).
select cash_out_ticket(4356, 583931) from dual; i get error that i cant perform dml operation inside a query , error on line 54.
Ok i understand that i cant call procedure end_of_ticket inside IF cursor but where ever i put it (at the end where RETURN (ret_val) is it doesnt do updates).
How can i fix this error ?