Sponsored Content
Full Discussion: Sql query output count
Top Forums Shell Programming and Scripting Sql query output count Post 303033702 by bmk123 on Wednesday 10th of April 2019 10:39:54 AM
Old 04-10-2019
Sql query output count

Hi Team,
below sql rerturn 20 records, the result set i am going to assign to one variable and it showing count is 1.
and i don't use count() in sql query... based on count, i need to fail the script.

No_of_step=`echo ${g_count} | wc -l`

Code:
function gf_count()
{
g_count=`sqlplus -s scott/scott@orcl << !END_SQL
whenever oserror exit 99
whenever sqlerror exit 99
set echo off
set heading off
set feedback off
set pagesize 0
set line 500
select ename||sal from emp
/
exit
!END_SQL`
}

Can you help me on this one ?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to store the sql query's output in a variable

Hi, My requirement is : We are calling an sql statement from a UNIX session, and fetching data into some variables from a table .. now we are unable to access these variables from outside the SQL part. Please let me know how can I achieve this. Can you please share a code snippet which... (4 Replies)
Discussion started by: venkatesh_sasi
4 Replies

2. Shell Programming and Scripting

need help in reading a output of a sql query in unix script

i'm used a sql query in a unix script to get the information from table. but unable to extract the output which i need. Any help with logic will be greatly appreciated. my sql query provide output some thing like this - col1 col2 count ---- ---- ------ A B 10 c D 6 e... (8 Replies)
Discussion started by: pharos467
8 Replies

3. Shell Programming and Scripting

redirecting sql query output to a file

Hi, I am executing sql files in my unix shell script. Now i want to find whether its a success or a failure record and redirect the success or failure to the respective files. meaning. success records to success.log file failure record to failure.log file. As of now i am doing like... (1 Reply)
Discussion started by: sailaja_80
1 Replies

4. UNIX for Advanced & Expert Users

Output the SQL Query result to a File

Hello Guys, This message is somewhat relates with last thread. But I need to re-write thing. I start over a little. I am stuck now and need your help. Here is my script- #! /bin/ksh export ORACLE_HOME=/opt/oracle/app/oracle/product/9.2 /opt/oracle/app/oracle/product/9.2/bin/sqlplus -s... (5 Replies)
Discussion started by: thepurple
5 Replies

5. Shell Programming and Scripting

How to store the sql query output into txt file?

Hi I want ot save SQL query result in one txt file. for that i have written one code line sqlplus -s $dbstring @/usr/local/bin/sched/nightly_Cronjob/exec_123.sql >> /usr/local/bin/sched/nightly_Cronjob/result.txt but it is not working . database : Oracle so please advice me how can i... (7 Replies)
Discussion started by: Himanshu_soni
7 Replies

6. Shell Programming and Scripting

How to remove characters for sql query output?

Hi, my sql query return below value for " $SQL_OPN_AMT " CUSTCODE OH OHOPNAMT_GL OHREFNUM -------------------------------- -- ----------- ------------------------------ OHENTDATE FCC --------- --- 1.1072256 IN 74.85 000072061 0 01-MAY-13 MVR 1.1072256 IN 751.72 0000744751 01-JUN-13 MVR... (3 Replies)
Discussion started by: ranabhavish
3 Replies

7. Shell Programming and Scripting

SQL Query in Shell Script output formatting

Hi All, #!/bin/ksh call_sql () { sql=$1 sqlplus -s $sqlparam_sieb <<EOF SET ECHO OFF; SET NEWPAGE NONE; SET SQLBL OFF; SET VERIFY OFF; SET LINESIZE 2000; SET... (2 Replies)
Discussion started by: Kevin Tivoli
2 Replies

8. Solaris

SQL QUERY to Table Output

