1 Login with MySQL client
2 Select Database
mysql>use test
3 What stored procedures are queried for the current database
mysql>show procedure status where Db='test'
4 Create a simple stored procedure
mysql>create procedure hi() select 'hello';
5 stored
Tags: style io os ar for div sp on Cthe SQL that establishes the stored procedure is as follows:
CREATE PROCEDURE proc_variable ()
BEGIN
DECLARE dec_var_ VARCHAR (+);
DECLARE rep_num INT;
DECLARE Dec_var CURSOR for SELECT id_ from act_ru_variable WHERE name_ = ' yjdqsj ' GROUP by Execution_id_ have Coun T (name_) >1;
OPEN Dec_var;
REPEAT
FETCH D
The difference between stored procedures and functions reference links:Http://www.cnblogs.com/lengbingshy/archive/2010/02/25/1673476.htmlTo create a stored procedure:DROP PROCEDURE Mypro;CREATE procedure Mypro (SID int,out Scount INT)BEGINSELECT COUNT (*) into Scount from student where id = SID;ENDExecute the stored pr
Tags: php process mys review href encounter roc cat Te ProDo the project process encountered the need to insert an ordered test data, do not want to write PHP loop, online Find methods, review the stored procedure again haha.SQL statement Reference from Https://stackoverflow.com/questions/26981901/mysql-insert-with-while-loopDelimiter $$CREATE PROCEDURE MyProc ()
Create a data table using a stored procedure:When creating a table, note that you must add authid current_user. If the created table already exists, the stored procedure continues to run. If you do not add this key statement, the stored procedure will be abnormal,This statement is equivalent to granting permissions.Example 1The creation statement is as follows:Co
DDL statements cannot be used directly in Oracle's stored procedures, such as CREATE, alter, DROP, truncate, and so on.That assumes that we want to create a temporary table in a stored procedure that can only use dynamic SQL statements:Create or replace procedure Pro as str_sql varchar2 (+); Begin -Creates a temporar
Some time ago, I found a good naming method for the stored procedure in the group and named it as a group number. So I couldn't wait to search for some examples on the Internet. After reading the examples, I thought the naming method was quite special, I forgot about it here. I suddenly forgot to use it today, so I went online again and rummaged through the box ........
Naming method "create procedureProcn
The newly developed colleague came to me, after adding a field to a table on the intranet database, and then creating the stored procedure, the error indicates that the new field is invalid.
Warning:procedure created with compilation errors.Sql> Show ErrorErrors for PROCEDURE cb_date_modify:Line/col ERROR-------- -----------------------------------------------------------------37/20 Pl/sql:sql Statement
Create or replace procedure PD_GENERATE_HELP_LAST_TABLES IS-- Generate a local data table for the view vw_last_xxx generated from sqlserverTabNocount NUMBER;V_ SQL VARCHAR2 (200 );
BEGIN-- Judge the table dat_help_last_scqy1)SELECT count (*) INTO tabNocount FROM user_tables WHERE table_name = 'dat _ HELP_LAST_SCQY1 ';IF tabNocount> 0 THENDbms_output.put_line ('drop table dat_help_last_scqy1 ');V_ SQL: = 'dr
I 've been struggling for the past couple months to use the Visual Studio XSD tool to create typed datasets from my stored procedures. but I always get an error telling me the temp table is an invalid object name. I 've just discovered that temp tables are actually not allowed in this tool, due to the way it writes the schema to XML (see this article and this article for details ). there are a couple Things about typed datasets that wocould make my li
1.mySQL Create stored process procedure as follows:/* The wonderful thing is to define a label [delimiter//] means procedure is not SQL, procedure's key word was eaten by the dog? */2. Process Control Language If then end if3.case when end case.4.while End While/* End while is light, this is different from Oracle */5.loop End Loop Cycles:6.repeat until end repeat
Recently, SQL stored procedures have been found to greatly reduce the amount of code in the program.
In the future, we need to consider using more stored procedures.
Two tips:
1. Use stored procedures to dynamically create data tables.
/*Process function: dynamically create a data table in a stored procedureNote: connect the "single quotation marks" of the SQL statement"Created on: 2006-09-01Created by: sky
procedure of the database, is also the first query of the master table records, and then use the cursor loop in the process of querying the child table information, and then in C #
--Centralized processing
Obviously, the latter reduces the transaction cost of the database, one time to obtain the desired data, personally think it is better than the first, welcome everyone to discuss a better way
Note that the type returned by Row_number () is big
procedure this Monday wocould of course be to use group_concat to avoid a temporary table in the first of the two dynamic queries. I chose the cursor loop over group_concat as a loop wocould give us more flexibility to enhance the procedure with more functionality. but after rethinking this I found that you coshould possibly achieve about 90% of what you coshould ever think of WITH NESTED control flow func
. Similarly, compare the current time with weektime/monthtime for weeks/months, and add weekhits/monthhits to 1 or set it to 1, finally, set the update time to the current time (remember !).
The brief code is as follows (this code is implemented by storage ):
-- Function: counts the clicks of novels (daily clicks, weekly clicks, monthly clicks, and total clicks) -- Author: Jiang -- modification time: 2011-12-3use txbook -- determine whether the stored proce
Tags: os ar using for SP data on the BSDescription:1. Use SQL stored procedures with transactions.2, when adding data, automatically create a unique primary key format "one letter" + "time format" + "a five-digit"3, using the cursor, through another table of multiple data, to the current table data added, and automatically produce a unique primary key format as above.4. Usage scenario: While increasing primary key unique primary table data, read multi
GPS system, due to the large amount of storage, the decision to create a data database on a daily basis, 23 hours a day to execute the job-- ============================================= --author:--Create Date: --description:-- ============================================= ALTER PROCEDURE [dbo].[Proc_created_database_log] as Declare @sqlStr varchar( $) BEGI
In the query window, enter:
Set ansi_nulls onGoSet quoted_identifier onGoIf not exists (select * From sys. objects where object_id = object_id (n' [DBO]. [getlistbypage] ') and type in (n'p', n'pc '))BeginExec DBO. sp_executesql @ Statement = N'
-- Efficient paging Stored Procedure-- Create by Jinlong Zhang
Create proce
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.