db2

db2 stored procedures creation behavior

早过忘川 提交于 2019-12-24 09:26:44
问题 I am playing with db2 stored procedures and I am struggling in understading the following concept. When I create a stored procedure like the simple below create or replace procedure test() begin insert into mytable(a) values ('a'); insert into mytable(a) values ('b'); insert into mytable(a) values ('c'); end I can see that the mytable gets filled during this creation. I was expecting to use 'call test()' to insert my data, but I can see it is not what I thought. What I am doing wrong here or

Extract data from XML Clob using SQL from db2

蓝咒 提交于 2019-12-24 08:13:24
问题 I want to extract the value of Decision using sql from table TRAPTABCLOB having column testclob with XML stored as clob. IN DB2 Sample XML as below <?xml version="1.0" encoding="UTF-8"?> <DCResponse> <Status>Success</Status> <Authentication> <Status>Success</Status> </Authentication> <ResponseInfo> <ApplicationId>5701200</ApplicationId> <SolutionSetInstanceId> 63a5c214-b5b5-4c45-9f1e-b839a0409c24 </SolutionSetInstanceId> <CurrentQueue /> </ResponseInfo> <ContextData> <!--Decision Details

ignoring end of line character in a DAT file in DB2 import command while loading data

流过昼夜 提交于 2019-12-24 08:05:29
问题 I have a dat file containing data. A line from the file is as below: HHHH-III|AAAA0000536101|2011/11/16|0100002MM000 This data is being loaded in a DB2 table using db2 import command. Issue: The last field in the data gets loaded along with the "new line" character at the end of the line in the dat file i.e. 0100002MM000 is getting loaded with some invisible character at the end. Same field is being loaded in other table from other file. But in the other dat file it is at the centre somewhere

.NET Standard 2.0 / EntityFrameworkCore / DB2 / IBM.EntityFrameworkCore issue

泄露秘密 提交于 2019-12-24 07:49:31
问题 Does anyone here has experience with IBM.EntityFrameworkCore package? I've created a .NET Standard 2.0 library project in VS2017, added mentioned package, and tried to make it work by following this and this tutorial from IBM website, with no luck. I get the project compiled, but at the runtime I'm getting a System.TypeLoadException with the following message: Method 'ApplyServices' in type 'IBM.EntityFrameworkCore.Infrastructure.Internal.Db2OptionsExtension' from assembly 'IBM

Top 2 max value excluding duplicate values

两盒软妹~` 提交于 2019-12-24 07:45:15
问题 Example data: Name | Domain | Count | datetime ---------------------------------------------------- John | google | 5 | 2019-07-09 01:00:01 John | apple | 6 | 2019-07-09 01:02:01 John | apple | 8 | 2019-07-09 01:03:01 John | google | 10 | 2019-07-09 01:11:01 John | dos | 1 | 2019-07-09 01:11:01 John | dos | 3 | 2019-07-09 01:11:01 Expected output: Name | max_Domain1| max_Count1 | max_Domain2 | max_Count2 | datetime --------------------------------------------------------------------------

Why is my “before update” trigger changing unexpected columns?

我只是一个虾纸丫 提交于 2019-12-24 07:14:31
问题 I have a table USERS with a varchar column LoginId . I am trying to use a before update trigger to change the incoming value to lower case. This is what I have done so far. It changes the value to lower case. But it also changes all other column to their default values. CREATE TRIGGER TOLOWER BEFORE UPDATE ON USERS REFERENCING NEW AS N OLD AS O FOR EACH ROW MODE DB2SQL set N.LoginId= lcase(N.LoginId) Is this trigger correct? If not then what changes should should I do ? 来源: https:/

SQL - How can I return the IDs from a where clause list that are not in the table?

天涯浪子 提交于 2019-12-24 04:45:07
问题 Given a query like this: select customerId from customer where customerId in ( 1, 2, 3 ) I have hundreds of IDs in the where clause's list; how would I return the IDs from the list in the where clause that are not in the table? This is a production table that I can only run select queries against. I can only run select queries; I don't have permissions to create any tables. 回答1: The really, really brutal approach , for most DBMS, this will work (except Oracle where you need to select..from

What is the fastest way to insert 1 mln+ records in DB2 table?

偶尔善良 提交于 2019-12-24 04:18:13
问题 In C# I have 1mln+ records which are necessary to insert into DB2 table. What is the fastest way to insert 1 mln+ records in DB2 table? I've check several way and the fastest is by 1000 rows basing on the following request: INSERT INTO tbl (id, rel) values (1, 2), (2,3),... Are the any other ideas? 回答1: Try wth something like that for 1000 records: INSERT INTO table SELECT cast (RAND()*50000 as numeric(6)) AS id, cast (RAND() as varchar(30)) AS rel, FROM qsys2/COLUMNS fetch first 1000 rows

Connecting Android application to BlueMix stored DB2 Database

烂漫一生 提交于 2019-12-24 03:42:39
问题 How can I connect an Android application to a DB2 database stored in BlueMix? I know that some Java libraries are missing in Android, so I can't use JDBC to connect to the database. Any Idea? 回答1: You can not talk directly to the SQL DB on Bluemix from your android app. You will need to create an intermediary application on bluemix that talks to the db and your android app can talk to that application. You can implement this backend as a RESTful API (Java JAX-RS, Node.js w/ Express etc). The

“AMOUNT1” is not valid in the context where it is used

本小妞迷上赌 提交于 2019-12-24 03:32:36
问题 I'm executing the the following query in DB2: select SUM (orders.totalproduct +orders.TOTALTAX +orders.totalshipping -orders.totaladjustment) as amount1 from orders where amount1>10000 The query is not executed, I get this exception instead: "AMOUNT1" is not valid in the context where it is used.. SQLCODE=-206, SQLSTATE=42703, DRIVER=3.64.96 SQL Code: -206, SQL State: 42703 What am I doing wrong? 回答1: You can't create and use amount1 in same time in DB2. Try this: select * from ( select SUM