MATLAB DATABASE TOOLBOX RELEASE NOTES Guide de l'utilisateur Page 640

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 684
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 639
7 Functions — Alphabetical List
7-210
close(conn)
Call a Stored Procedure with Input Arguments
Define a stored procedure named insert_data that inserts a category description
into a table named test_create by executing this code. This procedure has one input
argument data. This code assumes you are using a Microsoft SQL Server database.
CREATE PROCEDURE insert_data
@data varchar(50)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
INSERT INTO test_create (CATEGORY_DESC)
VALUES (@data)
END
GO
Create a Microsoft SQL Server database connection conn using the JDBC driver. For
details, see “Connecting to a Database”. Then, call the stored procedure insert_data
using the database connection conn with the category description Apples as the input
argument.
inputarg = {'Apples'};
results = runstoredprocedure(conn,'insert_data',inputarg)
results =
0
results returns 0 because calling insert_data does not return a data set.
The table test_create adds a row where the column CATEGORY_ID equals 1 and the
column CATEGORY_DESCRIPTION equals Apples.
CATEGORY_ID is the primary key of the table test_create. This primary key
increments automatically. CATEGORY_ID equals 1 when calling insert_data for the
first time.
Vue de la page 639
1 2 ... 635 636 637 638 639 640 641 642 643 644 645 ... 683 684

Commentaires sur ces manuels

Pas de commentaire