Sponsored Content
Top Forums Shell Programming and Scripting Need help with Isql record count Post 302096784 by johnu122 on Saturday 18th of November 2006 11:31:09 AM
Old 11-18-2006
Quote:
Originally Posted by shashikandi
The reason is sql returns like this if there are no matching records.

column1 column2 column3 ...
------------------------------------------------------
(0 rows affected)

The reccnt=`wc -l tmp_isql.status` always returns more than 0.

May be you can try this.
recount='cat tmp_isql.status |awk 'NR >3' |grep -v - | grep -v return'

if [$recount != "(0 rows affected)"]
message="no records returned"
echo $message>>ss_pto.status
else
cat tmp_isql.status>>ss_pto.status

mailx -s"SS PTO" -senders email reciepents email < ss_pto.status

Here change ' NR>3' according to the number of lines for columns headings

Hope this piece of code is useful to you.
Thanks I got it to work just had one trouble and that was the variable $recount ended up having a carriage return in it so the compare kept failing. I ended up writing it to a file then using the file results. I am not sure if there is a better or easier way but here is what I did.
Code:
recount='cat tmp_isql.status |awk 'NR >1' |grep -v - | grep -v return'

echo $recount>temprecount
recount2=`cat temprecount`

if ["$recount2" = "(0 rows affected)"]
message="no records returned"
echo $message>>ss_pto.status
else
cat tmp_isql.status>>ss_pto.status

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to count the record count in an EBCDIC file.

How do I get the record count in an EBCDIC file on a Linux Box. :confused: (1 Reply)
Discussion started by: oracle8
1 Replies

2. Shell Programming and Scripting

record count

i have a file named file_names.dat where there are several files along with their path. exp: /data1/dir1/CTA_ACD_20071208.dat /data1/dir1/CTA_DFG_20071208.dat i want to write a script which will create a csv file with the name of the file and record count of that file the output file... (4 Replies)
Discussion started by: dr46014
4 Replies

3. Shell Programming and Scripting

replaying a record count with another record count

i use unix command to take the record count for a file1 awk 'END{print NR}' filename i already have a file2 which conatin the count like ... .. rec_cnt=100 .. .. I want to replace the record in the file2 using the record i take from file1. suggest me some simple ways of doing it... (2 Replies)
Discussion started by: er_zeeshan05
2 Replies

4. Shell Programming and Scripting

Validate record count

Hi all How to verify the number of records in case of delimited file, If the file has records. And then if it is not equal to mentioned no. of records, email is triggered and file is moved to bad directory path. Example ----- input file = a.txt bad directory path : /usr/bin/bad (6 Replies)
Discussion started by: balaji23_d
6 Replies

5. Shell Programming and Scripting

Character count per record

I have a flat file. How can i retrive the character count per record in whole file. Can anybody assist me on this Cheers (9 Replies)
Discussion started by: subrat
9 Replies

6. Shell Programming and Scripting

How to assign record count output of isql to a shell variable ?

isql select count(*) from Table eof How to assign record count output of isql query to a shell variable ? (4 Replies)
Discussion started by: vikram3.r
4 Replies

7. UNIX for Dummies Questions & Answers

Reduce the count on the 98 record by 2,

recod,amount,noofaccount,count 98,+00000187865779787,00319,000000640/ 99,+00000187865779787,00001,000000642/ thsi is my input file my question is 1) Reduce the count on the 98 record by 2 (6 Replies)
Discussion started by: sgoud
6 Replies

8. Shell Programming and Scripting

Validating the record count

Hi , I am having a text file with several records., it has a header record and trailer record. The header record has the number of rows (records) found in the text file and time-stamp. The footer record has the total number of records ( along with the header and trailer., Suppose: wc -l... (4 Replies)
Discussion started by: cratercrabs
4 Replies

9. Shell Programming and Scripting

count of record in files

Hi all, I have written a scripts which count number of lines in all the files in a directory and write in a text file. I don't know how to format it while writing. OS suns solaris 10 my scripts is as below for i in /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/RIO_02-Aug-2012/ *.LOG do echo... (11 Replies)
Discussion started by: guddu_12
11 Replies

10. UNIX for Dummies Questions & Answers

Need record count on every 30 minute

We have the below records where we need record count of every 30 minute like 00:01 to 00:30 so in that we will have 48 record count in 24 hrs , and also we need sum of record count from 00:01 to 23:30. Please find sample data as well. 00:01 21 00:02 23 00:03 34 00:04 34 00:05 30... (10 Replies)
Discussion started by: nadeemrafikhan
10 Replies
PG_GET_RESULT(3)														  PG_GET_RESULT(3)

pg_get_result - Get asynchronous query result

SYNOPSIS
resource pg_get_result ([resource $connection]) DESCRIPTION
pg_get_result(3) gets the result resource from an asynchronous query executed by pg_send_query(3), pg_send_query_params(3) or pg_send_exe- cute(3). pg_send_query(3) and the other asynchronous query functions can send multiple queries to a PostgreSQL server and pg_get_result(3) is used to get each query's results, one by one. PARAMETERS
o $connection - PostgreSQL database connection resource. RETURN VALUES
The result resource, or FALSE if no more results are available. EXAMPLES
Example #1 pg_get_result(3) example <?php $dbconn = pg_connect("dbname=publisher") or die("Could not connect"); if (!pg_connection_busy($dbconn)) { pg_send_query($dbconn, "select * from authors; select count(*) from authors;"); } $res1 = pg_get_result($dbconn); echo "First call to pg_get_result(): $res1 "; $rows1 = pg_num_rows($res1); echo "$res1 has $rows1 records "; $res2 = pg_get_result($dbconn); echo "Second call to pg_get_result(): $res2 "; $rows2 = pg_num_rows($res2); echo "$res2 has $rows2 records "; ?> The above example will output: First call to pg_get_result(): Resource id #3 Resource id #3 has 3 records Second call to pg_get_result(): Resource id #4 Resource id #4 has 1 records SEE ALSO
pg_send_query(3). PHP Documentation Group PG_GET_RESULT(3)
All times are GMT -4. The time now is 11:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy