VFP because of its popularity, ease of use, by the vast number of developers welcome, but its security and stability is not very perfect. The advantages of Oracle in this respect are legendary, the combination of both, can develop efficient, safe and stable application system. There is less information on how to invoke Oracle stored procedures in VFP, and here's a simple example of this, hoping to play a role. This method is suitable for the development of C/s method using VFP as front-end development tool and Oracle as back-end database.
On the Oracle side, the following tables and stored procedures are built:
Table Gzb 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;
At the front end (VFP end), assume that you have established a link with Oracle ′vfplink′ (the specific steps can refer to VFP's help documentation):
To open a link:
Nhand=sqlconnect (′vfplink′)
&&nhand for the returned link handle
Call Oracle's stored procedure P-UPDATE-GZB:
This stored procedure has two parameters, respectively, ID and GZ, we set to update the employee ID 2 of GZ to 5000, you can perform:
SqlExec (Nhand, ″{call p-update-gzb (2,5000)}″)
If the execution succeeds, it returns 1, and the failure returns-1. We can execute the following command to verify that the stored procedure was executed successfully:
SqlExec (Nhand,′select * from gzb′)
Brow
The result:
Id |
GZ |
1 |
3050 |
3 |
2500 |
2 |
5000 |
Visible, Oracle's stored procedure P-UPDATE-GZB has been successfully executed, and finally, don't forget to disconnect:
Disconnect (Nhand)
The above example runs through the VFP6.0, Oracle 7.3.3 environment.