db2

How to do a safe "SELECT FOR UPDATE" with a WHERE condition over multiple tables on a DB2?

Problem On a DB2 (version 9.5) the SQL statement SELECT o.Id FROM Table1 o, Table2 x WHERE [...] FOR UPDATE WITH RR gives me the error message SQLSTATE=42829 (The FOR UPDATE clause is not allowed because the table specified by the cursor cannot be modified). Additional info I need to specify WITH RR, because I'm running on isolatio...

Equivalent of LIMIT for DB2

How do you do LIMIT in DB2 for iSeries? I have a table with more than 50,000 records and I want to return records 0 to 10,000, and records 10,000 to 20,000. I know in SQL you write LIMIT 0,10000 at the end of the query for 0 to 10,000 and LIMIT 10000,10000 at the end of the query for 10000 to 20,000 So, how is this done in DB2? Wha...

DB2 SQL-Error: -519, SQLState: 24506

There is a strut application which throws -519 error sometimes. I would have to restart tomcat whenever this error occures. You can find te detail of -519 here It rarely happens. But I am not able to understand the actual cause and its solution. ...

php process - one after another - simulating threading

I have a report generation functionality. Export to csv or txt . For each month it will be 25000 records each row with 55 columns. For yearly it will be more than 300000!! i try to add memory limit ,but i dont think its good!! Anyway now its 128M. My expectation I will split the date range selected by user into a range of 25 days or 30...

joda time hibernate to DB2 DATE

I tried without succes to make a custom type mapping between DateTime joda and DATE db2. Which annotations should we use in the case of using joda time hibernate library instead of custom type mapping ? Thanks a lot ...

Syntax of if exists in IBM Db2

The follow query drops a table if the table exists but it doesnt seem to work for IBM Db2. Begin atomic if( exists( SELECT 1 FROM SYSIBM.SYSTABLES WHERE NAME='EMAIL' AND TYPE='T' AND creator = 'schema1' )) then drop table EMAIL; end if; End Whereas the same if exisits syntax works if i have a DML st...

DB2 Case Sensitivity

I'm having great difficultly making my DB2 (AS/400) queries case insensitive. For example: SELECT * FROM NameTable WHERE LastName = 'smith' Will return no results, but the following returns 1000's of results: SELECT * FROM NameTable WHERE LastName = 'Smith' I've read of putting SortSequence/SortType into your connection string b...

Return custom value if join not successfull ?

I am trying to do a select which would return a blank '' when a join is not successfull (when a blank '' or a '-' is encountered in column) and return column value when it is successfull. I am using case for this but not succeeding until now. Anyone can advise a better query ? select a.EmpName,a.deptcode,(a.deptcode||' '||(SELE...

impact of index in SQL query

Suppose there are two indexes on a table index1 on col1,col2 index2 on col3 Please tell me, whether in below case index will help? .. where col1,col4 .. where col3,col4 .. where col1,col3 .. where col1,col2,col3,col4 *note, i wrote where clause only without specifying the conditions. Only used column are mentioned I am using D...

DB2 - SQL Querie Insert Rows from one DatabaseA.Table to DatabaseB.Table

Hi, is something like this possible in SQL/DB2? INSERT INTO Prod.CD_Final (ID) VALUES (SELECT ID FROM Test.CD_Final); I alway get the error message: "Prod.CD_Final" is an undefined name. SQL Code: -204, SQL State: 42704 "Test.CD_Final" is an undefined name. SQL Code: -204, SQL State: 42704 Thanks, Stefan ...

How do I do Change Data Capture for DB2 on AS 400 and iSeries.

I am not looking for Infosphere based solution. Is there any API so that I can use it for my development. ...

DB2 query group by id but with max of date and max of sequence

Hi , My table is like ID FName LName Date(mm/dd/yy) Sequence Value 101 A B 1/10/2010 1 10 101 A B 1/10/2010 2 20 101 X Y 1/2/2010 1 15 101 Z X 1/3/2010 5 10 102 A B 1/10/2010 2 10 102 X Y 1/2/2010 1 15 1...

exporing data and schema of databse

1)does database backup exports only data or schema as well? 2)i have one PC running DB2 database server1 and having a database XYZ,Now i want to create replica of this database on another pc running db2 datbase. 3)I dont want to do this without using affecting db server1, i dont want it to stop or hang 4)can i use db2 BACKUP DATABASE t...

changing from was-ce server to any other server?

I have created a j2ee project using: 1)DB2 (as database server) 2)WAS-CE server to deploy the application 3)eclipse to code. as was-ce server is running too slow I want to change to any other server. my question is: can I change to any other server? What are your views about tomcat and sql server? The most important question is wha...

DB2 Limit update access to one column in table

I have a DB2 table with column "comments" that I would like to allow a user to have update access to, without giving them update access to the whole table. I suspect that the answer will involve a view. However, in order to make the view relevant, won't I need to expose the primary key to the view? Won't the user then be able to update ...

java.lang.UnsatisfiedLinkError while loading DB2 JDBC driver

I try to use jboss-seam with a db2 database, the following error occurs com.ibm.db2.jcc.a.SqlException: [jcc][10389][12245][3.52.95] while loading the native library db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path an error occurred ERRORCODE=-4472, SQLSTATE=null I tried setting -Djava.library.path=/opt...

Why does this query generate so much data?

Err I apologize for the title, but I forgot what its actually called in SQL lingo. Thing is using this query: SELECT DISTINCT a.col1, a.col2,a.col3,c.col1, c.col2 FROM table1 a LEFT JOIN table2 c ON a.col1 = c.col3 WHERE a.col2 = '038CQH' I get a result with around 56000 rows, but when I checked using: SELECT a.col1, a.col2,a.c...

Removing leading \n while assaigning to a variable

I have a DB2 query in a shell script which return an integer value, but I am unable to store it in a variable. temp1= echo db2 -x "select max(id) from work.work_tb" I am getting this output when I run it, sh -x test.sh db2 -x select max(id) from work.work_tb echo 50 temp1= 50 So for some reason $temp1 is unable to get the value, ...

Insert data from another DB in tables

Hi all, I'm having some issue here. Let me explain. So I was about done with migration of this project and I've decided to run the test suite to make sure the logic was still working as expected. Unfortunately, it didn't... but that's not the issue. At the end of the suite, there was a nice script that execute a delete on the datas of ...

DB2 REORG TABLE from client side with Migrator.NET

I'm using Migrator.NET with a DB2 database and my current migration executes an ALTER TABLE statement, which causes the table to go into the "reorg pending state". This state requires the reorganisation of the table with > REORG TABLE TableName before I can do anything else with it. I tried executing this with Database["DB2"].Execut...