How to Use Procedure
2016-12-02 12:55
274 查看
SQL give you the capability to define your own procedure,
Here is an example.
create procedure Tonytest
--after create this Procedure, you can use alter instead
of create to
modify it--
as
Begin
Select student_number as pre_stdn from students
update students set student_number=student_number+1 where student_number is
not null
--add 1 on all student numbers--
select student_number as alt_stdn from students
End
After this define, use this to run procedure:
Execute Tonytest;
You can see it has been changed.
If you want to go check all Procedure you made, please use:
select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_DEFINITION
from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE='PROCEDURE'
Here is an example.
create procedure Tonytest
--after create this Procedure, you can use alter instead
of create to
modify it--
as
Begin
Select student_number as pre_stdn from students
update students set student_number=student_number+1 where student_number is
not null
--add 1 on all student numbers--
select student_number as alt_stdn from students
End
After this define, use this to run procedure:
Execute Tonytest;
You can see it has been changed.
If you want to go check all Procedure you made, please use:
select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_DEFINITION
from INFORMATION_SCHEMA.ROUTINES
where ROUTINE_TYPE='PROCEDURE'
相关文章推荐
- How to Use a Function or a Procedure as a Parameter in another Function
- How To Use a DataReader Against an Oracle Stored Procedure in Visual C# .NET
- How to use Oracle 11g ODP.NET UDT in an Oracle Stored Procedure's Where clause
- How to use Oracle 11g ODP.NET UDT in an Oracle Stored Procedure's Where clause
- 如何在QT for S60 中使用pthread库(Carbide.c++) (How to use pthread in QT4.6 for S60)
- How to Collect and Display System Statistics (CPU and IO) for CBO use (Doc ID 149560.1)
- how to use Eclipse with Maven
- java How to Use Tables
- How to use pylab to plot figure()?
- Example of how to use both JDK 7 and JDK 8 in one build.--reference
- How to Use Cursor
- How to use lingo...
- How to use the xsd generator generate the class
- How to use the tools provided to train Tesseract for a new language.
- How to use iBatis/NHibernate in medium trust/partial trust environments like Mosso
- EF 接收OUTPUT参数的方法 How to Retrieve Stored Procedure Output Parameters in Entity Framework
- How to detect a rollback in MySQL stored procedure?
- How to use "vi" edit the docs or source code files
- UE4 How To use Colored Translucent Shadows
- (zhuan) Attention in Neural Networks and How to Use It