If you have really understood some of the methods we discussed above (Edit, update, and AddNew), perhaps some readers already know how to delete records in an Oracle database.
<%
' Delete all records that match the above criteria Oradynaset.delete
%>
Code to search for and update data records in Oracle8i
1) Search
<%
' retriverecproc.asp-Update data logging using ASP's Oracle Objects for OLE
%>
<% ' defines a variable as an OLE object
Dim orasession
Dim Oradatabase
Dim Oradynaset
' Create a Orasession object
Set orasession = CreateObject ("Oracleinprocserver.xorasession")
' Create a Oradatabase object by opening a connection to an Oracle database
' Be sure to use your username and password to access the Oracle database
Set oradatabase = Orasession.opendatabase ("", "User/password", _
Cint (0))
' Create Oradynaset object Execute SQL statement
Set Oradynaset = Oradatabase.dbcreatedynaset (_
"SELECT * from Mytable1", CInt (0))
%>
<body>
Using oo4o
<table border=1 id= "Table1" >
<%
Do while (oradynaset.eof = FALSE)
Response.Write ("<tr><td>")
Response.Write (Oradynaset.fields ("ID"))
Response.Write ("</td><td>")
Response.Write (Oradynaset.fields ("UserName"))
Response.Write ("</td><td>")
Response.Write (Oradynaset.fields ("Phone"))
Response.Write ("</td><td>")
Response.Write (Oradynaset.fields ("Email"))
Response.Write ("</td></tr>")
Oradynaset.movenext
Loop
' Delete orasession Set orasession = Nothing
%>
</table>
Dim orasession
Dim Oradatabase
Dim Oradynaset
' Get the field value from the submitted table
FID = Request.Form ("ID")
Fusername = Request.Form ("UserName")
Fphone = Request.Form ("Phone")
FEMAIL = Request.Form ("Email")
' Create a Orasession object
Set orasession = CreateObject ("Oracleinprocserver.xorasession")
' Create a Oradatabase object by opening a connection to an Oracle database
Set oradatabase = Orasession.opendatabase ("", "User/password", _ Cint (0))
' Create the Oradynaset object for the record of the id= FID
Set Oradynaset = Oradatabase.createdynaset (_ "SELECT * from MYTABLE1 where id=" & FID, CInt (0))
' Update fields for Id=fid records using the Edit method
Do while (oradynaset.eof = FALSE)
Oradynaset.edit
Oradynaset.fields ("UserName"). Value = Fusername
Oradynaset.fields ("Phone"). Value = Fphone
Oradynaset.fields ("Email"). Value = FEMAIL
Oradynaset.update
Oradynaset.movenext Loop
%>
<body>
The record (id=<%=fid%>) has been updated successfully!<br>
can view the result <a href= "retrieveallrec.asp" > Here</a>
<a href= "Javascript:window.history.go ( -1)" > Back previous page</a>
&bnsp;&bnsp;
<a href= "Javascript:window.history.go ( -2)" > Back home page</a>
<%
' Delete Orasession object
Set orasession = Nothing
%>
</body>
So far, we've discussed how to use Oracle Objects for OLE in ASP code to handle data in an Oracle database.
Using Stored Procedures
We have discussed how to access an Oracle database in ASP, and all SQL statements can be embedded in an ASP Web page. If you use stored procedures in your ASP, you will be more able to process your data more efficiently. I recommend that readers use pl/sql stored procedures in addition to embedding SQL statements in ASP. Creating a stored procedure in an Oracle database is beyond the scope of this article and is no longer covered here.
ASP and Oracle databases are two of the more popular technologies, there are quite a wide range of user groups, if they can organically combine the two, will be able to bring a lot of convenience to work, I hope this article can play a role, so that readers can better explore the combination of these two technologies to use the way.