📄 ieptests.sql
字号:
create table alltypes(chartype char(20) , biginttype bigint , datetype date , decimaltype decimal(10,5) , doubletype double , inttype integer , lvartype long varchar , realtype real , sminttype smallint , timetype time , tstamptype timestamp , vartype varchar(50));insert into alltypes values('chartype string' , 9223372036854775807, '1993-10-29' , 12345.54321, 10E307, 2147483647, 'long varchar testing', 10E3, 32767, '09.39.43', '2004-09-09 11:14:11', 'varchar testing');insert into alltypes values('chartype string' , -9223372036854775808, '1993-10-29' , 0.0, -10E307, -2147483647, 'long varchar testing', -10E3, 32767, '09.39.43', '2004-09-09 11:14:11', 'varchar testing');insert into alltypes values('"chartype" string' , 9223372036854775807, '1993-10-29' , -12345.54321, 10E307, 2147483647, 'long "varchar" testing', 10E3, 32767, '09.39.43', '2004-09-09 11:14:11', '"varchar" testing'); call SYSCS_UTIL.SYSCS_EXPORT_TABLE (null, 'ALLTYPES' , 'extinout/alltypes.del' , null, null, null) ;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'ALLTYPES' , 'extinout/alltypes.del' , null, null, null, 0) ;select * from alltypes ; delete from alltypes;--import should work with trigger enabled on append and should not work on replacecreate table test1(a char(20)) ;create trigger trig_import after INSERT on alltypesreferencing new as newrowfor each row mode db2sqlinsert into test1 values(newrow.chartype);call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'ALLTYPES' , 'extinout/alltypes.del' , null, null, null, 0) ;select count(*) from alltypes ;select * from test1;delete from alltypes;call SYSCS_UTIL.SYSCS_IMPORT_TABLE (null, 'ALLTYPES' , 'extinout/alltypes.del' , null, null, null, 1) ;select count(*) from alltypes;drop trigger trig_import;drop table test1;--test importing to identity columnscreate table table1(c1 char(30), c2 int generated always as identity, c3 real, c4 char(1));create table table2(c1 char(30), c2 int, c3 real, c4 char(1));insert into table2 values('Robert',100, 45.2, 'J');insert into table2 values('Mike',101, 76.9, 'K');insert into table2 values('Leo',102, 23.4, 'I');call SYSCS_UTIL.SYSCS_EXPORT_QUERY('select c1,c3,c4 from table2' , 'extinout/import.del' , null, null, null) ;CALL SYSCS_UTIL.SYSCS_IMPORT_DATA(NULL,'TABLE1', 'C1,C3,C4' , null, 'extinout/import.del',null, null,null,0);select * from table1;delete from table1;call SYSCS_UTIL.SYSCS_EXPORT_TABLE(null , 'TABLE2' , 'extinout/import.del', null, null, null) ;--following import should fail becuase of inserting into identity column.CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE(NULL, 'TABLE1', 'extinout/import.del',null, null, null,1);--following import should be succesfulCALL SYSCS_UTIL.SYSCS_IMPORT_DATA(NULL, 'TABLE1', 'C1,C3,C4' , '1,3,4', 'extinout/import.del',null, null, null,1);select * from table1;update table2 set c2=null;--check null values import to identity columns should also failcall SYSCS_UTIL.SYSCS_EXPORT_TABLE(null , 'TABLE2' , 'extinout/import.del' , null, null, null) ;CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE(NULL, 'TABLE1', 'extinout/import.del',null, null, null,1);select * from table1;--check that replace fails when there dependents and replaced data --does not violate foreign key constraints.create table parent(a int not null primary key);insert into parent values (1) , (2) , (3) , (4) ;create table child(b int references parent(a));insert into child values (1) , (2) , (3) , (4) ;call SYSCS_UTIL.SYSCS_EXPORT_QUERY('select * from parent where a < 3' , 'extinout/parent.del' , null, null, null) ;--replace should fail because of dependent tableCALL SYSCS_UTIL.SYSCS_IMPORT_TABLE(NULL, 'PARENT', 'extinout/parent.del',null, null, null,1);select * from parent;---test with a file which has a differen records seperators (\n, \r , \r\n)create table nt1( a int , b char(30));CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE(NULL, 'NT1', 'extin/mixednl.del',null, null, 'UTF-8',0);select * from nt1;drop table nt1 ;--test case for bug 5977;(with lot of text data)create table position_info ( position_code varchar(10) not null , literal_no int not null , job_category_code varchar(10), summary_description long varchar, detail_description long varchar, web_flag varchar(1) );CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE ('APP', 'POSITION_INFO', 'extin/position_info.del', null, null, 'US-ASCII', 1);select count(*) from position_info ;select detail_description from position_info where position_code='AG1000';CALL SYSCS_UTIL.SYSCS_EXPORT_TABLE ('APP', 'POSITION_INFO', 'extinout/pinfo.del', null, null, null);delete from position_info;CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE ('APP', 'POSITION_INFO', 'extinout/pinfo.del', null, null, null, 1);select count(*) from position_info ;select detail_description from position_info where position_code='AG1000';--test for autoincrement valuesCALL SYSCS_UTIL.SYSCS_EXPORT_QUERY('values(1),(2),(3)','extinout/autoinc.dat',null,null,null);create table dest_always(i int generated always as identity);create table dest_by_default(i int generated by default as identity);CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE('APP','DEST_ALWAYS','extinout/autoinc.dat',null,null,null,0);select * from dest_always;CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE('APP','DEST_BY_DEFAULT','extinout/autoinc.dat',null,null,null,0);select * from dest_by_default;drop table dest_always;drop table dest_by_default;create table dest_always(i int generated always as identity);create table dest_by_default(i int generated by default as identity);CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE('APP','DEST_ALWAYS','extinout/autoinc.dat',null,null,null,1);select * from dest_always;CALL SYSCS_UTIL.SYSCS_IMPORT_TABLE('APP','DEST_BY_DEFAULT','extinout/autoinc.dat',null,null,null,1);select * from dest_by_default;drop table dest_always;drop table dest_by_default;--test case for bug (DERBY-390)--test import/export with reserved words as table Name, column Names ..etc.create schema "Group";create table "Group"."Order"("select" int, "delete" int, itemName char(20)) ;insert into "Group"."Order" values(1, 2, 'memory') ;insert into "Group"."Order" values(3, 4, 'disk') ;insert into "Group"."Order" values(5, 6, 'mouse') ;--following export should fail because schema name is not matching the way it is defined using delimited quotes.call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('GROUP', 'Order' , 'extinout/order.dat', null, null, null) ;--following export should fail because table name is not matching the way it is defined in the quotes.call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('Group', 'ORDER' , 'extinout/order.dat', null, null, null) ;--following export should fail because of unquoted table name that is a reserved word.call SYSCS_UTIL.SYSCS_EXPORT_QUERY('select * from "Group".Order' , 'extinout/order.dat' , null , null , null ) ;--following exports should pass.call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('Group', 'Order' , 'extinout/order.dat', null, null, null) ;call SYSCS_UTIL.SYSCS_EXPORT_QUERY('select * from "Group"."Order"' , 'extinout/order.dat' , null , null , null ) ;call SYSCS_UTIL.SYSCS_EXPORT_QUERY('select "select" , "delete" , itemName from "Group"."Order"' , 'extinout/order.dat' , null , null , null ) ;--following import should fail because schema name is not matching the way it is defined using delimited quotes.call SYSCS_UTIL.SYSCS_IMPORT_TABLE ('GROUP', 'Order' , 'extinout/order.dat', null, null, null, 0) ;--following import should fail because table name is not matching the way it is defined in the quotes.call SYSCS_UTIL.SYSCS_IMPORT_TABLE ('Group', 'ORDER' , 'extinout/order.dat', null, null, null, 0) ;--following import should fail because table name is not matching the way it is defined in the quotes.call SYSCS_UTIL.SYSCS_IMPORT_DATA('Group', 'ORDER' , null , null , 'extinout/order.dat' , null , null , null, 1) ; --following import should fail because column name is not matching the way it is defined in the quotes.call SYSCS_UTIL.SYSCS_IMPORT_DATA('Group', 'Order' , 'DELETE, ITEMNAME' , '2, 3' , 'extinout/order.dat' , null , null , null, 1) ; --following import should fail because undelimited column name is not in upper case.call SYSCS_UTIL.SYSCS_IMPORT_DATA('Group', 'Order' , 'delete, itemName' , '2, 3' , 'extinout/order.dat' , null , null , null, 1) ; --following imports should passcall SYSCS_UTIL.SYSCS_IMPORT_TABLE ('Group', 'Order' , 'extinout/order.dat', null, null, null, 0) ;select * from "Group"."Order";call SYSCS_UTIL.SYSCS_IMPORT_DATA('Group', 'Order' , null , null , 'extinout/order.dat' , null , null , null, 1) ; select * from "Group"."Order";call SYSCS_UTIL.SYSCS_IMPORT_DATA('Group', 'Order' , 'delete' , '2' , 'extinout/order.dat' , null , null , null, 1) ; select * from "Group"."Order";call SYSCS_UTIL.SYSCS_IMPORT_DATA('Group', 'Order' , 'ITEMNAME, select, delete' , '3,2,1' , 'extinout/order.dat' , null , null , null, 1) ; select * from "Group"."Order";drop table "Group"."Order";---test undelimited names( All unquoted SQL identfiers should be passed in upper case). create schema inventory;create table inventory.orderTable(id int, amount int, itemName char(20)) ;insert into inventory.orderTable values(101, 5, 'pizza') ;insert into inventory.orderTable values(102, 6, 'coke') ;insert into inventory.orderTable values(103, 7, 'break sticks') ;insert into inventory.orderTable values(104, 8, 'buffolo wings') ;--following export should fail because schema name is not in upper case.call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('inventory', 'ORDERTABLE' , 'extinout/order.dat', null, null, null) ;--following export should fail because table name is not in upper case.call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('INVENTORY', 'ordertable' , 'extinout/order.dat', null, null, null) ;--following export should pass.call SYSCS_UTIL.SYSCS_EXPORT_TABLE ('INVENTORY', 'ORDERTABLE' , 'extinout/order.dat', null, null, null) ;--following import should fail because schema name is not in upper casecall SYSCS_UTIL.SYSCS_IMPORT_TABLE ('inventory', 'ORDERTABLE' , 'extinout/order.dat', null, null, null, 0) ;--following import should fail because table name is not in upper case.call SYSCS_UTIL.SYSCS_IMPORT_TABLE ('INVENTORY', 'ordertable' , 'extinout/order.dat', null, null, null, 0) ;--following import should fail because table name is not in upper case .call SYSCS_UTIL.SYSCS_IMPORT_DATA('INVENTORY', 'ordertable' , null , null , 'extinout/order.dat' , null , null , null, 1) ; --following import should fail because column name is not in upper case.call SYSCS_UTIL.SYSCS_IMPORT_DATA('INVENTORY', 'ORDERTABLE' , 'amount, ITEMNAME' , '2, 3' , 'extinout/order.dat' , null , null , null, 1) ; call SYSCS_UTIL.SYSCS_IMPORT_DATA('INVENTORY', 'ORDERTABLE' , null , null , 'extinout/order.dat' , null , null , null, 1) ; select * from inventory.orderTable;call SYSCS_UTIL.SYSCS_IMPORT_DATA('INVENTORY', 'ORDERTABLE' , 'ITEMNAME, ID, AMOUNT' , '3,2,1' , 'extinout/order.dat' , null , null , null, 1) ; select * from inventory.orderTable;drop table inventory.orderTable;--end derby-390 related test cases.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -