Changing Database Records with Stored Procedures

Stored procedures can perform various actions similar to what Access Action queries and Select queries with parameters can do. For example, here's how you would write a statement to create a stored procedure that, when executed, deletes a record from the Shippers table:

conn.Execute "CREATE PROCEDURE usp_DeleteRec " &_ "(Id INTEGER) " & _ "AS " & _

"DELETE * FROM Shippers WHERE ShipperId = Id;"

Programming with the Jet Data Definition Language

To update a phone number in a specified record in the Shippers table, you may want to create a stored procedure that performs the specified record update with the following statement:

conn.Execute "CREATE PROCEDURE usp_UpdatePhone " & _ "(Id Integer, tel text (24)) " &_ "AS " & _

"UPDATE Shippers SET Phone = tel " & _ "WHERE ShipperId = Id;"

0 0

Post a comment