The following describes how to create a MySQL stored procedure and describes the detailed steps. If you have encountered any problems with the MySQL stored procedure, you may wish to take a look at it. -- Select database mysqlusetest; Databasechanged -- create an example Tab
To do a recent project, you need to do a CLR stored procedure for SQL SERVER 2005 and study the implementation of the CLR. For the convenience of later use, summed up my implementation process here, but also for the CLR interested but do not know how to achieve the friends to do a reference, if there are different views, hope to teach more. Here is a first
1. Create a stored procedure
Like a data table, we need to create a stored procedure before using it. Its concise syntax is:
Create proc stored procedure name
[Parameter list (multiple parameters are separated by commas (,)]
As
MySQL stored procedure example. you cannot use beginend in ifelse. Otherwise, the error ErrorCode: 1064 is reported to solve bitsCN.com.
MySQL stored procedure example. you cannot use begin end in if else. Otherwise, an Error Code
is no Chinese reference to the Parameter embedding optimization, reluctantly translated as "parametric implant optimization")This article uses a simple example to illustrate the difference between the two. Here, first of all, thank uest Students for the reference and guidance suggestions.Differences in use with RECOMPILE and OPTION (RECOMPILE)For recompilation of stored
It can be used to encrypt SQL stored procedures or triggers.(This is provided by SQL Server itself, that is, this is Microsoft's encryption algorithm)
Use the with encryption optionThe with encryption clause hides the Stored Procedure text from the user. In the following
@num intSet @num = 1;WhileBeginIf @num%2=0BeginPrint @numEndSet @num [Email protected]+1EndThings: The ability to guarantee a large number of operations in a batch, if there is a failure, you can return to the original state. Ensure that the operation is correct.Only if the data changes, it will trigger things, that is, to increase the deletion.Classification:Explicit transactions (manual write required)Implicit transaction (MSSQL Default, no manual required)Begin tryBEGIN Tran-Set the point of
, which enhances program security. Storage programs restrict user action permissions more granular than standard SQL Server. For example, if you have a deposit form, every time you sell a cargo, the cashier will update the form (minus one item from the stock). You can set permissions on the cashier to allow them to use the Decrement_item stored
Label:First step: Build a package with a cursor type Sql>create or Replace package testpackage As type test_cursor is REF CURSOR; --Define a cursor named Test_cursor End Testpackage; Step two: Write a paged stored procedure Sql>create or replace procedure Fenye ( TableName i
', ' 2014-08-10 ' as ' broken line Date ', (select W_color from T_warning D where D.w_code=a.p_code) as W_color, 1 as ' broken line ' From T_product A Left joins T_product_sort B on a.p_sort=b.ps_id and A.p_sort in (' 1 ', ' 2 '); --Open cursor OPEN cur; --Start cycle Read_loop:loop --Extract the data in the cursor, there is only one, and many words are the same; FETCH cur into a_code; -At the end of the declaration IF do Then LEAVE Read_loop; END IF; Call ' Spgetwangingscount ' (A_code, '
1. Create a stored procedureSQL> Create or replace function get_sal3 (name varchar2)2 return number is3 v_sal number (6, 2 );4 begin5 select Sal into v_sal from EMP where upper (ename) = upper (name );6 RETURN v_sal;7 end;8/
The function has been created.
SQL> var salary numberSQL> Exec: Salary: = get_sal3 ('Scott ')
The PL/SQL process is successfully completed.
Label:Not finished, feeling a bit of a problem.================================== Declaration ==================================This article is original, reproduced in the text of the influential annotated author and source, and to ensure the integrity of the article.Do not modify (including this statement) without the consent of the author, and reserve the right of legal investigation.Do not use for publication, printing or academic reference without the consent of the author.In order to ensure
All along, I always in SQL tools, such as SQL Server, Navicat and so on to execute SQL statements to find the problem of their own written SQL problem, the result is asked, let people laughable!So how do you debug a white-line stored pro
stored procedure when calling the procedure. This reduces the amount of data transmitted over the network. Security. Parameterized stored procedures can prevent SQL injection attacks and apply Grant, Deny, and Revoke permissions to stor
SQL Server stored procedure syntax:Create PROC [edure] procedure_name [; number] [{@parameter data_type} [VARYING] [= default] [OUTPUT]] [,... n] [with {RECOMPILE |Encryption | RECOMPILE, encryption}] [for REPLICATION] as sql_statement [... n]First, a brief introduction of the parameters 1, procedure_nameThe name of the new
dbo. proc_test @ in_p,
@ Out_p out,
@ In_out_p output
Select @ in_p, -- input parameter
@ Out_p, -- output parameter
@ In_out_p -- Input and Output Parameters
/*
(No column name)
1 3 4
*/
2. Parameters in the stored procedure.
The following are the issues:
[SQL] view plaincopy create table # tableTest (id int identity, name varchar (20), age int ,)
Go
Insert int
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.