Source: Network/Editor: getting started with programming: Unknown
Because of its popularity and ease of use, VFP is well received by developers, but its security and stability are not perfect. In this regard, Oracle
The advantage is that they are well-known and can be combined to develop efficient, secure, and stable application systems. The following is a simple example of calling the Oracle Stored Procedure Method in VFP.
Hope to play a role in attracting others. This method is applicable to the c/s development method that uses VFP as the front-end development tool and Oracle as the back-end database.
On the Oracle side, the following tables and stored procedures are built:
The gzb table is as follows:
SQL〉select * from gzb; ID
GZ
1
3050
3
2500
2
4000.8
The stored procedure is as follows:
create or replace procedure p_update—gzb (p—id in number, p—gz in number) as
begin
update gzb set gz=p—gz where id=p—id;
commit;
end;
On the frontend (VFP end), assume that the connection with Oracle is established 'vfplink '(for detailed steps, refer to the help documentation of VFP ):
Open link:
Nhand = sqlconnect ('vfplink ′)
& Nhand is the returned link handle
Call the Oracle Stored Procedure p-Update-gzb:
This stored procedure has two parameters: ID and GZ. If we set the GZ value of the employee whose ID is 2 to 5000, we can execute:
Sqlexec (nhand, "{call p-Update-gzb (2,5000 )}″)
If the execution is successful, 1 is returned, and-1 is returned if the execution fails. Run the following command to verify whether the stored procedure has been successfully executed:
Sqlexec (nhand, 'select * From gzb ′)
Brow
The result is:
ID |
GZ |
1 |
3050 |
3 |
2500 |
2 |
5000 |
It can be seen that the Oracle Stored Procedure p-Update-gzb has been successfully executed. Finally, do not forget to disconnect:
Disconnect (nhand)
The preceding example is run in VFP6.0 and Oracle 7.3.3 environments.