db2

Duplicate Key error when using INSERT DEFAULT

耗尽温柔 提交于 2019-12-08 07:33:37
问题 I am getting a duplicate key error, DB2 SQL Error: SQLCODE=-803, SQLSTATE=23505, when I try to INSERT records. The primary key is one column, INTEGER 4, Generated, and it is the first column. the insert looks like this: INSERT INTO SCHEMA.TABLE1 values (DEFAULT, ?, ?, ...) It's my understanding that using the value DEFAULT will just let DB2 auto-generate the key at the time of insert, which is what I want. This works most of the time, but sometimes/randomly I get the duplicate key error.

COBOL program, JCL job, or both?

自闭症网瘾萝莉.ら 提交于 2019-12-08 06:37:50
问题 I have to preform 3 tasks: an insert, a delete, and a write I'm not sure what the best way to do this is. My mainframe program design skills aren't too tight, so I was looking for advice. Could I avoid doing a COBOL program for this? The way I see it, I just need JCL that executes SQL statements. If I design my statements correctly, then they should be able to preform tasks 1 and 2 this way. But I'm thinking I may need to have a COBOL program to write to a file? I'll overview my thought

How to generate the primary key in DB2 (SQL Optimization)

匆匆过客 提交于 2019-12-08 06:18:56
问题 I use the following statement to generate my primary key. table2 keeps the curent primary key. But it is too slow. How can i optimize this proces. update table1 t set ID =ROW_NUMBER() OVER (); update table1 t set ID = (Select NUMGEN.currentvalue + ID from table1 data, table2 NUMGEN where NUMGEN.tablename = 'table1' and t.Id = data.ID ); 回答1: Why are you doing primary keys this way. Why would you need to dynamically generate/modify your own id values? If you need a unique generated id for a

How to create New instance in db2 10.1 using IBM Data Studio

允我心安 提交于 2019-12-08 04:16:22
问题 How to create new instance in db2 10.1 using command line db2icrt command with example or using data studio client. Anybody please reply. Thanks 回答1: Which OS are you usnig. In Lunix/UNIX/OS X You have two options: Dedicated user for the instance You need to create one user in the OS (useradd) with a file system useradd -m db2inst2 /opt/db2/10.1/instance/db2icrt -u db2inst1 db2inst1 Your own user You install DB2 in your home, and then your username will be the name of the instance (non-root

Dropping a schema and all of its contents in DB2 8.x

让人想犯罪 __ 提交于 2019-12-08 03:53:15
问题 How would I drop a schema and all of its contents, using SQL, in DB2 8.x without knowing what the content is? 回答1: I do not have a schema to drop at hand, but the infocenter (http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/t0005230.htm) says that a DROP SCHEMA [schema name] shall work on DB2 8.x EDIT: Ok, the Infocenter also says: "Before dropping a schema, all objects that were in that schema must be dropped themselves or moved to another schema"

Why am I getting this SQL/DB error?

﹥>﹥吖頭↗ 提交于 2019-12-08 03:06:22
问题 I am trying to run a simple SQL statement with DB2 and am having a few problems. I would like to have a single script in a txt/db2 file and have the engine process all of the commands Here is the script: CONNECT TO MYDB CREATE TABLE PERSONS( PID SMALLINT NOT NULL, NAME VARCHAR(20) NOT NULL ) TERMINATE When I run a db2 -f /pathtofile I get: SQL0104N An unexpected token "(" was found following "CREATE TABLE PERSONS". Expected tokens may include: "END-OF-STATEMENT". SQLSTATE=42601 What am I

REORG command in db2

心已入冬 提交于 2019-12-08 02:44:25
So I have been altering a table in QMF. After 3 alters I believe the table has gone into a pending reorg state so that I cannot alter it additionally. Am I correct in this assumption? If so what implications does this have and to get around it can I simply reorganize the table and continue altering it? If so, what does the syntax look like for reorganizing a table? I tried REORG TABLE PIDJBIP.TABLE_NAME_T and receive the error: an unexpected token "PIDJBIP" was found following "REORG TABLE". Expected tokens may include: "JOIN". SQL state = 42601. I haven't gotten much help out of the IBM pages

DB2 Unique Constraint over multiple Columns

吃可爱长大的小学妹 提交于 2019-12-08 02:32:22
问题 Is there a way to create a unique constraint over multiple columns like in Mysql? UNIQUE KEY `uniqueKey` (`Field1`,`Field2`), The only thing i have found is the unique keyword directly after the field. Thanks in advance! 回答1: You should be able to add a unique constraint as: alter table t add constraint unq_field1_field2 unique(field1, field2) As with other databases, this is almost exactly equivalent to creating an index. The difference is that the constraint is named -- which can be

Access informix using C# inside docker container

我怕爱的太早我们不能终老 提交于 2019-12-08 02:15:21
问题 I am working on migrating a NET application that accesses an Informix database so that it can run in a Docker container. I have done a POC and when I run it on my local machine it works correctly. But when I want to run the same application inside a container, an exception is thrown: Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'db2app.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at IBM.Data.DB2.UnsafeNativeMethods.DB232

How can I su from root to db2inst1 and invoke a SQL script, in one line?

蹲街弑〆低调 提交于 2019-12-08 01:31:47
问题 How can I su from root to db2inst1 and invoke a SQL script all in 1 line? I am thinking about something like this: su db2inst1 | db2 CONNECT TO myDatabase USER db2inst1 USING mypw; db2 -c -i -w -td@ -f /tmp/deploy/sql/My.sql | exit; Any ideas? 回答1: You can use the -c or --command=<command> option to execute a command with su . In your case, something like this: su -c 'db2 CONNECT TO myDatabase USER db2inst1 USING mypw; db2 -c -i -w -td@ -f /tmp/deploy/sql/My.sql' db2inst1 回答2: if using