db2

How to convert xml text stored in a VARCHAR and select using XQUERY expression

爷,独闯天下 提交于 2019-12-11 16:46:39
问题 I have xml documents stored as text in a VARCHAR column. I'd like to convert the text to XML documents in order to perform XQUERY selects on the documents. An example document looks like: <a> <b foor="bar"/> <c/> </a> My query looks like: SELECT XMLQUERY('//c' PASSING XMLCAST('<a><b foor="bar"/><c/></a>' AS XML)) FROM SYSIBM.sysdummy1 But instead of returning a element I get the following error message: SQL Error [10507]: The Context item in an axis step must be a node. SQLCODE=-16012,

update table from another table in db2 9

╄→гoц情女王★ 提交于 2019-12-11 16:38:25
问题 hi i run this script " UPDATE t1 SET T1.col1= T2.col1 FROM aaa t1 , bbb t2 WHERE T1.col2=138802 AND T1.col3 >=8800084 and T1.col3 <=8852884 AND T1.col4=0 AND T1.col5=T2.col2" and i get syntax error !!! (ILLEGAL USE OF KEYWORD FROM) how i can run this script??? 回答1: Here's a modified version: UPDATE aaa t1 SET T1.col1 = (SELECT T2.col1 FROM bbb t2 WHERE T1.col5=T2.col2) WHERE T1.col2=138802 AND T1.col3 >=8800084 and T1.col3 <=8852884 AND T1.col4=0 I isolated the T2 stuff in a subquery with an

SQL Convert Seconds into Day:Hour:Min:Sec

萝らか妹 提交于 2019-12-11 16:34:53
问题 Topic says it all. I'm trying to do some magic, via a function, that turns a second integer into a string "DD:HH:MM:SS". Snip input: 278543 output: "3D 5H 22M 23S " What I'd like to do, more gracefully if possible, is pad the numbers (So that 5M shows as 05M) and right align them so that "3D 5H 22M 23S " is " 3D 5H 22M 23S" instead. edit: Latest cut that seems to work. Would love to have it prettier, but this definitely works as far as I can tell: CREATE FUNCTION DHMS(secondsElapsed INT)

Connecting php server to DB2 from outside IBM Cloud

烂漫一生 提交于 2019-12-11 16:33:07
问题 I am following the process as described here: https://www.ibm.com/support/knowledgecenter/en/SSHRBY/com.ibm.swg.im.dashdb.doc/connecting/connect_connecting_php.html I have completed the instalation and I have even run the validation command in shell db2cli validate -dsn DashDB -connect -user bluadmin -passwd 'your_secret_password' see output below But still my www page crashes on the line $conn = odbc_connect( $conn_string, "", "" ); becasue it does not recognize the odbc_connect function.

iDB2Commands in Visual Studio 2010

大城市里の小女人 提交于 2019-12-11 16:24:32
问题 These are the basic things I know about iDB2Commands to be used in Visual Studio 2010. Could you please help me how could I extract data from DB2? I know INSERT, DELETE and Record Count. But SELECT or Extract Data and UPDATE I don't know. Imports IBM.Data.DB2 Imports IBM.Data.DB2.iSeries Public conn As New iDB2Connection Public str As String = "Datasource=10.0.1.11;UserID=edith;password=edith;DefaultCollection=impexplib" Dim cmdUpdate As New iDB2Command Dim sqlUpdate As String conn = New

Difference between data values in two DB2 tables with different table structures

China☆狼群 提交于 2019-12-11 16:15:47
问题 I have two db2 tables on the mainframe 'old' and 'new'. These tables have 1 billion records each as of now with 70-80 columns. These tables are getting populated from two different systems, so the table structure is not identical, i.e. there are some differences in the columns with both tables sharing some common columns which have to be compared for different data values. for example : OLD id A B C 1 x y z 1 x y z 3 m n o 4 e f g NEW id B C D E 1 y a a b 1 y a a b 2 n o c d 4 g g l m So in

Using prepared statement without ROW_NUMBER() and OVER() functions in Db2

只谈情不闲聊 提交于 2019-12-11 16:13:12
问题 Let's say I have a table T_SWA.This is my prepared statement. Select version From (Select id, version, creator, created_date ROW_NUMBER() OVER(order by created_date) cnt From T_SWA Where cnt=3 and id=35); I need to select the 3rd recent version from the T_SWA table. Can anyone suggest a replacement for this query without using ROW_NUM() and OVER() functiions? 回答1: First take the three most recent and then from those three take the first. select id, version, creator, created_date from ( select

What is the best way to handle BOOLEAN values in Db2?

江枫思渺然 提交于 2019-12-11 15:57:50
问题 Database Db2 Scenario I have a column that needs to be true or false. I have found two sources that point to how to achieve this; however, when I bring them together I get an error. Boolean values Casting between data types Current Solution CREATE TABLE USERS ( ID INT NOT NULL, . . . IS_LOCKED SMALLINT NOT NULL WITH DEFAULT 0, PRIMARY KEY(ID) ); SELECT U.ID, CAST(U.IS_LOCKED AS BOOLEAN) as IS_LOCKED FROM USERS U Error: A value with data type "SYSIBM.SMALLINT" cannot be CAST to type "SYSIBM

IMPORT script on IBM DB2 Cloud using RUN SQL Interface

浪子不回头ぞ 提交于 2019-12-11 15:44:08
问题 I am trying to import a JOBFILE.CSV from my hard drive into the table JOB using the RUN SQL script in IBM DB2 cloud. CALL SYSPROC.ADMIN_CMD('IMPORT FROM "C:/DATAFILE/JOBFILE.CSV" OF DEL INSERT INTO JOB'); I am getting this error: An I/O error (reason = "sqlofopn -2029060079") occurred while opening the input file.. SQLCODE=-3030, SQLSTATE= , DRIVER=4.25.1301 It seems the path that I have set is not working. As I have researched JOBFILE.CSV must be loaded first into the DB2 server before the

Using days of the week for aggregates in DB2

为君一笑 提交于 2019-12-11 15:43:40
问题 I currently have a query that reads from a table which is written to daily, so I have totals for every day. What I'm trying to do is modify this query so that I can use days of the week as an aggregate, if that makes sense. THe totals I get right now are correct, but I want to use Sunday through Saturday as a week and effectively say ``'If today is wednesday, sum totals for weeklyData for Sunday, MOnday and Tuesday from tableOne``` I have this query: SELECT employee, sum(case when category =