...Here is my script that i ran- #! /bin/ksh export ORACLE_HOME=/opt/oracle/app/oracle/product/9.2 /opt/oracle/app/oracle/product/9.2/bin/sqlplus -s abc/abc@mydb <<EOF spool /mycount.txt set heading off set feedback 0 set verify off set auto off set echo off
@myquery.sql spool off !echo "Spool file generated..." clear buffer EXIT
EOF
...
You may want to try the OS's redirection capability here, instead of spool -
Unfortunately, you are still on Oracle 9i, which is an old version.
From Oracle 10g Release 2 onwards, the spool command comes with an "append" option that appends data to a spool file.
Prior to that version, the spool command creates the spool file every time it is invoked.
HTH,
tyler_durden
Last edited by durden_tyler; 11-12-2010 at 03:32 PM..
Hi,
I search all post...and no soluation about..if i would like to run a sql statement and output the result to txt file.
for example,
i usually run "sql" to logon the database and run select statement. Then I need to copy the output into the result.txt. Can I run the script to do this... (7 Replies)
Hi ,
I just found you while surfing for the string
'Redirecting sql select query output from within a shell script to txt file/excel file'
Could you find time sending me the code for the above question?
It'll be great help for me.
I have a perl file that calls the sql file... (1 Reply)
Hi Yogesh,
Lucky that i caught you online. Yeah i read about DBI and the WriteExcel module. But the server is not supporting these modules. It said..."Cannot locate DBI"..."Cannot locate Spreadsheet::WriteExcel"
I tried creating a simple text file to get the query output, but the... (1 Reply)
Hi All,
I want to format the result driven from the query into neat format.
For example pls find the below code,
#! /bin/sh
result='
sqlplus -s uname/passwrd@DBname
select no,name,address,ph_no, passport_no,salary,designation
from emp_table where salary>1000;
exit
EOF'
... (8 Replies)
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)
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)
Hi,
I never did this before... what I want to do is execute a SQL query from a unix script and redirect sql query's output to a flat file (comma separated one) without the header info (no column names). I would also want not to print the query's output to the screen.
snapshot of my script:... (13 Replies)
How to Get SQL query result to file in putty?
I have one SQL query and I want that query output to be redirected to the file.
uname -a
SunOS XXX 5.8 Generic_117350-58 sun4u sparc SUNW,Sun-Fire-480R
Please suggest. (7 Replies)
Dear community,
please help with a query on Oracle. I'm using SQLPlus (but with SQLDeveloper is the same) to accamplish a sinple query like:
select count(*) from ARCHIT_D_TB where (TYP_ID=22 OR TYP_ID=23) and SUB_TM like '%SEP%' and CONS=1234This is a very simple query that works perfect until... (5 Replies)
I am trying to write SQL query output into a .csv file. But in the output columns are displaying in different lines instead of coming in one line.
Main Code shell script:
this is my code:
#!/bin/bash
file="db_detail.txt"
. $file
rm /batch/corpplan/bin/dan.csv... (6 Replies)
Discussion started by: sandeepgoli53
6 Replies
LEARN ABOUT DEBIAN
webservice::solr::query
WebService::Solr::Query(3pm) User Contributed Perl Documentation WebService::Solr::Query(3pm)NAME
WebService::Solr::Query - Abstract query syntax for Solr queries
SYNOPSIS
my $query = WebService::Solr::Query->new( { foo => 'bar' } );
my $result = $solr->search( $query );
DESCRIPTION
WebService::Solr::Query provides a programmatic way to generate queries to be sent to Solr. Syntax wise, it attempts to be as close to
SQL::Abstract WHERE clauses as possible, with obvious exceptions for idioms that do not exist in SQL. Just as values in SQL::Abstract are
SQL-escaped, this module does the appropriate Solr-escaping on all values passed to the object (see "escape()").
QUERY SYNTAX
Key-Value Pairs
The simplest way to search is with key value pairs.
my $q = WebService::Solr::Query->new( { foo => 'bar' } );
# RESULT: (foo:"bar")
Implicit AND and OR
By default, data received as a HASHREF is AND'ed together.
my $q = WebService::Solr::Query->new( { foo => 'bar', baz => 'quux' } );
# RESULT: (foo:"bar" AND baz:"quux")
Furthermore, data received as an ARRAYREF is OR'ed together.
my $q = WebService::Solr::Query->new( { foo => [ 'bar', 'baz' ] } );
# RESULT: (foo:"bar" OR foo:"baz")
Nested AND and OR
The ability to nest AND and OR boolean operators is essential to express complex queries. The "-and" and "-or" prefixes have been provided
for this need.
my $q = WebService::Solr::Query->new( { foo => [
-and => { -prohibit => 'bar' }, { -require => 'baz' }
] } );
# RESULT: (((-foo:"bar") AND (+foo:"baz")))
my $q = WebService::Solr::Query->new( { foo => [
-or => { -require => 'bar' }, { -prohibit => 'baz' }
] } );
# RESULT: (((+foo:"bar") OR (-foo:"baz")))
Default Field
To search the default field, use the "-default" prefix.
my $q = WebService::Solr::Query->new( { -default => 'bar' } );
# RESULT: ("bar")
Require/Prohibit
my $q = WebService::Solr::Query->new( { foo => { -require => 'bar' } } );
# RESULT: (+foo:"bar")
my $q = WebService::Solr::Query->new( { foo => { -prohibit => 'bar' } } );
# RESULT: (-foo:"bar")
Range
There are two types of range queries, inclusive ("-range_inc") and exclusive ("-range_exc"). The "-range" prefix can be used in place of
"-range_inc".
my $q = WebService::Solr::Query->new( { foo => { -range => ['a', 'z'] } } );
# RESULT: (+foo:[a TO z])
my $q = WebService::Solr::Query->new( { foo => { -range_exc => ['a', 'z'] } } );
# RESULT: (+foo:{a TO z})
Boost
my $q = WebService::Solr::Query->new( { foo => { -boost => [ 'bar', '2.0' ] } } );
# RESULT: (foo:"bar"^2.0)
Proximity
my $q = WebService::Solr::Query->new( { foo => { -proximity => [ 'bar baz', 10 ] } } );
# RESULT: (foo:"bar baz"~10)
Fuzzy
my $q = WebService::Solr::Query->new( { foo => { -fuzzy => [ 'bar', '0.8' ] } } );
# RESULT: (foo:bar~0.8)
Boost
my $q = WebService::Solr::Query->new( { foo => { -boost => [ 'bar', '2.0' ] } } );
# RESULT: (foo:"bar"^2.0)
Literal Queries
Specifying a scalar ref as a value in a key-value pair will allow arbitrary queries to be sent across the line. NB: This will bypass any
data massaging done on regular strings, thus the onus of properly escaping the data is left to the user.
my $q = WebService::Solr::Query->new( { '*' => '*' } )
# RESULT (*:*)
ACCESSORS
o query - stores the original query structure
METHODS
new( \%query )
Creates a new query object with the given hashref.
stringify( )
Converts the supplied structure into a Solr/Lucene query.
escape( $value )
The following values must be escaped in a search value:
+ - & | ! ( ) { } [ ] ^ " ~ * ? :
NB: Values sent to "new()" are automatically escaped for you.
unescape( $value )
Unescapes values escaped in "escape()".
D
Debugging constant, default: off.
BUILDARGS
Moose method to handle input to "new()".
SEE ALSO
o WebService::Solr
o http://wiki.apache.org/solr/SolrQuerySyntax
AUTHORS
Brian Cassidy <bricas@cpan.org>
Jos Boumans <kane@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2008-2012 National Adult Literacy Database
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.14.2 2012-05-24 WebService::Solr::Query(3pm)