The shell processing DB2 database, which is written for work needs, extracts DB2 data from the shell and processes it.
#SQL文定义
Sql= "SELECT AAA, BBB, CCC from MYTBL1"
#执行SQL
Sdata= ' DB2 ' "$SQL"
#返回值判断
If [$?-ne 0]
Then
#显示db2返回的错误信息
echo "$SDATA"
Exit 1
Fi
#对取得的数据进行处理.
echo "$SDATA" | Sed-e ' 4,/^$/!d;/^$/d ' |
While read AAA triple BBB CCC
Todo
echo "AAA is $AAA, the BBB is $BBB, the CCC is $CCC"
Done
#取得数据件数
echo "$SDATA" | Sed-n-E '/^$/{1,3d;n;s/[^0-9]*\ ([0-9]*\) [^0-9]*
values (6, ' mu ')"db20000i the SQL command completedsuccessfully.$ DB2 "UPDATE student set name= ' gu ' where age=1 'db21034e the command is processed as an SQL statement because it is not aValid command line Processor command. During SQL Processing It returned:sql0911n the current transaction have been rolled back because of a deadlockOrTimeout. Reason code "68". sqlstate=40001$ DB2 "Delete from student where age=2"db21034e the command is processed
Tags: generate unavailable Sele exception Exce end call Cat backThere are several declarative forms of error handling:§ If any error (not FOUND), set L_error to 1 to continue execution:DECLARE CONTINUE HANDLER for SQLEXCEPTIONSET l_error=1;§ If any errors occur (not FOUND), execute rollback and produce an error message after exiting the current block or stored procedure.DECLARE EXIT HANDLER for SQLEXCEPTIONBEGINROLLBACK;SELECT ' Error occurred–terminating ';END;§ If the MySQL 1062 error (Duplica
completedsuccessfully.$ DB2 "UPDATE student set name= ' gu ' where age=1 'db21034e the command is processed as an SQL statement because it is not aValid command line Processor command. During SQL Processing It returned:sql0911n the current transaction have been rolled back because of a deadlockOrTimeout. Reason code "68". sqlstate=40001$ DB2 "Delete from student where age=2"db21034e the command is processed as an SQL statement because it is not aVali
Sql0668n cause code is "1 ", therefore, the SQL state = 57016 Oracle cannot be imported to db2sql0668n at a time because the cause code is "1" sqlstate = 57016 Oracle to DB2 Sun Moon King's blog http://sunmoonking.spaces.live.com using MTK tool failed to import data, so (Oracle uses MTK tool to import data to DB2
Http://sunmoonking.spaces.live.com/blog/cns! E3bd9cbed01777ca! 751. Entry. Everything went well. After the sampling check, we found that so
An error occurred while stopping the database.
Error Message:'Error occurred during the shutdown of RPM database.'
Analysis: DB2 was not started before the RPM database was installed. Therefore, the installation script view fails to stop DB2.
Solution: Start DB2 and run the installer again.
An error occurred while creating the buffer pool.
Error Message:'Error occurred during buffer pool creation.'
Analysis:Check the log file and find it in bufferpools. log. An error is prompted:
DB2
,'! ');//Delimiter;Select Hello ('World ');Show create function testprocedure. Hello \ G# It returns the childProgramFeatures such as databases, names, types, creators, and creation and modification datesShow function status like 'hello' \ G
# # Note that the name cannot be the same as the field nameDelimiter //Drop procedure if exists test //
Create procedure Test ()BeginDeclare name varchar (5) default 'bob ';Declare newname varchar (5 );Declare Xid int;
Select name, Id into newname,
handling DECLARE HANDLER syntax:DECLARE {exit| CONTINUE} HANDLER for {error_number|{ SQLSTATE Error-string}|condition} SQL StatementThe above is the use of error handling, that is, when the program automatically triggered after the error code, MySQL allows two kinds of processors, one is exit processing, the other is continue processing, and exitThe difference is that after he executes, the primary program still runs, and then the compound statement
mysqli_get_server_version () n/A returns the MySQL server-side version of the integer information
$mysqli-gt;info Mysqli_info () n/A retrieve information for the last query executed
$mysqli-gt;insert_id mysqli_insert_id () n/A returns the ID that was automatically generated and used by the last query
$mysqli-gt;sqlstate mysqli_sqlstate () n/A returns the SQLSTATE error of the previous MySQL operation
$mysq
Use test;
DROP table if exists T8;
CREATE TABLE T8 (S1 int,primary KEY (S1));
drop procedure if exists handlerdemo;
DELIMITER $$
CREATE PROCEDURE handlerdemo ()
BEGIN
declare xx int default 4;
DECLARE oh_no condition for sqlstate ' 23000 ';
#DECLARE CONTINUE HANDLER for SQLSTATE ' 23000 ' SET @X2 =1;
Declare exit handler for Oh_no set @info = ' violates PRIMARY key constraint ';
SET @x=1;
INSERT into T8
On Linux operating systems, each instance must correspond to a Linux user, so the conversion of 2 instances can be simple by converting the user
Implementation, using the SU command.
Scripting: Create_table.bat
DB2 Drop DB Express2 Set Dbpath=c:SET Dbname=express2 SET memory=20 DB2 CREATE DATABASE%dbname% on%dbpath% autoconfigure USING mem_percent APPLY DB and DBM DB2 CONNECT to% dbname% USER%1 USING%2 Del Schema.log Triggers.log App_objeects.log DB2 Set Schema ExpressDb2-t-v-f schema.ddl-z S
---------$ DB2 +c "INSERT into student values (7, ' he ')"db20000i the SQL command completed successfully.Session 2---------$ DB2 "SELECT * FROM Student"sql0911n the current transaction have been rolled back because of a deadlockOrTimeout. Reason code "68". sqlstate=40001$ DB2 "SELECT * FROM student where Age = 3"sql0911n the current transaction have been rolled back because of a deadlockOrTimeout. Reason code "68".
conditions You can use the DECLARE keyword to define conditions in MySQL. The basic syntax is as follows:
DECLARE condition_name Condition for Condition_value
Condition_value:
SQLSTATE [VALUE] sqlstate_value | Mysql_error_code
Where the Condition_name parameter represents the name of the condition, the Condition_value parameter represents the type of condition, and the Sqlstate_value parameter and Mysql_error_code parameter ca
values (7, ' he ')"db20000i the SQL command completed successfully.Session 2---------$ DB2 "SELECT * FROM Student"sql0911n the current transaction have been rolled back because of a deadlockOrTimeout. Reason code "68". sqlstate=40001$ DB2 "SELECT * FROM student where Age = 3"sql0911n the current transaction have been rolled back because of a deadlockOrTimeout. Reason code "68". sqlstate=40001As you can see
conditions and handlers. 1. Defining conditions You can use the DECLARE keyword to define conditions in MySQL. The basic syntax is as follows:
DECLARE condition_name Condition for Condition_value
Condition_value:
SQLSTATE [VALUE] sqlstate_value | Mysql_error_code
Where the Condition_name parameter represents the name of the condition, the Condition_value parameter represents the type of condition, and the Sqlstate_value parame
. The basic syntax is as follows:
DECLARE condition_name Condition for Condition_value
Condition_value:
SQLSTATE [VALUE] sqlstate_value | Mysql_error_code
Where the Condition_name parameter represents the name of the condition, the Condition_value parameter represents the type of condition, and the Sqlstate_value parameter and Mysql_error_code parameter can represent the MySQL error. For example, in error 1146 (42S02), the Sqls
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.