Hi I am trying to run sql query from solaris in csh script and send the output to email. Below is my sql query select p.spid,se.program seprogram, se.machine, se.username, sq.sql_text,sq.retrows from v$process p inner join v$session se on p.addr = se.paddr inner join ( select... (2 Replies)
Discussion started by: tharmendran
2 Replies

9. Shell Programming and Scripting

How to Assign the Output of an SQL Query to a Variable?

Hi iam new to shell scripting how to declare variables as redshift query and I have to compare two counts by using if condition . ex:count=select count(*) from prd; select count(*) from prd; select count(*) from tag; can any one help me . Please use CODE tags when displaying... (1 Reply)
Discussion started by: sam526
1 Replies

10. Shell Programming and Scripting

Shell script appending output of sql query

I am writing the following script to create the file v_out.txt. sqlplus -s /nolog << EOF CONNECT scott/tiger@orcl; whenever sqlerror exit sql.sqlcode; set newpage 0; SET PAGESIZE 0; SET ECHO OFF; SET FEEDBACK OFF; SET HEADING OFF; SET VERIFY OFF; SET LINESIZE 100; set tab off; set... (7 Replies)
Discussion started by: itzkashi
7 Replies
dspam_maintenance(1)						   User Commands					      dspam_maintenance(1)

NAME
dspam_maintenance - remove old signatures and unimportant tokens from the DSPAM storage backend SYNOPSIS
dspam_maintenance [--profile=PROFILE] [--logdays=no_of_days] [--signatures=no_of_days] [--neutral=no_of_days] [--unused=no_of_days] [--hapaxes=no_of_days] [--hits1s=no_of_days] [--hits1i=no_of_days] [--without-sql-purge] [--with-sql-automatization] [--with-sql-autoup- date] [--purgescriptdir=directory] [--with-all-drivers] [--verbose] DESCRIPTION
dspam_maintenance is used to remove old signatures/tokens and unimportant tokens from the DSPAM storage backend and purge old log entries in user and system logs. This script can be called from the command line or run from within cron. Either add a line in your crontab or add this script in your cron.{hourly,daily,weekly,monthly}. Running this script every hour might not be the best idea but it's your decision if you want to do so. OPTIONS
--profile=PROFILE Specify a storage profile from dspam.conf. The storage profile selected will be used for all database connectivity. NOTE: See dspam.conf for more information. --logdays=no_of_days All log entries older than no_of_days days will be removed. NOTE: Default is 31 days. (for more info: man dspam_logrotate) --signatures=no_of_days All signatures older than no_of_daysdays will be removed. NOTE: Default value is set by the PurgeSignatures option in dspam.conf, if this option is not set, the default value is 14 days. This option is only used for the Hash driver. --neutral=no_of_days Deletes all tokens from the target users database whose probability is between 0.35 and 0.65 (fairly neutral, useless data). NOTE: Default value is set by the PurgeNeutral option in dspam.conf, if this option is not set, the default value is 90 days. --unused=no_of_days Remove stale tokens which have not been used for a long period of time. NOTE: Default value is set by the PurgeUnused option in dspam.conf, if this option is not set, the default value is 90 days. --hapaxes=no_of_days Remove tokens with a total hit count below 5 (which will be assigned a hapaxial value by DSPAM). NOTE: Default value is set by the PurgeHapaxes option in dspam.conf, if this option is not set, the default value is 30 days. --hits1s=no_of_days Remove tokens with a single SPAM hit. NOTE: Default value is set by the PurgeHits1S option in dspam.conf, if this option is not set, the default value is 15 days. --hits1i=no_of_days Remove tokens with a single INNOCENT hit. NOTE: Default value is set by the PurgeHits1I option in dspam.conf, if this option is not set, the default value is 15 days. --without-sql-purge Do not use SQL based purging. Only run dspam_clean. NOTE: Default is off (aka: use SQL based purging). --with-sql-optimization Run VACUUM (for PostgreSQL/SQLite) and/or OPTIMIZE (for MySQL). NOTE: Default is off (aka: do not use optimizations). --with-sql-autoupdate Run SQL based purging with purge day values passed to dspam_maintenance. NOTE: Default is off (aka: do not attempt to modify SQL instructions). --purgescriptdir=directory Space separated list of directories where to search for SQL files used for the SQL based purging. --with-all-drivers Process all installed storage drivers (not just the active driver). NOTE: Default is true (aka: process all installed drivers). --verbose Verbose output while running maintenance script. EXIT VALUE
0 Operation was successful. other Operation resulted in an error. Run the script with --verbose to get more information about error. COPYRIGHT
Copyright (C) 2002-2010 DSPAM Project All rights reserved. For more information, see http://dspam.sourceforge.net. SEE ALSO
dspam(1), dspam_admin(1), dspam_clean(1), dspam_crc(1), dspam_dump(1), dspam_logrotate(1), dspam_merge(1), dspam_stats(1), dspam_train(1) dspam_maintenance Apr 26, 2010 dspam_maintenance(1)
All times are GMT -4. The time now is 08:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy