473,769 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to archive lots of records

hi all,

I have a table with lots of stock movements. ( stockmovements)
Once per year the user need to run a routine that move these records
into a table (history) and delete the movements from the original
table (stockmovements ).

My application is writtend in Borland Delphi. (interfacing with db2
with sql statements and stored procedure written in SQL)

I have tried different solutions but without success:

1) an "atomic" sql insert/delete of all movements. this is impossible
because of log size.
2) a loop of "atomic" sql insert/delete statements restricted to a
fixed number of records each time: but in my situation this take a
very long time.(4 hr) (i think because the "history" table is very
very large...and so..the insert statement take very long time)
3) a "manual" procedure of export to ixf...and load...: this is very
fast and i prefer this solution... but i can't provide this solution
like an interactive procedure for the user (i don't know how to do
these command of export / load in SQL)... moreover: i think i can't
launch these statements while users are connected to database...

Have you a solution for this kind of problem?
Maybe i have a bad design of my tables? (suggestions?)

(sorry for english mistakes)
JH

Jun 27 '08 #1
7 1550
On Apr 16, 12:31 pm, John Hopfield <Hopfi...@freem ail.itwrote:
hi all,

I have a table with lots of stock movements. ( stockmovements)
Once per year the user need to run a routine that move these records
into a table (history) and delete the movements from the original
table (stockmovements ).

My application is writtend in Borland Delphi. (interfacing with db2
with sql statements and stored procedure written in SQL)

I have tried different solutions but without success:

1) an "atomic" sql insert/delete of all movements. this is impossible
because of log size.
2) a loop of "atomic" sql insert/delete statements restricted to a
fixed number of records each time: but in my situation this take a
very long time.(4 hr) (i think because the "history" table is very
very large...and so..the insert statement take very long time)
3) a "manual" procedure of export to ixf...and load...: this is very
fast and i prefer this solution... but i can't provide this solution
like an interactive procedure for the user (i don't know how to do
these command of export / load in SQL)... moreover: i think i can't
launch these statements while users are connected to database...

Have you a solution for this kind of problem?
Maybe i have a bad design of my tables? (suggestions?)

(sorry for english mistakes)
JH
You don't mention your db2 version. If it is V9.x (unsure whether this
was already in 9.1) you can use range partitioning.

/Lennart
Jun 27 '08 #2
On 16 Apr, 14:41, Lennart <Erik.Lennart.J ons...@gmail.co mwrote:
>
You don't mention your db2 version. If it is V9.x (unsure whether this
was already in 9.1) you can use range partitioning.
Sorry.
I'm working with db2 8.2
Jun 27 '08 #3
John Hopfield wrote:
hi all,

I have a table with lots of stock movements. ( stockmovements)
Once per year the user need to run a routine that move these records
into a table (history) and delete the movements from the original
table (stockmovements ).

My application is writtend in Borland Delphi. (interfacing with db2
with sql statements and stored procedure written in SQL)

I have tried different solutions but without success:

1) an "atomic" sql insert/delete of all movements. this is impossible
because of log size.
2) a loop of "atomic" sql insert/delete statements restricted to a
fixed number of records each time: but in my situation this take a
very long time.(4 hr) (i think because the "history" table is very
very large...and so..the insert statement take very long time)
3) a "manual" procedure of export to ixf...and load...: this is very
fast and i prefer this solution... but i can't provide this solution
like an interactive procedure for the user (i don't know how to do
these command of export / load in SQL)... moreover: i think i can't
launch these statements while users are connected to database...

Have you a solution for this kind of problem?
Maybe i have a bad design of my tables? (suggestions?)

(sorry for english mistakes)
JH
Take a look at

http://www.optimsolution.com/

Larry E.
Jun 27 '08 #4
On Apr 16, 3:31 am, John Hopfield <Hopfi...@freem ail.itwrote:
hi all,

I have a table with lots of stock movements. ( stockmovements)
Once per year the user need to run a routine that move these records
into a table (history) and delete the movements from the original
table (stockmovements ).

My application is writtend in Borland Delphi. (interfacing with db2
with sql statements and stored procedure written in SQL)

I have tried different solutions but without success:

1) an "atomic" sql insert/delete of all movements. this is impossible
because of log size.
2) a loop of "atomic" sql insert/delete statements restricted to a
fixed number of records each time: but in my situation this take a
very long time.(4 hr) (i think because the "history" table is very
very large...and so..the insert statement take very long time)
3) a "manual" procedure of export to ixf...and load...: this is very
fast and i prefer this solution... but i can't provide this solution
like an interactive procedure for the user (i don't know how to do
these command of export / load in SQL)... moreover: i think i can't
launch these statements while users are connected to database...

Have you a solution for this kind of problem?
Maybe i have a bad design of my tables? (suggestions?)

(sorry for english mistakes)
JH
John.

Have a look at the "ADMIN_CMD" stored procedure. With it, you can do
something like the following within a stored procedure:

SET V_TS = CURRENT_TIMESTA MP;--

SET V_SP_CALL = 'CALL SYSPROC.ADMIN_C MD(''EXPORT TO /some_directory/
table.'||CHAR(V _TS)||'.ixf OF IXF messages /some_directory/
expTab.messages SELECT * FROM YOUR_TABLE WHERE'')';--

PREPARE S_SP_CALL FROM V_SP_CALL;--

EXECUTE S_SP_CALL;--

In my example above, I'm using dynamic SQL so that I can create a
unique name for the export file (based on a timestamp-valued variable
called V_TS). You may not need to do this, in which case your call to
ADMIN_CMD could be simpler, and may not even need to be dynamic.

