Http://www.cnblogs.com/kkcheng/archive/2010/03/19/1689672.html
Stored procedures, like a programming language, also contain data types, process control, input and output, and its own library of functions.
--------------------Basic Syntax--------------------
I. Creating a stored procedureCREATE PROCEDURE Sp_name ()Begin.........End
two. Call the
1. External Storage Process-think this is better and can save the encapsulated RPG or CL
Program . The efficiency is also significant,
After all, it is direct Io.
It is relatively simple to bind Cl. sqlrpg hasn't done it yet. Some people know it, because I have already set DS according to the parameter, and the result still cannot work.
Create
Procedure
Emplib. sp_eqchkln (
In
Ckdate
Char
(
8
),
In
Ckdept
Char
(
2
),
Result:Mysql> Set @p_in =1Mysql> call Sp_demo_in_parameter (@p_in)SlightlyMysql> Select @p_in;SlightlyAs you can see, p_in is modified in the stored procedure, but does not affect the value of @p_id Examples of Out parametersCreate:Mysql> CREATE PROCEDURE sp_demo_out_parameter (out P_out INT)BEGINSELECT p_out;/* View
CREATE PROCEDURE SALES. Db2pagination (in Itbname VARCHAR),--table nameIn Ishowfield VARCHAR (1000),--display fieldIn Ijoin VARCHAR (1000),--join conditions (for example: inline, outreach)In Iwhere VARCHAR,--query Criteria (Note: Do not add WHERE)In Iorder VARCHAR,--sort criteria (note: Do not add order by)In ipagesize INTEGER,--page size if 0 defaults to return the first 1 million data can be considered to return all dataINOUT Iocurrentpageix INTEGER
for SundayDayOfYear (date)//day of the yearEXTRACT (interval_name from date)//Extract the specified part of the dateMakedate (year, day)//gives the first days of the years and years, generating a date stringMaketime (hour, minute, second)//Generate time stringMONTHNAME (date)//English month nameNow ()//Current timeSec_to_time (seconds)//seconds turn into timeStr_to_date (string, format)//string turns into time, displayed in formatTimediff (datetime1, datetime2)//Two time differenceTime_to_sec (
1. a case where the stored procedure does not return a value ( that is, a statement in a stored procedure statement that does not have a return )Using the method int count = ExecuteNonQuery (..) There are only two cases of executing a stored
Result:Mysql> Set @p_in =1Mysql> call Sp_demo_in_parameter (@p_in)SlightlyMysql> Select @p_in;SlightlyAs you can see, p_in is modified in the stored procedure, but does not affect the value of @p_id Examples of Out parametersCreate:Mysql> CREATE PROCEDURE sp_demo_out_parameter (out P_out INT)BEGINSELECT p_out;/* View
for SundayDayOfYear (date)//day of the yearEXTRACT (interval_name from date)//Extract the specified part of the dateMakedate (year, day)//gives the first days of the years and years, generating a date stringMaketime (hour, minute, second)//Generate time stringMONTHNAME (date)//English month nameNow ()//Current timeSec_to_time (seconds)//seconds turn into timeStr_to_date (string, format)//string turns into time, displayed in formatTimediff (datetime1, datetime2)//Two time differenceTime_to_sec (
Example of recursive calling of stored procedures in SQL Server: SQL Server Stored Procedure
Recursion refers to the situation where a code snippet calls itself. The danger lies in how to prevent it from repeatedly calling itself if it calls itself once. That is to say, rec
, the task never expires.Ojobschedule. Schedule. activeenddate = 99991231 no end dateOjobschedule. Schedule. activeendtimeofday = 235959 No End Time
Add a task to scheduleOjob. beginalterOjob. jobschedules. Add (ojobschedule)Ojob. doalter
The above commands are successfully tested in vfp7, and the newly added commands and running settings are also displayed in SQL Server, but because I use Windows ME, you cannot test whether the task is actually run
Define a stored procedure as follows:CREATE proc [dbo]. [Test1] @id Intasselect 1 as ID, ' ABC ' as name union ALL select @id as ID, ' zzz ' as nameReturns two rows of data.Now you want to call the stored procedure with the SQL statement and put the table he returned into th
1. Define a SQL class HelloDROP JAVA SOURCE newxzxt. " Hello "; CREATE OR REPLACE and RESOLVE JAVA SOURCE NAMED newxzxt. " Hello "as import java.lang.*; public class Hello {public static string say (String args) { System.out.println (args); return args; } } /2. The SQL class above the stored
Before you start
About this series
This six-part series on DB2 SQL Procedure Developer describes all the basic constructs and methods of SQL procedural Language, and explains how to use it in stored procedures, user-defined functions, and triggers, including error handling
PHP access to Oracle stored procedure examples
For example, my local Oracle database has a package with a stored procedure:
Create or Replace package Pkg_trans_rel are --author:test--Created:--purpose:test --Public type Declarat Ions Pkg_name varchar2 (): = ' Pkg_trans_re
Stored procedures, like a programming language, also contain data types, process control, input and output, and its own library of functions.
--------------------Basic Syntax--------------------
I. Creating a stored procedureCREATE PROCEDURE Sp_name ()Begin.........End
two. Call the stored procedure1. Basic syntax: Cal
There are not many articles on the NHibername stored procedure, and there are basically just a few examples on the Internet, especially for the stored procedure that returns the record set. According to my research summary, this article is intended for MySql databases, and s
) → open the database to be operated using the open () method → create a sqlcommand or sqldataadapter object → executenonquery () for SQL commands or stored procedures () method or executereader () method to perform data operations → read or input data to the database → close the connection using the close () method.
We can see that before using stored procedures
If we have learned ADO. Net or actually used an application that interacts with the databaseProgramIt is very easy to understand the knowledge point we teach today-stored procedures in SQL. stored procedures are the most common way to process database data during actual project development, this is the most basic database operation and must be mastered. Since it
stored in the system table. The T-SQL statement of batch processing needs to be pre-compiled and optimized every time, so the speed will be slower.2.3 stored procedures reduce network trafficFor the same database object operation, if the T-SQL statements involved in this operation are organized into a
A stored procedure is a compiled, optimized set of SQL statements placed on the database server, which can be called directly by the application. There are several advantages to using stored procedures:1. Faster execution speed than normal SQL statements2, easy to centralize
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.