How to avoid locks while loading database through UNIX script.?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to avoid locks while loading database through UNIX script.?
# 1  
Old 10-11-2013
How to avoid locks while loading database through UNIX script.?

Hi,

I have the following requirement:

I have load_cdr as main scriptwhich loads all the file records into vertica database through unix script. But there are two files which try to update same table..n thats y my script is getting failed...

Can any1 give me some logic how to over come this error..i need to lock the table if one file is getting loaded( i guess this is be default as when ever we apply update automatically it locks the table) and then if any other file try to update that same table..instead of fail attempt that second file should waut until first file gets loaded completely...

i need to inherit these changes in my load_cdr main script...can any1 provide input on this..Smilie

Thanks,
# 2  
Old 10-11-2013
Load you files sequentially when concerning a same object.
Try to see whether you can avoid splitting object across different files during the generation step.

People won't be able to help much if you don't give more clue about the code you use.
# 3  
Old 10-11-2013
well the script i am using is too big to post here....i am clear about my requirement the only thing i am not able to put that in unix code..

i want to add sm code in exisitng script where, if my script is running and reading all the files .. and if one file is getting loaded into table and say suppose sm other file also try to update the same table thn it shud go in sleep mode till that first file get loaded completely
# 4  
Old 10-11-2013
Concurent access issues are tricky things... I know since I had to write a module (cobol...) to get visual basic pro v3 work in concurrent mode using access DB in a Novell environment 20 years ago... Trust me, what ctsgnb has posted is by far the simplest or be prepared to spend a month of wrting and testing just for that...
# 5  
Old 10-11-2013
Each database use to have its own tools and/or method to load data.
I don't know those used by Vertica but it should be some, with their own requirements and constraints.
I would suggest to use the approach recommended by the editor of the product before trying to implement an home made solution.
Check Vertica's docs, pdf and red book about loading data and then, if you still encounter specific performance issue while loading, you could get help from specialised forum about this database. (At least that is how i would proceed)
# 6  
Old 10-11-2013
thanks ctsgnb ..

well i figured something like..i can use lock file property of unix on the first file and if second files tries to load and lock file exists i will make my script to go in sleep mode...

Now prob is how can i give sleep command if i dont know how much time it wud require to finsh first file loading..is there any option with sleep command where i can give some condition instead of giveing some definite time..
Or how about i run one loop and check the lock file in every five seconds...jus a wild guess...any input on this
# 7  
Old 10-11-2013
If you are referring to the wait command use with $!

see for example thread https://www.unix.com/shell-programmin...y-solaris.html ok you may run on another unix but you may have some equivalence
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix script for removing the footer from the datafile while loading into externaltable using sqlload

Hi, Can you please tell me the Unix shell script for removing footer from the datafile while loading into external table using sqlloader we will be skipping the header like this while creating the table organization external ( type oracle_loader default directory directoryname... (5 Replies)
Discussion started by: srikanth_sagi
5 Replies

2. Shell Programming and Scripting

Script to report database home in unix

Hello: I am trying to build a ksh shell script which would summarize space occupied by "product" directory under /u*/app/oracle and summarize and report the total size occupied by it in one server. Environment is this... HP UNIX 11i Korn Shell some thing like ... (1 Reply)
Discussion started by: Sam1974
1 Replies

3. Shell Programming and Scripting

Help with loading data from DB2 database to CSV file

Hi everyone!! I need help regarding this. How can we load data from DB2 Database tables into a Comma Separated File? I also have another Question? Using Shell scripting, Is it easy to read Data from a table or from a text file? It is very urgent for me. Please help me out guys. ... (1 Reply)
Discussion started by: ss3944
1 Replies

4. UNIX for Dummies Questions & Answers

data is seen as NULL after loading into database

hello, when I load a data from text file all the values become NULL in the table. Please help me with this problem. Thanks sheen (15 Replies)
Discussion started by: sheen
15 Replies

5. Shell Programming and Scripting

Database Connection test in unix Script

i have a unix script that gives me the sysdate from the database EDNAMID.WORLD.What i want my script to do the following 1) Establish a database connection 2) if database connection is successfull then echo the message "Connected" 3) put the o/p of the Sql query in a spool file 4) then... (3 Replies)
Discussion started by: ali560045
3 Replies

6. Shell Programming and Scripting

unix script for loading a data from a file into database

Hi All, I am trying to load a data from a files in a particular directory to a database.. cd $SCC isql metdb >> ${LOGDATA}/LOAD.LOG < ! load from "${LDATA}/${FORM}.ld" insert into $LOADTABLE ! But it's showing the error "syntax error at line 46 : `<<' unmatched" Can u plz help me... (5 Replies)
Discussion started by: grajesh_955
5 Replies

7. Shell Programming and Scripting

how will i connect postgres database from unix shell script

I have got the solution so just closing this issue. (3 Replies)
Discussion started by: jambesh
3 Replies

8. Shell Programming and Scripting

what is uses of unix shell script in database projects

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (2 Replies)
Discussion started by: alokjyotibal
2 Replies

9. Shell Programming and Scripting

Loading values into a MYSQL database

Where to start? Ok, I need to pick up a Worldpay exchange rates file from a url such as: https://select.worldpay.com/wcc/info?op=rates&instId=12345&op=rates-today the http response returns a exchange rates file with content-type "text/plain" content as below: #Exchange rates for... (2 Replies)
Discussion started by: kshelluser
2 Replies

10. Shell Programming and Scripting

getting dump from database by UNIX script

can i make a dump to happen from my script in a databse.and download that dump. I want to schedule a script i cron so that i will make a dump and download that inot my server. (1 Reply)
Discussion started by: arunkumar_mca
1 Replies
Login or Register to Ask a Question