Problem with open cursors.
Hi all,I have translated this procedure from T-SQL to PL/SQL.As you see it is a mixed operation
procedure,I mean if some condition is true it does a DML and if other condition is true it does a Query.
Code:
CREATE OR REPLACE PROCEDURE FaxSettings(
p_USERCODE number,
p_HSENDER VARCHAR2,
p_HTITLE VARCHAR2,
p_DIALTONE number,
p_PREFFIX VARCHAR2,
p_WAIT number,
p_DIALRETRY number,
p_READWRITE number,
p_MODEM VARCHAR2,
p_FAXSERVER NUMBER,
p_result_cur OUT sys_refcursor)
AS
v_counter NUMBER := 0;
BEGIN
IF p_READWRITE = 1 then
SELECT COUNT(*)
INTO v_counter
FROM UserAProFaxSettings
WHERE Code = p_USERCODE;
IF v_counter = 0 then
INSERT INTO UserAProFaxSettings (Code,Sender,Title,DialTone
,Preffix,DialWait,DialRetry,Modem,FaxServer)
VALUES (p_USERCODE,
p_HSENDER,
p_HTITLE,
p_DIALTONE,
p_PREFFIX,
p_WAIT,
p_DIALRETRY,
p_MODEM,
p_FAXSERVER);
ELSE
UPDATE UserAProFaxSettings
SET Sender = p_HSENDER,
Title = p_HTITLE,
DialTone = p_DIALTONE,
Preffix = p_PREFFIX,
DialWait = p_WAIT,
DialRetry = p_DIALRETRY,
Modem = p_MODEM,
FaxServer = p_FAXSERVER
WHERE Code = p_USERCODE;
END IF;
END IF;
IF p_READWRITE = 2 THEN
OPEN p_result_cur for
SELECT *
FROM UserAProFaxSettings
WHERE Code = p_USERCODE;
END IF;
END FaxSettings;
/
The problem is: I don't know it will be a DML without cursor or a Query with a returned cursor to
application.So I do not know if I should close that cursor in application or no?
Any help will be so appreciated.