records manupulation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers records manupulation
# 1  
Old 10-24-2007
records manupulation

I am sending the data in userfile and colfile from ksh script to pl/sql script
linto an array with this command

grep '[a-zA-Z]' $userfile |awk '{print "my_user_id("FNR") := '$SQL_QUOTE'"$1"'$SQL_QUOTE';"}' >> $SQL_TEMP_FILE

grep '^[0-9]\{1,10\}$' $colfile | awk '{print "my_col_id("NR") := "$1";"}' >> $SQL_TEMP_FILE



SQL_TEMP_FILE is the pl/sql script file

userfile has the below data
pinky
dolly

colfile has the below data
1198
1134
1165
1135

in pl/sql script with this command
grep '[a-zA-Z]' $userfile |awk '{print "my_user_id("FNR") := '$SQL_QUOTE'"$1"'$SQL_QUOTE';"}' >> $SQL_TEMP_FILE
I am able to send as


my_user_id(1) := 'pinky'
my_user_id(2) := 'dolly'

with this command
grep '^[0-9]\{1,10\}$' $colfile | awk '{print "my_col_id("NR") := "$1";"}' >> $SQL_TEMP_FILE
I am able to send as
my_col_id(1) := 1198;
my_col_id(2) := 1134;
my_col_id(3) := 1165;
my_col_id(4) := 1135;

but I am problem is if userfile has 1000 records
and colfile has 1000 records it will fill up my SQL_TEMP_FILE

in my pl/sql script I declared array as

TYPE t_user_id_tab IS TABLE OF VARCHAR2(1000) INDEX BY BINARY_INTEGER;
my_user_id t_user_id_tab;

so any one can suggest me any command to send like this

my_user_id := t_user_id_tab('pinky','dolly');
so that it looks better for 1000 records

thanks in advance
pinky










echo $SQL_A > $SQL_TEMP_FILE
grep '[a-zA-Z]' $userfile |awk '{print "my_user_id("FNR") := '$SQL_QUOTE'"$1"'$SQL_QUOTE';"}' >> $SQL_TEMP_FILE
grep '^[0-9]\{1,10\}$' $colfile | awk '{print "my_col_id("NR") := "$1";"}' >> $SQL_TEMP_FILE
echo $SQL_C >> $SQL_TEMP_FILE
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separate records of a file on 2 types of records

Hi I am new to shell programming in unix Please if I can provide help. I have a file structure of a header record and "N" detail records. The header record will be the total number of detail records I need to split the file in 2: One for the header Another for all detail records Could... (1 Reply)
Discussion started by: jamcogar
1 Replies

2. Shell Programming and Scripting

awk for string manupulation

Hi All, I have one file with two columns separated by tab. I need to search for second column value of this file in the 5 column of another file. If the match is found replace the 5th column of second file with entire row of the first file. e.g. file1 123 D.abc 234 D.rde 4563 ... (2 Replies)
Discussion started by: alok2082
2 Replies

3. Shell Programming and Scripting

How to do Date Manupulation in Korn Shell?

Hi All, I need to find the date 19days back from the current date: eg: if today is 17 March 2013 then the output should be : 26 Feb 2013 Can i do this using date command in Korn Shell? And also if i need future 15 days date from current date, how to that? Any help appreciated :) ... (3 Replies)
Discussion started by: Arun Mishra
3 Replies

4. Shell Programming and Scripting

CDR manupulation

Hello Friends, I need to examine a huge CDR file according to a complex (at least for me) condition like below and i couldnt write anything :( In CDR file there are more than hundreds of fields, I need to print the rows which matches the below condition: while $13 field of subsequent... (9 Replies)
Discussion started by: EAGL€
9 Replies

5. Shell Programming and Scripting

Compare two files with different number of records and output only the Extra records from file1

Hi Freinds , I have 2 files . File 1 |nag|HYd|1|Che |esw|Gun|2|hyd |pra|bhe|3|hyd |omu|hei|4|bnsj |uer|oeri|5|uery File 2 |nag|HYd|1|Che |esw|Gun|2|hyd |uer|oi|3|uery output : (9 Replies)
Discussion started by: i150371485
9 Replies

6. UNIX for Dummies Questions & Answers

Grep specific records from a file of records that are separated by an empty line

Hi everyone. I am a newbie to Linux stuff. I have this kind of problem which couldn't solve alone. I have a text file with records separated by empty lines like this: ID: 20 Name: X Age: 19 ID: 21 Name: Z ID: 22 Email: xxx@yahoo.com Name: Y Age: 19 I want to grep records that... (4 Replies)
Discussion started by: Atrisa
4 Replies

7. AIX

Rows manupulation using AWK or sed

Hi Everyon, I am stuck in a script.I have a file named file1.txt as given below: It contains 2 columns-count and filename. cat file1.txt count filename 100 A_new.txt 1000 A_full.txt 1100 B_new.txt 2000 B_full.txt 1100 C_new.txt 2000 C_full.txt ................... ..................... (10 Replies)
Discussion started by: rajsharma
10 Replies

8. Shell Programming and Scripting

Based on num of records in file1 need to check records in file2 to set some condns

Hi All, I have two files say file1 and file2. I want to check the number of records in file1 and if its atleast 2 (i.e., 2 or greater than 2 ) then I have to check records in file2 .If records in file2 is atleast 1 (i.e. if its not empty ) i have to set some conditions . Could you pls... (3 Replies)
Discussion started by: mavesum
3 Replies

9. Shell Programming and Scripting

Count No of Records in File without counting Header and Trailer Records

I have a flat file and need to count no of records in the file less the header and the trailer record. I would appreciate any and all asistance Thanks Hadi Lalani (2 Replies)
Discussion started by: guiguy
2 Replies

10. Shell Programming and Scripting

Date Manupulation

HI all, I am relatively new to Unix Shell Scripts ... I want to know how u can calculate the differnece between the 2 dates. As if in Oracle by using SYSDATE u get current date and time .. How one can achieve it in Unix ? Thanks.. (1 Reply)
Discussion started by: dhananjaysk
1 Replies
Login or Register to Ask a Question