T-SQL is an enhanced SQL language provided by SQLServer based on the SQL language. The T-SQL provides all the features of ANSISQL and adds more features such as extended functions, system pre-storage, and program design structures. The following describes
3. the T-SQL of SQL Server
T-SQL is an enhanced SQL language provided by SQL Server based on SQL language. The T-SQL provides all the features of ansi SQL and adds more features such as extended functions, system pre-storage, and program design structures. The following describes the enhancement features of several common T-SQL.
(1) T-SQL provides richer data types
The T-SQL provides multiple additional data types that can save up to 2 GB of data in one attribute of the database. In addition, the XML data type is provided for storing XML data.
(2) error handling mechanism
The T-SQL provides methods like try... catch statements in PHP to catch exceptions when SQL code is running.
The format is as follows.
BEGIN TRY
-- SQL code
END TRY
Begin catch TRAN_ABORT
-- Handle errors
END CATCH
4. Oracle PL/SQL
PL/SQL is an SQL extension provided by Oracle, similar to T-SQL. PL/SQL uses block syntax to complete a function. The block syntax format of PL/SQL is as follows.
[DECLARE]
--- Definition
BEGIN
--- Execution part
[EXCEPTION]
--- Exception handling
END
Each statement in PL/SQL ends with a semicolon. one or more SQL statements can be embedded.
Oracle provides four types of PL/SQL programs.
(1) function: the function can accept several parameters and return the processed variables. the syntax format is as follows.
FUNCTION name [{parameter1 [, parameter2,...])] RETURN date_type IS
--- Definition
BEGIN
--- Execution part
[EXCEPTION
--- Exception handling
END [name]
(2) process: similar to a function, the difference is that there is no return value. The syntax format is as follows.
PROCEDURE name [{parameter1 [, parameter2,...])] IS
--- Definition
BEGIN
--- Execution part
[EXCEPTION
--- Exception handling
END [name]
(3) package: a collection of various related objects, including multiple functions and processes.
(4) trigger: used to receive operations from the database and trigger a PL/SQL block.