db2

Connecting to DB2 database

醉酒当歌 提交于 2019-12-13 05:26:40
问题 I get the following error when I try to connect Toad for DB2: ERROR [08001] [IBM] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "10.99.13.5". Communication function detecting the error: "recv". Protocol specific error code(s): " ", " ", "0". SQLSTATE=08001 Attached is my connection properties. Any help connecting would be great. 回答1: This is tipical problem when

Update table with value from another table

不想你离开。 提交于 2019-12-13 05:25:43
问题 I try to update value from one table with another table by use IP_ID to compare 2 table by following sybtax UPDATE EDWID02.CUSTOMER_MOBILE t1 SET T1.MOBILE = ( SELECT T2.MOBILE FROM EDWID02.NEW_MOBILE t2 WHERE T1.IP_ID=T2.IP_ID) The error I found was DB2 Database Error: ERROR [21000] [IBM][DB2/AIX64] SQL0811N The result of a scalar fullselect, SELECT INTO statement, or VALUES INTO statement is more than one row. SQLSTATE=21000 even I change = to in it's told me another error DB2 Database

DB2 Coalesce function is returning nulls

点点圈 提交于 2019-12-13 05:21:00
问题 I am using DB2 for IBM i V6R1, and I am trying to convert a string value which sometimes has a valid representation of a number in it into a number. What I came up with was this: select onorno, onivrf, coalesce(cast(substr(onivrf,1,5) as numeric),99999) as fred from oinvol sometimes the ONIVRF field has data like '00111-11', sometimes it has data like 'FREIGHT'. The documentation leads me to believe that for data like this: ONORNO ONIVRF 12 11010-11 13 FREIGHT 14 00125-22 I should get output

DB2 Stored Procedure - controlled large record deletion

泪湿孤枕 提交于 2019-12-13 05:15:23
问题 Ive written a DB2 Stored Procedure for a housekeeping job that in theory could be deleting large volumes for data from the database. The requirement is to control the deletion by committing a defined number of records at a time. Firstly, I would like some feedback on my Stored Procedure to see if there is any improvements I could make. Secondly, Ive got a question about SQL Errors. If an error occurs during an iteration of the loop, does the Stored Procedure exit immediately ? Ideally I would

DB2 Load from delimitited Files - escape " in Fields doesn't work

自闭症网瘾萝莉.ら 提交于 2019-12-13 04:56:54
问题 I bet it's totaly simple and i just don't see it, but i don't get it .. I execute the following command in DB2 command line processor: DB2 LOAD FROM "DB_ACC_PASS_REGEXP.del" OF DEL METHOD P (1, 2, 3, 4, 5) MESSAGES "DB_ACC_PASS_REGEXP.del.msg" INSERT INTO DB_ACC_PASS_REGEXP (APP_ID,APREGEXP,EXPLAIN_TEXT,ID,OPT_KZ) NONRECOVERABLE INDEXING MODE REBUILD Which loads the Data specified in following File into the database. 1,"[a-z]",,1,0 1,"[A-Z]",,2,0 1,"[0-9]",,3,0 1,"[!|\"|§|$|%|&|/|(|)|=|?|`|´|

DB2 Size of Table

半世苍凉 提交于 2019-12-13 04:47:04
问题 I'm trying to figure out the size in kb of each table in a schema. I have a query set up, but I'm not sure if I'm getting the correct output. I'm running DB2 v9 LUW. My Query: SELECT T.TABNAME, T.TABSCHEMA, COLCOUNT, TYPE, (DATA_OBJECT_P_SIZE + INDEX_OBJECT_P_SIZE + LONG_OBJECT_P_SIZE + LOB_OBJECT_P_SIZE + XML_OBJECT_P_SIZE) AS TOTAL_SIZE FROM SYSCAT.TABLES AS T, SYSIBMADM.ADMINTABINFO AS A WHERE T.TABNAME = A.TABNAME It works and all, but I am fairly sure that division is required in this

Application ID from db2 8.1.5 on Z/OS

泪湿孤枕 提交于 2019-12-13 04:45:42
问题 I have been searching how to get application Id from db2 8.1.5 on Z/OS(remote). I found this link: http://www.ibm.com/developerworks/data/library/techarticle/0302stolze/0302stolze.html In this link, it is said that there is not built-in function(application_id) in db2 prior to 8.2 to get application id. So, i tried the solution said in this link. But when trying SQL function in previous link to register the Java method, db2 warns me in this way: DB21034E The command was processed as an SQL

Refer to table name dynamically in DB2/400 SQL query..?

孤者浪人 提交于 2019-12-13 04:41:16
问题 I'd like to run a query that gets a combination of live data and metadata for a regularly changing list of table names. This is for research & analysis on a large server with 100+ schemas and thousands of tables/views in each. I need help referring to table names dynamically, which I do understand is NOT possible. However... My googling indicates the solution may be an SQL statement in a text variable, which is then executed by the EXEC statement. But this is DB2/400 v7r3, which is a complex

Insert and subselect

こ雲淡風輕ζ 提交于 2019-12-13 04:39:42
问题 INSERT INTO S654321.PERSON (PNR, FIRSTNAME, LASTNAME) VALUES SELECT 32, FIRSTNAME, LASTNAME FROM S654321.CUSTOMER WHERE CUSTNR = 'C002' Returns sqlcode -104 and sqlstate 42601. Do you see the error? The select statement itself is correct. 回答1: The error is that when you insert records you either use a select, or you specify the values. You don't do both. This is ok insert into table (field1) values (value1) as is this: insert into table (field1) select distinct value1 from somewhere So pick a

IBM Db2: select numeric characters only from a column

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 04:36:14
问题 I have a column 'TEST_COLUMN' that carries 3 values: 123 123ad(44) w-eq1dfd2 I need to SELECT TEST_COLUMN but get the following result: 123 12344 12 I am running on Db2 Warehouse on Cloud. 回答1: You can use REGEXP_REPLACE: SELECT REGEXP_REPLACE( '123Red345', '[A-Za-z]','',1) FROM sysibm.sysdummy1 The query would return "123345". Because you asked below, here is the generic version: SELECT REGEXP_REPLACE(YOUR_COLUMN, '[A-Za-z]','',1) FROM SCHEMA.TABLE 来源: https://stackoverflow.com/questions