TOraObjects and member function/procedure
TOraObjects and member function/procedure
Hello,
my question is in the subject : how can we call a member function or procedure of an Oracle object ?
We can modify attributes etc., but I don't see anything about members (not static members)...
Thanks for all,
my question is in the subject : how can we call a member function or procedure of an Oracle object ?
We can modify attributes etc., but I don't see anything about members (not static members)...
Thanks for all,
Hello,
For work with object methods, you can use ToraStoredProc, for example
For work with object methods, you can use ToraStoredProc, for example
Code: Select all
CREATE OR REPLACE TYPE MY_TYPE AS OBJECT
(MY_FIELD NUMBER
, MEMBER FUNCTION MY_METHOD RETURN NUMBER
)
OraStoredProc.StoredProcName := 'MY_TYPE.MY_METHOD';
When calling object method, the first parameter always must be a pointer to the object.
OraStoredProc.ParaByName('SELF') := <- reference to the created object
OraStoredProc.Execute;Problem is...
I cannot execute two member procedures... I've got an access violation
on OraClient10.dll in InitProcParams8 , line 9975 of oraClasses unit
Check(OCIAttrGet1(hParam, OCI_DTYPE_PARAM, ValuePtr, nil,
OCI_ATTR_LIST_ARGUMENTS, hOCIError));
My Code :
Error is at the second PrepareSQL...
Member procedure Init modifys Object...
Thanks for all,
on OraClient10.dll in InitProcParams8 , line 9975 of oraClasses unit
Check(OCIAttrGet1(hParam, OCI_DTYPE_PARAM, ValuePtr, nil,
OCI_ATTR_LIST_ARGUMENTS, hOCIError));
My Code :
Code: Select all
OraType:=TOraType.Create(OraSession.OCISvcCtx,'"Mail"');
OraObject:=TOraObject.Create(OraType);
OraProc:=TOraStoredProc.Create(OraSession);
OraProc.Session:=OraSession;
OraProc.StoredProcName:='"Mail"."Init"';
OraProc.PrepareSQL;
OraProc.ParamByName('SELF').AsObject:=OraObject;
OraProc.ExecProc;
OraProc.StoredProcName:='"Mail"."AddSender"';
OraProc.PrepareSQL;
OraProc.ParamByName('SELF').AsObject:=OraObject;
OraProc.ParamByName('SRECIPIENT').AsString:='[email protected]';
OraProc.ExecProc;
Member procedure Init modifys Object...
Thanks for all,
Hello,AlexP wrote:Hello,
Thank you for the information.
We have added the advised fix in OraClasses.
A script for creating your "Mail" object would be appriciated for reproducing the problem
script is here :
http://dral.free.fr/Mail.7z
password is devart.com
just replace values in "Init" member function of "Mail" object to send mails.
You probably needs some rights :
grant execute on sys.utl_tcp
grant execute on sys.utl_smtp
GRANT EXECUTE ON SYS.DBMS_LOB
Thanks for all,
Hello,
I created the objects you have presented, and the following code was executed with no errors.
If any errors occur when executing this code, try calling these methods in the following anonymous block
for example, in the standart SQL Plus
If the same errors occur, you probably have problems with the Oracle server.
I created the objects you have presented, and the following code was executed with no errors.
Code: Select all
var
OraStoredProc: TOraStoredProc;
OraObject: TOraObject;
begin
OraObject:= TOraObject.Create(TOraType.Create(OraSession1.OCISvcCtx,'"Mail"'));
OraObject.AllocObject;
OraObject.IsNull := False;
OraStoredProc:= TOraStoredProc.Create(nil);
OraStoredProc.Session := OraSession1;
OraStoredProc.StoredProcName:='"Mail"."Init"';
OraStoredProc.PrepareSQL;
OraStoredProc.ParamByName('SELF').AsObject:=OraObject;
OraStoredProc.ExecProc;
OraStoredProc.StoredProcName:='"Mail"."AddSender"';
OraStoredProc.PrepareSQL;
OraStoredProc.ParamByName('SELF').AsObject:=OraObject;
OraStoredProc.ParamByName('SSENDER').AsString:='[email protected]';
OraStoredProc.ExecProc;Code: Select all
DECLARE
MAIL "Mail";
BEGIN
MAIL := "Mail"();
MAIL."AddSender"('[email protected]');
END;If the same errors occur, you probably have problems with the Oracle server.