473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

COBOL DB2 V8 Mainframe - moving data from one table to another

Hello to all.

This is my first post. I have received many answers to questions in the past, but this one I cannot find.

We need to move data from production tables to archive tables. I wrote this:
[code]
EXEC SQL
INSERT INTO table1_archive
SELECT *
FROM table1_production
WHERE table1_nbr = :some number
END-EXEC. [code]

Which worked, while the tables were identical. Now a DATE column defined as “NOT NULL WITH DEFAULT has been added to the archive tables in the first column.

Now I am getting SQLCODE=-408 ( THE VALUE IS NOT COMPATIBLE WITH THE DATA TYPE OF ITS TARGET.)

Is there a way to skip this first column, or say to start at column 2?

Any ideas? we have lots of tables at this time to be archived, each having 1 to many rows.

I truly appreciate the knowledge and expertise that all of you bring to this forum. Thank you!
Jun 28 '07 #1
6 9412
r035198x
13,262 8TB
Hello to all.

This is my first post. I have received many answers to questions in the past, but this one I cannot find.

We need to move data from production tables to archive tables. I wrote this:
[code]
EXEC SQL
INSERT INTO table1_archive
SELECT *
FROM table1_production
WHERE table1_nbr = :some number
END-EXEC. [code]

Which worked, while the tables were identical. Now a DATE column defined as “NOT NULL WITH DEFAULT has been added to the archive tables in the first column.

Now I am getting SQLCODE=-408 ( THE VALUE IS NOT COMPATIBLE WITH THE DATA TYPE OF ITS TARGET.)

Is there a way to skip this first column, or say to start at column 2?

Any ideas? we have lots of tables at this time to be archived, each having 1 to many rows.

I truly appreciate the knowledge and expertise that all of you bring to this forum. Thank you!
Moved to DB forum.
P.S Welcome to TSDN
Jun 28 '07 #2
You might try specifying the actual field names in your INSERT and SELECT statements:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO myarchive (field2, field3, field4)
  2. SELECT field1, field2, field3 FROM mytable;
  3.  

This worked for me in a sample test I just tried using the CLP.


Rick
Jun 28 '07 #3
I am hoping to avoid listing all the column names. But thanks!
Jun 29 '07 #4
I am hoping to avoid listing all the column names. But thanks!
I'm not sure you can easily do that. Perhaps somebody else can provide a better answer for you.

One thing you could do -- based on your initial statement that the new column in each table is a DATE or TIMESTAMP field, I'm guessing what you're looking for is adding the date that the table was archived. You could achieve the same effect by not adding the column until after the data has been moved into the archive table.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO myarchive SELECT * FROM mytable;
  2. ALTER TABLE ADD date_archived TIMESTAMP default CURRENT_TIMESTAMP;
  3.  

Rick
Jun 29 '07 #5
This is going to be an ongoing process; therefore, altering the tables each time would not be a good solution. I appreciate all suggestions!
Jun 29 '07 #6
Snib
24
I seem too remember (and I could be completely wrong!) that when you are not identifying the rows DB2 attempts to add the value in the first column on the input table to the first column on the output table. It does not do anything clever like checking the if the columns are named the same. So the error message indicates that the first column on the live table is not of a compatible type with the archive table - probably stating the obvious but then my suggestion below tends to make a bit more sense!

You may want to try putting the date field at the end of the archive table and setting it to so the default is null. As new rows are added the table all the rows from the live table will be loaded correctly into the archive table and the date field is set to null.

If the date field is meant to track when the archive rows were added to the table you can then run an UPDATE query after you have copied the new rows into the table to set the date field to CURRENT DATE where the current value is NULL.

Regards

Snib
Jun 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Batista, Facundo | last post by:
People: I'm trying to convert my father from using COBOL to Python, :) One difficult thing we stuck into is how to read, from python, files written with COBOL. Do you know a module that...
2
by: Kalpana Shridhar | last post by:
I am on a project where I am converting COBOL to C++ on the mainframe. I am new to COBOL and have a lot of questions - any websites or any suggestions from experienced people will be really...
30
by: Stuart Turner | last post by:
Hi Everyone, I'm working hard trying to get Python 'accepted' in the organisation I work for. I'm making some good in-roads. One chap sent me the text below on his views of Python. I wondered...
7
by: Mythran | last post by:
No Cobol.Net yet? Wha?!? Anywho, hope someone is familiar enough with Cobol to help me out here. I have some files written by COBOL applications that contain COMP-3 fields (on a mainframe)...
13
by: EricJ | last post by:
hi i need to access cobol data files from .net, the files have no or .vix extention (i think thats a acucobol or something like that) (/me has completely no experience in cobol) i heard that...
3
by: schwartzenberg | last post by:
Dear friends, I have just run into a strange DB2 problem. Something i'd some of you would answer, if only shortly. My basic question is: How do i ensure 'insensitive' (ie static) cursors...
7
by: misha | last post by:
Hello. I was wandering if someone could explain to me (or point to some manual) the process of mapping the addresses of host variables by DB2. Especially I would like to know when DB2 decides to...
2
by: pompeyoc | last post by:
Hi, I am a newbie when it comes to stored procs and i would like to learn how to call a COBOL program from a stored procedure. The SP can either be an DB2 SQL SP or an external COBOL/DB2 SP. I...
0
by: kick2006 | last post by:
Hi guys: I am a mainframe cobol programmer, and now i need some helps. I want to write a cobol subroutine it can provide functions for accessing DB2. ex. there is a subroutine called...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.