Regards,

--Jeff
Jun 27 '08 #5
Lew
You might want to use the load from cursor functionality.

declare cursor mycur as select * from stockmovements where date <
xxxxxxx
load from mycur of cur insert into stockmovements_ history

You could also use this to "clean" out your table if you have the
space

create table stockmovements_ new
declare cursor mycur as select * from stockmovements where date >
xxxxxxx
load from mycur of cur insert into stockmovements_ new

drop table stockmovements
rename table stockmovements_ new to stockmovements

Not sure if my syntax is correctbut you get the idea



Jun 27 '08 #6
On 17 Apr, 13:02, Lew <seth...@yahoo. comwrote:
You might want to use the load from cursor functionality.

declare cursor mycur as select * from stockmovements where date <
xxxxxxx
load from mycur of cur insert into stockmovements_ history
...
very interesting...t hank you

but...i don't know if i can launch this kind of "script" from SQL or
from a SQL-Stored Procedure.

or using ADMIN_CMD( script )?

JH
Jun 27 '08 #7
John Hopfield wrote:
On 17 Apr, 13:02, Lew <seth...@yahoo. comwrote:
You might want to use the load from cursor functionality.

declare cursor mycur as select * from stockmovements where date <
xxxxxxx
load from mycur of cur insert into stockmovements_ history
...

very interesting...t hank you

but...i don't know if i can launch this kind of "script" from SQL or
from a SQL-Stored Procedure.
Unfortunately not - both are CLP commands, not SQL statements.
or using ADMIN_CMD( script )?
In version 8, no (8's ADMIN_CMD can only call DESCRIBE, EXPORT, PRUNE,
REORG, RUNSTATS, and UPDATE DB CFG). In version 9, sort of - you
couldn't do DECLARE CURSOR, but you could call ADMIN_CMD('EXPO RT...')
followed by ADMIN_CMD('LOAD ...'). The file used for the data would be
sat on the server by virtue of ADMIN_CMD (i.e. there wouldn't be lots
of network traffic involved).

Going back to your original post: are you unable to increase the log
size for some reason? (or possibly increase LOGSECOND to allow for
sufficient secondary logs to be allocated if/when necessary).

As for EXPORT+LOAD - you can use them both when others are connected to
the database - EXPORT in particular, which is effectively no different
to a normal query. However, LOAD does make the target table
inaccessible at least for the duration of the load (and possibly
afterward in the case of things like Check Pending states).
Cheers,

Dave.
Jun 27 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
2514
by: Dan Perl | last post by:
Here is a python feature that I would like: to be able to import modules from an archive like the jar files in Java. Maybe a regular tar file? Maybe a python specific file type, let's call it a 'par' file? It would be useful in packaging an python library. Sure, there's always the python packages, but a single file instead of a whole directory tree would be more convenient. I am particularly interested because I am working on a...
3
2000
by: Mike Turco | last post by:
I'm working on an application that imports and exports tons of CSV data, like 64,000 records per file, and six or seven files in a set. First off, by the tine I import a few hundred thousand records the database is _huge_. Like 500 meg, although the csv files are only 25 meg in total. When I compact the database its still 100meg. How do I keep the size down? Second, I did a manual delete of 300,000 records yesterday by doing a...
2
2403
by: indigo | last post by:
hi.. can someone suggest the best way to move data from one table to another. i'm trying to do this mainly due to my own limitations with regard to access. i have a form which has various cells on a continious form. at the end of each section there is a checkbox is it possible to create an event that if that check box is clicked then it moved that information from one table to another. the ovther table would be an archive table
5
2005
by: Comcast Newsgroups | last post by:
I'm trying to put together a macro that queries my cell phone call expense DB the selects records as of a specific Date that are not marked "Archive", prints a report, then marks the records "Archive". I've worked out the Queries and the report and even got them into the macro but I can't figure out how to set up the Macro to prompt for ONE Date. Instead I get a prompt for the Select Query date and then again for the Update Query date. ...
4
2207
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). The way I have it now is ennumerating through my XML file and for each record, running an INSERT INTO SQL statement to put the values in the database. Is this going to be okay with 50 or so records (hitting the database with 50 or so INSERT...
2
11480
by: Snonck | last post by:
Is is possible to recover deleted rows from a table from archive logs? For example, say you have a database with archive logging turned off. You create a table and populate it with records. You then reset the logs and place the database in archivelog mode. Then you delete from table;
2
5565
by: mkvenkit.vc | last post by:
Hello, I hope this is the right place to post a question on Boost. If not, please let me know where I can post this message and I will do so. I am having a strange problem with std::string as I am trying to read from a binary archive using Boost serialization. I am new to this, and it is possible that I have not understood the usage. In the code below, the string "faultblock" seems to be causing the problem. The code crashes in the ia...
1
1347
by: whitbacon | last post by:
I would like to have the ability to archive values in a lookup table. Take the following example lookup table luid, label, archive 1, green, No 2, red, No 3, blue, No select * from lookup table where archive = false
2
1883
by: Cara Murphy | last post by:
Hi, I am looking to use a button on an issues database that will allow me to archive issues that are closed, once all of the information has been updated. In this sense, I want the issue to be available for final input after it has been "closed", and use a command button to "delete" it (append the record to a table called ArchiveIssues and remove it from the table called Issues). Can you please advise what my options are to facilitate the...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10208
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9987
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8863
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3558
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2812
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.