MySQL Error Import ERROR 1030 (HY000) at line 84: Got error 168 from storage engine

To solve this problem :
 ERROR 1030 (HY000) at line 84: Got error 168 from storage engine

we can solve this error by :

1. Drop Existing DB
[root@localhost ~]# mysqladmin drop promisesmb_beta01db;

2. Create Empty DB
[root@localhost ~]# mysqladmin create promisesmb_beta01db;

3. Import sql file
[root@localhost ~]# mysql -u root -p promisesmb_beta01db < promisesmb_beta01db.sql

Sequence Oracle : Change Nextval Value

Sometimes, we have nextval of sequence not match with current primary key of our table. We can change value of nextval's sequence :

DECLARE
  last_used  NUMBER;
  curr_seq   NUMBER;
BEGIN
  SELECT MAX(FCODE_PK) INTO last_used FROM PROMISE_T1_M_KODE_FIELD;

  LOOP
    SELECT PROMISE_T1_M_KODE_FIELD_SEQ.NEXTVAL INTO curr_seq FROM dual;
    IF curr_seq >= last_used THEN EXIT;
    END IF;
  END LOOP;
END;

PROMISE_T1_M_KODE_FIELD is example of table, PROMISE_T1_M_KODE_FIELD_SEQ is example of my sequence, FCODE_PK is example of field.

Error DB2 = -413:22003

One day, our application developer give me error log like this :

com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-723, SQLSTATE=09000, SQLERRMC=USRPRO.INSERT_T6_KONTRAK;-413;22003;, DRIVER=3.65.131

we got error on DB2 : -413,22003.

from this link : http://www.sqlerror.de/db2_sql_error_-413_sqlstate_22003.html

It can happened because : OVERFLOW OCCURRED DURING NUMERIC DATA TYPE CONVERSION

We can solve this by change datatype, from integer to double.

before
DECLARE ITPM_JML1 integer;
DECLARE ITM_HRG_SAT integer;

after
DECLARE ITPM_JML1 DOUBLE;
DECLARE ITM_HRG_SAT DOUBLE; 

db2move copy schema to other schema in another database

[db2admin@db2server dbdata]$ db2move dbvm COPY -sn db2admin -co target_db VPCGD schema_map "((DB2ADMIN,USRVM))" -u db2admin -p db2admin

Application code page not determined, using ANSI codepage 1208

*****  DB2MOVE  *****

Action:  COPY

Start time:  Tue Sep 12 17:59:09 2017


All schema names matching:  DB2ADMIN;

Connecting to database DBVM ... successful!  Server : DB2 Common Server V11.1.1

Copy schema DB2ADMIN to USRVM on the target database VPCGD

Create DMT :  "SYSTOOLS"."DMT_59b7bdfdba232"

Binding package automatically ... /home/db2admin/sqllib/bnd/db2move.bnd ... successful!

Start Load Phase :


db2move finished successfully



Files generated:
-----------------
COPYSCHEMA.20170912175909.msg
LOADTABLE.20170912175909.MSG

Please delete these files when they are no longer needed.


End time:  Tue Sep 12 18:09:14 2017
[db2admin@db2server dbdata]$ ls

DB2 : Create Nickname & Setup Federated Database

[db2admin@db2server ~]$ db2 create wrapper drda
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 "create server sevcvm type DB2/UDB version '11.1' wrapper drda authorization \"db2admin\" PASSWORD \"db2admin\" options( add dbname 'dbvm')"
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 "CREATE USER MAPPING FOR db2admin SERVER sevcvm OPTIONS (REMOTE_AUTHID 'db2admin', REMOTE_PASSWORD 'db2admin')"
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 CREATE NICKNAME db2admin.VM_T5_DELIVERY_RECEIVED FOR sevcvm.db2admin.PROMISE_CM_T5_DELIVERY_RECEIVED
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 CREATE NICKNAME db2admin.VM_T5_DELIVERY_RECEIVED_JASA FOR sevcvm.db2admin.PROMISE_CM_T5_DELIVERY_RECEIVED_JASA
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 CREATE NICKNAME db2admin.VM_T5_DELIVERY_RECEIVED_MATERIAL FOR sevcvm.db2admin.PROMISE_CM_T5_DELIVERY_RECEIVED_MATERIAL
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 CREATE NICKNAME db2admin.VM_T4_F_SRVC FOR sevcvm.db2admin.PROMISE_CM_T4_F_SRVC
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 CREATE NICKNAME db2admin.VM_T4_F_ITEM FOR sevcvm.db2admin.PROMISE_CM_T4_F_ITEM
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 CREATE NICKNAME db2admin.VM_T4_F_PAYMENT_TERM FOR sevcvm.db2admin.PROMISE_CM_T4_F_PAYMENT_TERM
DB20000I  The SQL command completed successfully.

[db2admin@db2server ~]$ db2 CREATE NICKNAME db2admin.VM_T4_F_CONTRACT FOR sevcvm.db2admin.PROMISE_CM_T4_F_CONTRACT
DB20000I  The SQL command completed successfully.

Example Trigger on Database DB2

Here it's simple example trigger on DB2. This trigger copy data from one table to another table

CREATE TRIGGER INS_LOG
      AFTER INSERT ON PROMISE_LOG
      REFERENCING NEW AS NROW
      FOR EACH ROW MODE DB2SQL
      BEGIN ATOMIC
        INSERT INTO DB2ADMIN.PROMISE_LOG_TRIG(LOG_ID, DATE, IP, METHOD, PARAM, REQ, RESP, STATUS_CODE, TOKEN)
        VALUES(NROW.LOG_ID, NROW.DATE, NROW.IP, NROW.METHOD, NROW.PARAM, NROW.REQ, NROW.RESP, NROW.STATUS_CODE, NROW.TOKEN);
      END

reference :
https://www.ibm.com/support/knowledgecenter/en/SSEPEK_10.0.0/sqlref/src/tpc/db2z_sql_createtrigger.html

DB2 Error Set Tablespace Container : SQL0968C The File System is Full


Error Set Tablespace Container : SQL0968C The File System is Full

We can solve this problem by using automatic management :

before
SET TABLESPACE CONTAINERS FOR 11 USING
  (File '/plnhr/new/TSLOB0101' 786432,
   File '/plnhr/new/TSLOB0102' 786432,
   File '/plnhr/new/TSLOB0103' 786432,
   File '/plnhr/new/TSLOB0104' 786432,
   File '/plnhr/new/TSLOB0105' 786432,
   File '/plnhr/new/TSLOB0106' 786432) ;

after
SET TABLESPACE CONTAINERS FOR 11 USING AUTOMATIC STORAGE