db2

How to test the connection to a db2 database

℡╲_俬逩灬. 提交于 2019-12-20 01:36:21
问题 I need to test the connection to a db2 database. With oracle databases I'd execute a 'select * from dual' in order to do this. But dual is specific for oracle. Is there a similar canonical test sql statement for db2? 回答1: SELECT 1 FROM SYSIBM.SYSDUMMY1 cheaper then SELECT CURRENT SQLID FROM SYSIBM.SYSDUMMY1 回答2: I ended up using SELECT CURRENT SQLID FROM SYSIBM.SYSDUMMY1 which seems to work nice. 回答3: LIST DB DIRECTORY or LIST TABLES 来源: https://stackoverflow.com/questions/4733356/how-to-test

How do I combine two queries (union all) into one row?

假如想象 提交于 2019-12-19 18:23:50
问题 I have a tricky situation in trying to get information from multiple queries into a single row. Consider the following table: CpuUage: Time time Group char(10) Subsys char(4) Jobs int Cpu int holding the following data: Time Group Subsys Jobs Cpu ----- ------ ------ ---- --- 00:00 group1 NORM 1 101 (grp1-norm) A1 01:00 group1 SYS7 3 102 (grp1-sys7) A2 01:00 group1 NORM 5 104 (grp1-norm) A1 02:00 group1 NORM 7 108 (grp1-norm) A1 02:00 group2 NORM 9 116 (grp2-norm) B1 02:00 group3 SYS7 11 132

How do I combine two queries (union all) into one row?

左心房为你撑大大i 提交于 2019-12-19 18:23:50
问题 I have a tricky situation in trying to get information from multiple queries into a single row. Consider the following table: CpuUage: Time time Group char(10) Subsys char(4) Jobs int Cpu int holding the following data: Time Group Subsys Jobs Cpu ----- ------ ------ ---- --- 00:00 group1 NORM 1 101 (grp1-norm) A1 01:00 group1 SYS7 3 102 (grp1-sys7) A2 01:00 group1 NORM 5 104 (grp1-norm) A1 02:00 group1 NORM 7 108 (grp1-norm) A1 02:00 group2 NORM 9 116 (grp2-norm) B1 02:00 group3 SYS7 11 132

How to update DB2 table with a join?

一曲冷凌霜 提交于 2019-12-19 11:32:11
问题 I have two tables and I want to update by joining them. I am using DB2 V9.7. ORDER_APPROVALS ORDER_ID CREATED_BY_ID CREATED_BY_NAME PROCESS_DT ------------------------------------------------------- 234 2 admin (null) 307 2 admin (null) 313 2 admin 11-11-2013 ORDER_ATTRIBUTE ORDER_ID ATTRIBUTE_ID VALUE ----------------------------------- 234 123 ? --(ORDER_APPROVALS.CREATED_BY_NAME) 307 123 ? --(ORDER_APPROVALS.CREATED_BY_NAME) I want to update value field against Attribute_ID 123. So far I

Database: SUBSTRING upto first occurence of character

点点圈 提交于 2019-12-19 10:58:29
问题 i have string type abc_01, abcd_01 or 02 now i want the substring upto _ ie abc_,abcd_ etc. I am using db2 as400 .Please suggest the processing through RIGHT or LEFT function 回答1: Use the POSITION built-in function. The format is either: POSITION--(--search-string--IN--source-string--) or POSSTR--(--source-string--,--search-string--) I also suggest using a CASE structure to check for when there is no _ or if it's at the beginning or end. Here is an example. We'll assume, for the sake of the

Config file for holding connection string parameters in Java

孤街浪徒 提交于 2019-12-19 07:37:18
问题 I come from an ASP .Net background. I am now writing a Java program to import data from a DB2 database into an Oracle database. I have completed the basic functionality of importing this data. The problem I have is, I have all the connection properties harcoded into the Java program itself. Is there any "Best Practices" methodology to have the connection string details stored in a configuration file similar to web.config we use for ASP .Net? Does Java have any kind of mechanism for

db2 query insert from another table

↘锁芯ラ 提交于 2019-12-19 07:12:21
问题 I have a table product(id_product , name ); I have another one: productHistory (id_H , id_product , name); I wanna create a query (db2) to insert all the rows of product in productHistory; I have a sequence product_history_seq I wanna do something like that: insert into productHistory (id_h , , id_product , name) values ( product_history_seq.nextval,.. Or, select (id_product , name) from product What's the correct query? 回答1: I believe you are looking for: insert into productHistory ( id_h ,

DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704

倾然丶 夕夏残阳落幕 提交于 2019-12-19 06:08:26
问题 I created local database in DB2 called " TestDB " then I created table called " TestTable ". I found that the table is put under schema name is " yasmin ". I am trying to connect to the DB2 database using JDBC but I got this exception R SQLException information [1/4/14 11:32:59:289 EST] 0000004d SystemErr R Error msg: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=DB2ADMIN.TESTTABLE, DRIVER=3.61.86 [1/4/14 11:32:59:290 EST] 0000004d SystemErr R SQLSTATE: 42704 [1/4/14 11:32:59:290 EST]

How to use LIKE with IN in DB2?

流过昼夜 提交于 2019-12-19 05:58:09
问题 SELECT * FROM abc WHERE column1 IN (a1,b1,c1) I want to use LIKE with this select query; how can I write LIKE statement with IN, similar to the query below: SELECT * FROM abc WHERE column1 LIKE IN (a%,b%,c%) 回答1: You can't combine like with in . Write it as separate comparisons: select column1 from abc where column1 like 'a%' or column1 like 'b%' or column1 like 'c%' 回答2: You can't. Write it as: column1 LIKE 'a%' OR column1 LIKE 'b%' OR column1 LIKE 'c%' 回答3: As the other folks say you can

Is there a good in-memory database that would act like DB2 [closed]

混江龙づ霸主 提交于 2019-12-19 05:36:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 2 years ago . I am currently using DB2 to do unit tests, but it is sometime quite slow. I would need a good in-memory database that would include all the feature of DB2. Does this type of in-memory database exist, or do they only allow standard SQL feature? Thank you. EDIT The DB2 Database is on a remote server, so I would