Sponsored Content
Top Forums Shell Programming and Scripting Read input file and used it to SQL query Post 302954378 by RavinderSingh13 on Monday 7th of September 2015 09:28:24 AM
Old 09-07-2015
Quote:
Originally Posted by znesotomayor
Hi Sir RavinderSingh13,
thank you for your reply.
i got
awk: ^ syntax error
Please advise,
Thanks,
Hello znesotomayor,

on a Solaris/SunOS system, change awkto /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk.
If you doesn't have Solaris/SunOS then please let us know which os you have with complete error details, I
have bash and it works for me.

Code:
awk 'BEGIN{print "set pagesize 50000;" ORS "set feedback off;" ORS "set linesize 1000;" ORS "set numformat 99999999999999999999;" ORS "set pages 0" ORS "set lines 1000" ORS "set echo off" ORS "set trim on" > sql_input_file.sql} {print "select distinct a_no from ranges_log where a_no between " $1 " and " $2 ";" >> sql_input_file.sql}' Input_file
sqlplus -s test/testing@testbed < sql_input_file.sql

Thanks,
R. Singh

Last edited by RavinderSingh13; 09-07-2015 at 10:33 AM.. Reason: Corrected output SQL file name now.
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

unloading sql query to file

In unload to "/usr/home/data.012202" I wish to use a date variable as in unload to "/usr/home/data.`date`" for the file is that possible in a query to do, or will i need to add a mv command after the query to do it. I tried backquotes, , and () on `date` but didn't seem to work Thanks... (2 Replies)
Discussion started by: Link_02
2 Replies

2. UNIX for Dummies Questions & Answers

How do I use SQL to query based off file data?

This is basically what I want to do: I have a file that contains single lines of IDs. I want to query the oracle database using these IDs to get a count of which ones match a certain condition. the basic idea is: cat myfile | while read id do $id in select count(PC.ptcpnt_id) from... (4 Replies)
Discussion started by: whoknows
4 Replies

3. Shell Programming and Scripting

how to use data in unix text file as input to an sql query from shell

Hi, I have data in my text file something like this. adams robert ahmed gibbs I want to use this data line by line as input to an sql query which i run by connecting to an oracle database from shell. If you have code for similar scenario , please ehlp. I want the output of the sql query... (7 Replies)
Discussion started by: rdhanek
7 Replies

4. Shell Programming and Scripting

How to use sql data file in unix csv file as input to an sql query from shell

Hi , I used the below script to get the sql data into csv file using unix scripting. I m getting the output into an output file but the output file is not displayed in a separe columns . #!/bin/ksh export FILE_PATH=/maav/home/xyz/abc/ rm $FILE_PATH/sample.csv sqlplus -s... (2 Replies)
Discussion started by: Nareshp
2 Replies

5. 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

6. Shell Programming and Scripting

Read value from user and use it in Oracle SQL query

Guys can anyone just tell me whether i can pass a value(from UNIX SCRIPT) as an ARGUMENT in Oracle Query? e.g. echo "enter value" read value insert into tablename where col=$value /*something like this*/ (1 Reply)
Discussion started by: subodh.thakar
1 Replies

7. Shell Programming and Scripting

Need help to run sql query from a script..which takes input from a file

I need to run sql script from shell script which takes the input from a file and contents of file will be like : 12345 34567 78657 and query will be like : select seq_nbr from bus_event where event_nbr='12345'; select seq_nbr from bus_event where event_nbr='34567'; select seq_nbr... (1 Reply)
Discussion started by: rkrish
1 Replies

8. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

9. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

10. Shell Programming and Scripting

How do I read sql query into shell script?

Hello All, I'm trying to put together a shell script that will: 1. connect to an oracle database 2. execute a query 3. save the output to a csv file I know that I can execute the sqlplus -s user/pass @dbsid and get logged in. What I would like to do is have my query in a separate text... (9 Replies)
Discussion started by: bbbngowc
9 Replies
Class::DBI::AbstractSearch(3pm) 			User Contributed Perl Documentation			   Class::DBI::AbstractSearch(3pm)

NAME
Class::DBI::AbstractSearch - Abstract Class::DBI's SQL with SQL::Abstract::Limit SYNOPSIS
package CD::Music; use Class::DBI::AbstractSearch; package main; my @music = CD::Music->search_where( artist => [ 'Ozzy', 'Kelly' ], status => { '!=', 'outdated' }, ); my @misc = CD::Music->search_where( { artist => [ 'Ozzy', 'Kelly' ], status => { '!=', 'outdated' } }, { order_by => "reldate DESC", limit_dialect => 'LimitOffset', limit => 1 offset => 2 }); DESCRIPTION
Class::DBI::AbstractSearch is a Class::DBI plugin to glue SQL::Abstract::Limit into Class::DBI. METHODS
Using this module adds following methods into your data class. search_where $class->search_where(%where); Takes a hash to specify WHERE clause. See SQL::Abstract for hash options. $class->search_where(\%where,\%attrs); Takes hash reference to specify WHERE clause. See SQL::Abstract for hash options. Takes a hash reference to specify additional query attributes. Class::DBI::AbstractSearch uses these attributes: o order_by Array reference of fields that will be used to order the results of your query. o limit_dialect Scalar, DBI handle, object class, etc. that describes the syntax model for a LIMIT/OFFSET SQL clause. Please see SQL::Abstract::Limit for more information. o limit Scalar value that will be used for LIMIT argument in a query. o offset Scalar value that will be used for OFFSET argument in a query. Any other attributes are passed to the SQL::Abstract::Limit constructor, and can be used to control how queries are created. For example, to use 'AND' instead of 'OR' by default, use: $class->search_where(\%where, { logic => 'AND' }); AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net> with some help from cdbi-talk mailing list, especially: Tim Bunce Simon Wilcox Tony Bowden This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Class::DBI, SQL::Abstract, SQL::Abstract::Limit perl v5.10.0 2009-07-21 Class::DBI::AbstractSearch(3pm)
All times are GMT -4. The time now is 09:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy