Home » Developer & Programmer » Forms » ora_ffi working example req
ora_ffi working example req [message #120148] Wed, 18 May 2005 00:33 Go to next message
toufiq_raja
Messages: 39
Registered: May 2005
Location: Islamabad
Member

can any boddy send me the working of ora_ffi with example
Re: ora_ffi working example req [message #120155 is a reply to message #120148] Wed, 18 May 2005 01:20 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Sorry ... I should have said ole2 not ora_ffi.

Quote:


6.1.1.11.3 Example 3: modifying cells in an Excel spreadsheet
This example gets and sets cell values in an Excel spreadsheet.
PACKAGE spreadsheet IS
procedure setcell(trow number, col number, val number);
function getcell(trow number, col number) return number;
END;
PACKAGE BODY spreadsheet IS
obj_hnd ole2.obj_type;/* store the object handle */
FUNCTION get_object_handle return ole2.obj_type IS
BEGIN
/* If the server is not active, activate the server
and get the object handle.
*/
if not forms_ole.server_active ('spreadsheet') then
forms_ole.activate_server('spreadsheet');
obj_hnd := forms_ole.get_interface_pointer('spreadsheet');
end if;
return obj_hnd;
END;
/*
Excel cells are accessed with the following syntax in Visual Basic:
ActiveSheet.Cells(row, column).Value
In PL/SQL, we need to first get the active sheet using the
forms_ole.get_interface_pointer built-in. We can then use that to call the
Cells method with the row and column in an argument list to get a handle to
that specific cell. Lastly, we access the value of that cell.
*/
PROCEDURE SETCELL (trow number, col number, val number) IS
d ole2.obj_type;
c ole2.obj_type;
n number;
lst ole2.list_type;
BEGIN
/* Activate the server and get the object handle
to the spreadsheet.
*/
d := get_object_handle;
/* Create an argument list and insert the specified
row and column into the argument list.
*/
lst := ole2.create_arglist;
ole2.add_arg(lst,trow);
ole2.add_arg(lst,col);
/* Call the Cells method to get a handle to the
specified cell.
*/
c := ole2.invoke_obj(d,'Cells',lst);
/* Set the value of that cell. */
ole2.set_property(c,'Value',val);
/* Destroy the argument list and the cell object
handle.
*/
ole2.destroy_arglist(lst);
ole2.release_obj(c);
END;


Try that. (Comes from "Guidelines for Building Applications".)

David
Re: ora_ffi working example req [message #120160 is a reply to message #120148] Wed, 18 May 2005 02:15 Go to previous messageGo to next message
doraistud
Messages: 14
Registered: April 2005
Junior Member
Hi i tried with an example as given in oracle forms help document and its working fine. its finding power of numbers thats to find the result of 2 power 2 say..

create a package in forms

PACKAGE mathlib IS
FUNCTION pow(x NUMBER, y NUMBER)
RETURN NUMBER;
END;

PACKAGE BODY mathlib IS
mathlib_lhandle Ora_Ffi.Libhandletype;
to_power_fhandle Ora_Ffi.Funchandletype;
FUNCTION ff_to_power(fhandle Ora_Ffi.Funchandletype,
x NUMBER, y NUMBER)RETURN NUMBER;
PRAGMA interface(C, ff_to_power, 11265);
FUNCTION pow(x NUMBER, y NUMBER) RETURN NUMBER IS
BEGIN
RETURN(ff_to_power(to_power_fhandle, x, y));
END pow;
BEGIN
mathlib_lhandle := Ora_Ffi.Load_Library
('C:\WINDOWS\SYSTEM32\', 'msvcrt.dll');
to_power_fhandle := Ora_Ffi.Register_Function
(mathlib_lhandle, 'pow', Ora_Ffi.C_Std);
Ora_Ffi.Register_Parameter (to_power_fhandle,
Ora_Ffi.C_DOUBLE);
Ora_Ffi.Register_Parameter(to_power_fhandle,
Ora_Ffi.C_DOUBLE);
Ora_Ffi.Register_Return (to_power_fhandle, Ora_Ffi.C_DOUBLE);
END;


then type this in a button(when-button-pressed trigger)
BEGIN
message(mathlib.pow(2,2));
message(mathlib.pow(2,2));
END;

try out hope this helps you out...
icon5.gif  error in code [message #120311 is a reply to message #120155] Wed, 18 May 2005 23:42 Go to previous message
toufiq_raja
Messages: 39
Registered: May 2005
Location: Islamabad
Member

hi,
i used the code but 2 errors occured in the code..
1. when button pressed.
populate_data.load_emp_records;
error := identifier populate_data must be declared.
2. error in the procedure worksheet_purchaseRqst2
Procedure Worksheet_PurchaseRqst2 IS
C number := 1;
r number := 3;
BEGIN
OPEN_WORKSHEET('PurchaseRqst2');
FOR I IN 1..POPULATE_DATA.EMP_RECORDS.LAST LOOP
c := 1;
WRITE_TO_WORKSHEET(r,c,populate_data.emp_records(i).empno);
c := 3;
WRITE_TO_WORKSHEET(r,c,populate_data.emp_records(i).ename);
c := 4;
WRITE_TO_WORKSHEET(r,c,populate_data.emp_records(i).hiredate);
c := 7;
WRITE_TO_WORKSHEET(r,c,populate_data.emp_records(i).dname);
c := 1;
r := r + 1;
END LOOP;
END;
identifer populate_data must be declare!

can u send me the correction

Regards!
Previous Topic: To Trap TNS Error
Next Topic: problem in connectign sqlserver with develoepr6i forms
Goto Forum:
  


Current Time: Thu Sep 19 18:48:10 CDT 2024