Sponsored Content
Top Forums Shell Programming and Scripting Reading line by line from unix script Post 302406306 by chamajid on Monday 22nd of March 2010 01:48:47 PM
Old 03-22-2010
Not quite what I need.

Thanks for such a quick reply. What I am trying to do is put the parameter into the delete sql and run it. I am using the BTEQINF file to run the sql.

So my question is, how can I read the paramter value from fiscper.parm and run the DELETE SQL with correct tablename and number values.

Here is what I wrote:



Code:
while read -r tbl_name st_dt en_dt
do
     tbl_name=`cut -d";" -f1 /transfer/sap_fin/sap_rsync/cca/fiscper.parm`
     st_dt=`cut -d";" -f2 /transfer/sap_fin/sap_rsync/cca/fiscper.parm`
     en_dt=`cut -d";" -f3 /transfer/sap_fin/sap_rsync/cca/fiscper.parm`
     /upapps/inf/dev/scripts/bteqinf > /upapps/inf/dev/scripts/sap_bi_fin/findbt40;
     'DELETE FROM FINDBT40."$tbl_name" where fiscper between "$st_dt" and "$en_dt";'
     /upapps/inf/dev/scripts/bteqinf <<-!
done

What this script is doing is putting all the first column values into one

something like

DELETE FROM FIN427
FIN475
FIN474
FIN 476
where fiscper between 2010003
2010001
2010001
2010001

and 2010003
2010003
2010003
2010003


and I want it to be able to run the sql when I run the script.

DELETE FROM FINDBT40.FIN427 where fiscper between 2010003 and 2010003;

DELETE FROM FINDBT40.FIN475 where fiscper between 2010001 and 2010003;

DELETE FROM FINDBT40.FIN476 where fiscper between 2010001 and 2010003;

DELETE FROM FINDBT40.FIN474 where fiscper between 2010001 and 2010003;

edit by bakunin: please note that code-tags around code are a free-of-charge add-on of this forum. Don't be shy to use them yourself from now on.

Last edited by bakunin; 03-22-2010 at 05:24 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

reading a line into a variable in unix

hi... i need to open a file and read it line by line, and capture that it in to some variable and manipulate... i need to get a line in to a variable please help :confused: (1 Reply)
Discussion started by: lmadhuri
1 Replies

2. Shell Programming and Scripting

Reading a file line by line and processing for each line

Hi, I am a beginner in shell scripting. I have written the following script, which is supposed to process the while loop for each line in the sid_home.txt file. But I'm getting the 'end of file' unexpected for the last line. The file sid_home.txt gets generated as expected, but the script... (6 Replies)
Discussion started by: sagarparadkar
6 Replies

3. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

4. Shell Programming and Scripting

Reading line1 with line2 and line 2 with line 3 in unix

Hi, I have a requirement where i have to read a file line by line and see if the string(fixed postion 10 to 15 in the file) in line 2 is greater than string in line 1. I have used following code while read LINE1 do current_inv_no=$(echo "$LINE1" | cut -c 10-15) read... (2 Replies)
Discussion started by: chethanbg2010
2 Replies

5. Shell Programming and Scripting

Reading a line and the next line in a shell script

Hi, I'm trying to read a line and the next line in a shell script by executing the following code: for i in `seq 1 $numLines`; do line=$(sed -n '{$i}p' outputFile) echo $line done $numLines contanis the outputFile's number of lines. It doesn't work and I cannot... (8 Replies)
Discussion started by: JuanPerez
8 Replies

6. Shell Programming and Scripting

How to read a two files, line by line in UNIX script and how to assign shell variable to awk ..?

Input are file and file1 file contains store.bal product.bal category.bal admin.bal file1 contains flip.store.bal ::FFFF:BADC:CD28,::FFFF:558E:11C5,6,8,2,1,::FFFF:81C8:CA8B,::FFFF:BADC:CD28,1,0,0,0,::FFFF:81C8:11C5,2,1,0,0,::FFFF:81DC:3111,1,0,1,0 store.bal.... (2 Replies)
Discussion started by: veeruasu
2 Replies

7. Shell Programming and Scripting

Replace values in script reading line by line using sed

Hi all, Let's say I have a script calling for the two variables PA_VALUE and PB_VALUE. for pa in PA_VALUE blah blah do for pb in PB_VALUE blah blah do I have a text file with two columns of values for PA and PB. 14.5 16.7 7.8 9.5 5.6 3.6 etc etc I would like to read this... (7 Replies)
Discussion started by: crimsonengineer
7 Replies

8. UNIX for Dummies Questions & Answers

UNIX Help for reading line

Hi there, I am trying to read the content such that if there is 'adsmsext.dll', it will read everything from line one until it reads line 6 with 'C:' then it will terminate at line 5. 1. C:\WINDOWS\system32\adsmsext.dll NT AUTHORITY\Authenticated Users:R 2. ... (5 Replies)
Discussion started by: alvinoo
5 Replies

9. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies
NDB_DELETE_ALL(1)					       MySQL Database System						 NDB_DELETE_ALL(1)

NAME
ndb_delete_all - delete all rows from an NDB table SYNOPSIS
ndb_delete_all options DESCRIPTION
ndb_delete_all deletes all rows from the given NDB table. In some cases, this can be much faster than DELETE or even TRUNCATE TABLE. Usage ndb_delete_all -c connect_string tbl_name -d db_name This deletes all rows from the table named tbl_name in the database named db_name. It is exactly equivalent to executing TRUNCATE db_name.tbl_name in MySQL. The following table includes options that are specific to ndb_delete_all. Additional descriptions follow the table. For options common to most MySQL Cluster programs (including ndb_delete_all), see Options Common to MySQL Cluster Programs(1). Table 17.16. ndb_delete_all Options and Variables: MySQL Cluster NDB 7.2 +--------------------------+-----------------------------------+-------------------------------------+ |Format | Description | Added / Removed | +--------------------------+-----------------------------------+-------------------------------------+ | | Name of the database in which the | | | --database=dbname, | table is found | All MySQL 5.5 based releases | | | | | | -d | | | +--------------------------+-----------------------------------+-------------------------------------+ | | Perform the delete in a single | | | --transactional, | transaction (may run out of | All MySQL 5.5 based releases | | | operations) | | | -t | | | +--------------------------+-----------------------------------+-------------------------------------+ | | Run tup scan | | | --tupscan | | All MySQL 5.5 based releases | +--------------------------+-----------------------------------+-------------------------------------+ | | Run disk scan | | | --diskscan | | All MySQL 5.5 based releases | +--------------------------+-----------------------------------+-------------------------------------+ o --transactional, -t Use of this option causes the delete operation to be performed as a single transaction. Warning With very large tables, using this option may cause the number of operations available to the cluster to be exceeded. COPYRIGHT
Copyright (C) 1997, 2014, Oracle and/or its affiliates. All rights reserved. This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/. SEE ALSO
For more information, please refer to the MySQL Reference Manual, which may already be installed locally and which is also available online at http://dev.mysql.com/doc/. AUTHOR
Oracle Corporation (http://dev.mysql.com/). MySQL 5.5 01/30/2014 NDB_DELETE_ALL(1)
All times are GMT -4. The time now is 07:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy