availableMysql> SELECT * from Temp_table, temp_table as T2;ERROR 1137:can ' t reopen table: ' Temp_table 'If you are using a different alias to find a temporary table multiple times in a stored function, or if you are using a different statement in this storage function, this error will occur.The show tables statement does not enumerate temporary tablesYou can't
Many of the query class's stored procedures return a result set of a table structure, and if you need to use this result set in other stored procedures, you can use the former query results directly to avoid writing duplicate SQL scripts.
For example, a stored procedure Sp_
proc pro_page @ startIndex int, @ endIndex intas select count (*) from product; select * from (select row_number () over (order by pid) as rowId, * from product) temp where temp. rowId between @ startIndex and @ endIndexgo -- drop proc pro_pageexec pro_page 1, 4 ---- paging stored procedure if (object_id ('Pro _ page'
The use of another stored procedure as a table in one stored procedure does not support the direct receipt of a stored procedure from the from in SQL Server. This time we can use the te
{ DEFINER | INVOKER } | COMMENT 'string' routine_body: Valid SQL procedure statement or statements
The syntax comes from the official reference manual. The characteristic syntax block is worth attention. First, we will introduce it with an example.
Example:
# CREATE a database drop database if exists Dpro; create database DproCHARACTER SET utf8; USE Dpro; # CREATE a department table drop
Tags: c blog a http ext com
Temp table
? Will the stored data be purged automatically at the end of the session or transaction processing? Provide a dedicated data store for each session? Available for all sessions, without affecting the private data for each session if you need to store private data to perform a task, and after the task is executed
Tip: In Oracle8i, if you need to return a result set through a stored procedure, you need to use a cursor!
CREATE OR REPLACE PACKAGE Body "Sms_pay". Smsmaint "Is--Functional Description: Inquiry Agent Bank transaction flow information Writer:wang Haibo 2004-08-24PROCEDURE Getagtbankflow (AreaCode in Varchar2,keyword, varchar2,starttradedate in Varchar2,endtradedate, Re_cursor out T_cursor,ret out number)Is
procedures that are automatically created in the current database when a new database is created.Common system stored procedures are:exec sp_databases; --View Databaseexec sp_tables; --View TableEXEC sp_columns student;--view columnsEXEC sp_helpindex student;--View indexEXEC sp_helpconstraint student;--constraintsexec sp_stored_procedures;exec sp_helptext ' sp_stored_procedures ';--view stored
Stored procedures are the necessary technology to do the project, as long as you interview to find work, database and stored procedures are also required, the following to understand the simple basic technical knowledge of stored procedures:
First, the basic concept of stored procedures.
A
from the SQL Server instance. The name of the global temporary table begins with a two digit sign (# #), which is visible to any user after it is created, and is removed when all users referencing the table are disconnected from SQL Server.
Table variables are equivalent to ADO's Recordset, much faster than temporary tables.Table variables cannot be used in the
Stored Procedures | The recordset assumes the following stored procedures (the purpose of this article is not to tell the T-SQL syntax, so the stored procedure gives only code, not description):
/*sp1*/CREATE PROCEDURE Dbo.getuserlistAsSET NOCOUNT ONBeginSELEC
reducing the amount of data transmitted by the network. Security. Parameterized stored procedures can prevent SQL injection attacks and can apply grant, deny, and revoke permissions to stored procedures.
Stored procedure simple syntax:
CREATE PROCEDURE
Tag:ar use sp data bssql nbspc information 1. Why Use Table variablesTable variables are introduced from 2000, and Microsoft believes that table variables have the following advantages over local temporal tables:A. As with other variables, table variables have a well defined range and are automatically cleared;B. Using table
parameter is capable of being returned.
[With] Recompile in {Recompile|encryption}: Indicates that each time the stored procedure is executed, it is recompiled (by default, it is compiled only when it is created).
Encryption: The contents of the stored procedure created are encrypted.
Tip: Here's how to find the names
one time per 10 seconds */
--Create TABLE
Table Tab_time (
Timestamp
);
--Create a stored procedure
Procedure Pro_job_print
As
Begin
--dbms_output.put_line (' dd-mm-yyyy hh24:mi:ss '));
Values (sysdate);
End
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 centralized control3, can reduce the network traffic4, ensure the security and integrity of the data
Temporal table ConceptsA temporary table is a database object that is used to temporarily save temporary data (or intermediate data), which is somewhat similar to a normal table, but is quite different. It can only be stored in a temporary table space, not a user's tablespac
code that will be executed. Implemented function: Automatically inserts the current system time into the Getsysdate table every minute.
V. Examples
/* Insert one time per 10 seconds */
--Create TABLE
Table Tab_time (
Timestamp
);
--Create a stored
, and calling stored procedures can greatly reduce the number of interactions with the database.
Second, improve security. If SQL statements are mixed in ASP code, once the code is out of password, it also means that the database structure is out of password.
Third, it is conducive to the reuse of SQL statements.
In ASP, the stored procedure is generally called t
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.