09-02-2007
Aggregate values in a file & compare with sql output
Hi,
I have a file containing the following data:
junk123junk723itemcode001qty01price10total10junkjunk
junk123junk723itemcode002qty02price10total20junkjunk
..
..
..
could be 5000+ lines
I have an algo and need a code to implement this:
1. Linecount = wc -l (should give 5000)
2. For i = 1 to linecount (loops 5000 times)
3. pick up the value from total and aggregate them ie 10 + 20 = 30
4. This should be done fr all the lines and the total aggregated total in a variable called TOTAL.
5. The total aggregate should be compared against a database query ie:
total_database=`sqlplus -s un/pw@TNS_NAME<<END
set pagesize 0
set feedback off
set heading off
set echo off
set verify off
select total from results;
exit;
END`
echo "$total_database"
If $ total_database = $TOTAL then pass, else echo fail..
Can someone kindly help me out with this.I hope I gave in enough info..
Thanks and Regards,
Ron.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
how can I write a small script to run the following statement and output the result into check_result.txt
select /*+RULE*/ tapname from typetbl where tapname like 'AA%' and rejectcode=9;
Normally, I just type sql and get into SQL> (2 Replies)
Discussion started by: happyv
2 Replies
2. Shell Programming and Scripting
Hi All,
I have a file abc.txt with 3 fileds. Field 3 contains amount. Also at the end of file there is a Footer record, which contains total amount.
I need to calculate total sum of these fields & need to compare it with footer record. I have serched in thi site, many has asked this... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies
3. Shell Programming and Scripting
Hi every body
i have a problem need help urgently
file 1 (approx 200K entries)
aaaaa
bbbb
cccccc
dddd
ffff
file 2 (approx 2 million entries)
aaaaa,1,ee,44,5t,6y,
bbbb,3,ff,66,5u,8r,
cccccc, .....
dddd, .....
eeeeee, .....
ffff, ...... (5 Replies)
Discussion started by: The_Archer
5 Replies
4. Shell Programming and Scripting
file 1:
70|236|PPS|0501011818|mms|20090706|001452|00000024|2|0000000000000000|00000|0000000000|0000000000|40948000|1
70|236|PPS|0501020076|mms|20090705|204408|00000019|2|0000000000000000|00000|0000000000|0000000000|40947930|1... (3 Replies)
Discussion started by: magedfawzy
3 Replies
5. Shell Programming and Scripting
output of Unix & sql in same file
hi all,
am working on shell script, i need to format data in such a way
that both my Unix commands output & my sql output should be in a same file.
I am able to redirect both output in separate files.
for sql output: sqlplus -s... (6 Replies)
Discussion started by: bankimmehta
6 Replies
6. Shell Programming and Scripting
hi,
Could anyone tell me how to pass the output values of the PL/SQL procedure to Shell script and how to store that values in a shell script variable...
Thanks in advance... (5 Replies)
Discussion started by: funonnet
5 Replies
7. Shell Programming and Scripting
Hi all
I am trying to scan a file that has 3 columns:
red blue 123351
red blue 848655
red blue 126354
red blue 023158
black white 654896
red blue 650884
I want an output that sums the rows that have matching columns 1 and 2 :wall:
red blue has 5 entries
black white has 1 entry
... (4 Replies)
Discussion started by: reno
4 Replies
8. Shell Programming and Scripting
- I have two files (File 1 and File 2) and the contents of the files are mentioned below.
- I am trying to compare the values of Column1 of File1 with Column1 of File2. If a match is found, print the corresponding value from Column2 of File1 in Column5 of File2.
- I tried to modify and use... (10 Replies)
Discussion started by: Santoshbn
10 Replies
9. Shell Programming and Scripting
Hi All,
I have a requirement where I need to compare 2 files & if the values in the files match, it should proceed, else exit the script without proceeding further.
For e.g : Scenario 1
In this case, the script should exit without proceeding further.
Scenario 2
In this case, the script... (7 Replies)
Discussion started by: dsfreddie
7 Replies
10. UNIX for Dummies Questions & Answers
hey i am using this code to connect to sql , store the value in variable and then
compare it with another variable after some time by executing the same query
but the desired result is not coming
#!/bin/bash
val=$(sqlplus -s rte/rted2@rel76d2 <<ENDOFSQL
set heading off
set feedback off... (11 Replies)
Discussion started by: ramsavi
11 Replies
LEARN ABOUT DEBIAN
rdf::query::algebra::aggregate
RDF::Query::Algebra::Aggregate(3pm) User Contributed Perl Documentation RDF::Query::Algebra::Aggregate(3pm)
NAME
RDF::Query::Algebra::Aggregate - Algebra class for aggregate patterns
VERSION
This document describes RDF::Query::Algebra::Aggregate version 2.908.
METHODS
Beyond the methods documented below, this class inherits methods from the RDF::Query::Algebra class.
"new ( $pattern, @groupby, $alias =" [$op => $col] )>
"new ( $pattern, @groupby, expressions =" [ $alias => [$op, \%options, @cols] ] )>
Returns a new Aggregate structure. Groups by the named bindings in @groupby, and returns new bindings for the named $alias for the
operation $op on column $col.
$op may be one of: COUNT, MIN, MAX, SUM.
"construct_args"
Returns a list of arguments that, passed to this class' constructor, will produce a clone of this algebra pattern.
"pattern"
Returns the aggregates pattern.
"groupby"
Returns the aggregate's GROUP BY binding names.
"ops"
Returns a list of tuples as ARRAY refs containing "$alias, $op, @cols".
"sse"
Returns the SSE string for this algebra expression.
"as_sparql"
Returns the SPARQL string for this algebra expression.
"as_hash"
Returns the query as a nested set of plain data structures (no objects).
"type"
Returns the type of this algebra expression.
"referenced_variables"
Returns a list of the variable names used in this algebra expression.
"potentially_bound"
Returns a list of the variable names used in this algebra expression that will bind values during execution.
"definite_variables"
Returns a list of the variable names that will be bound after evaluating this algebra expression.
AUTHOR
Gregory Todd Williams <gwilliams@cpan.org>
perl v5.14.2 2012-01-31 RDF::Query::Algebra::Aggregate(3pm)