The last time we introduced the implementation process of creating a trigger for a DB2 database, this article will introduceDB2 databasePairStored ProcedureNext, let's take a look at this part.
I. Stored Procedure calls are divided into three parts
1. Connection (establish a connection with the database)
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver").newIns
Java execution of stored procedures and functions (web basic learning notes 14), stored procedure learning notesI. Overview
To execute the stored procedure, we should use the CallableStatement interface.
The CallableStatement interface inherits from the PreparedStatement int
In the development process, the need to constantly back up database objects, especially stored procedures, each time the manual backup is very low-energy AHAfter several modifications finally, perfect, O (∩_∩) o haha ~ (of course, you can also change a little bit easier ~ ~ ~)Select Dbms_metadata.get_ddl (' PROCEDURE ', ' procedure_name ', ' NAG ') encounter large store
Tags: com not mit else using database system cursor OTF whenStored ProceduresA set of SQL statements that are used to complete a specific database function that is compiled and stored in the database system. At the time of use, the user invokes and executes a stored procedure name that has already been defined and gives the corresponding
Stored Procedures, functions, triggers, and stored procedure triggersDifferences between stored procedures, functions, and triggers
Compare items
Stored Procedure
Function
Return Value?
Yes or n
Instance 1: only the stored procedure of a single record set is returned. The content of the bank deposit table (bankMoney) is as follows: IduserIDSexMoney001Zhangsan male 30002Wangwu male 50003Zhangsan male 40 requirement 1: createproceduresp_query_bankMoneyasselect * fromba
Instance 1: only the stored procedure of a
I will not talk about the concept of the stored procedure, because the search engine is more detailed and wonderful than me. I will only give an example to do more practical things.
First, create a database sample and then use the following statement to create a table. Of course, you 'd better insert some data in the table. If you don't want it, you can. Call the added
Brief introduction:(1) Definition:Commonly used or very complex work, pre-written with SQL statements and stored with a specified name, then to call the database to provide the same functionality as a defined stored procedure, only call execute to automatically complete the command.A stored
Basic Procedure for calling a stored procedure using JDBC (sxt)
Demo
Import java. SQL .*;
Public class testprocedure
{
/**
* @ JDBC call the basic process of the stored procedure. Procedure P contains four paramete
You can use exec or call to call a written stored procedure in Oracle data, but you can only use call to call the stored procedure in db2. Pay attention to parameter issues and parameter issues.
Exec proc_pay_idv ('20140901 ',?);
The execution reports an error. exec
① Why should stored procedures be used?Because it is faster than SQL statement execution.
② What is a stored procedure?Combine a bunch of SQL statements and execute SQL statements without passing through the conditions. (ax points of view in writing this article)
③ A simple Stored ProcedureCreate procedureDBO. test
that the code of the program becomes smaller and easier to understand. Another advantage of stored procedures is that SQL can be pre-compiled, which increases the speed of the program. Because stored procedures contain program logic, more processing can be performed on the database server. Similarly, when an n-tier program is executed, the stored
① Why should stored procedures be used?
Because it is faster than SQL statement execution.
② What is a stored procedure?Combine a bunch of SQL statements and execute SQL statements without passing through the conditions. (ax points of view in writing this article)
③ A simple Stored ProcedureCreate
Copy codeThe Code is as follows:SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOCreate procedure [dbo]. [Pagination]@ Page int = 1, -- current Page number@ PageSize int = 10, -- number of records per page (page size)@ Table nvarchar (500), -- Table name or view name, or even nested SQL: (Select * From Tab Where ID> 1000) Tab@ Field nvarchar (800) = '*', -- return the Field name of the record set, separated by ",". The default value is "*"@ OrderBy nvarch
Copy Code code as follows:
SET ANSI_NULLS on
Go
SET QUOTED_IDENTIFIER ON
Go
CREATE PROCEDURE [dbo]. [Pagination]
@Page int = 1,--current page number
@PageSize int = 10--Number of record bars per page (page size)
@Table nvarchar (500)--table name or view name, or even nested sql: (Select * from Tab Where id>1000) tab
@Field nvarchar (800) = ' * ',--Returns the recordset field name, "," is separated by the default is "*"
@OrderBy nvarcha
This article mainly introduces the correct use of dynamic cursors in DB2 stored procedures. I believe that if you have mastered the correct use of dynamic cursors in DB2 stored procedures, it will be of great help in future studies or work. The following is a detailed description of the main content of the article.
The following articles mainly describe the DB2 Stored Procedure writing process. This article mainly uses the actual application code to implement the DB2 stored procedure to lead to the correct operation process, the following is
If a stored procedure is modified during project development, how can I quickly find other stored procedures using the stored procedure?
If a stored procedure is modified during projec
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.