05-26-2016
You can do this in a few ways.
- You can call sqlplus and pass it a deck/file of multiple SQL commands.
- You can call sqlplus in what is called a here document and pass in the commands from your script
- Probably others......
How much SQL code are you planning to pass in, and will it be static or based on variables in the main script?
Robin
This User Gave Thanks to rbatte1 For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I new to Unix and scripting. Following is my requirement. Can someone tell me whether its possible or not. Also please let me know how to proceed further if this is possible.
List of queries are stored in a file. For example, I have to run a query like this:
Select * from &XYZ where... (0 Replies)
Discussion started by: simhasuri
0 Replies
2. Shell Programming and Scripting
Hi,
When i execute the below statement , the value is not getting stored in the variable.
AnneeExercice=`sqlplus $LOGSQL/$PASSWORDSQL << FIN >> $GEMOLOG/gemo_reprev_reel_data_ventil_$filiale.trc
SELECT bi09exercice
FROM bi09_scenario
WHERE bi09idfiliale=UPPER('de')
AND ... (1 Reply)
Discussion started by: krishna_gnv
1 Replies
3. Shell Programming and Scripting
Hi,
I need your help in sedning sql queries output to different excel sheets.
My requirement is like this:
Query1: Select name from table1 where status = 'Complete'
Query2: Select name from table1 where status = 'Failed'
Query3: Select name from table1 where status = 'Ignored'
... (4 Replies)
Discussion started by: parvathi_rd
4 Replies
4. Shell Programming and Scripting
i have to do a check in my UNIX script to see whats saved in the database. depending on whats there will fork data to certain functions. However i do not know how to capture SQL output into a UNIX variable.
Below is what i have tried, but i get an error:
Error 3706 Failure 3706 Syntax error:... (3 Replies)
Discussion started by: purplebirky
3 Replies
5. Shell Programming and Scripting
Hi,
I want to write the shell script to change multple file name (the file name is get from DB)
e.g. cp db1.txt file1_new.txt
cp db2.txt file2_new.txt
cp db3.txt file3_new.txt
I have write the script like this:
VAR=`sqlplus -s $LOGON @<<ENDOFTEXT
set termout off
... (0 Replies)
Discussion started by: jackyntk
0 Replies
6. Shell Programming and Scripting
In c:/zaheer/123-456/sql/ folder i have below 7 sql files.
cv_abc_a.sql
cv_abc_b.sql
cv_abc_c.sql
vtemp_d.sql
vtemp_e.sql
cv_abc_f.sql
Exviews.sql
In Exviews.sql file i have mentioned all cv and vtemp files to run like
start ${SQLDIR}/cv_abc_a.sql
start ${SQLDIR}/cv_abc_b.sql... (1 Reply)
Discussion started by: Zaheer.mic
1 Replies
7. Shell Programming and Scripting
Hi!
I would like to do a single connection to sqlplus and execute some querys.
Actually I do for every query one connection to database
i.e
echo 'select STATUS from v$instance;
exit' > $SQL_FILE
sqlplus user/pass@sid @$SQL_FILE > $SELECT_RESULT
echo 'select VERSION from v$instance;... (6 Replies)
Discussion started by: guif
6 Replies
8. Shell Programming and Scripting
Hi,
I have a script where I make a sqlplus connection. In the script I have multiple sql queries within that sqlplus connection. I want the result of the queries to be stored in shell variables declared earlier. I dont want to use procedures. Is there anyway else.
Thanks in advance..
Cheers (6 Replies)
Discussion started by: gonchusirsa
6 Replies
9. Shell Programming and Scripting
Dear All,
I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File.
The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files.
Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies
10. Shell Programming and Scripting
Hi All,
I have a file queries.txt as follows :
SELECT COLUMN1 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN1 FROM SCDEMA2.TABLE2;
SELECT COLUMN2 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN2 FROM SCDEMA2.TABLE2;
SELECT COLUMN3 FROM SCHEMA2.TABLE1 MINUS SELECT COLUMN3 FROM SCDEMA2.TABLE2;
SELECT... (2 Replies)
Discussion started by: SriRamKrish
2 Replies
LEARN ABOUT DEBIAN
sql::translator::producer::ttschema
SQL::Translator::Producer::TTSchema(3pm) User Contributed Perl Documentation SQL::Translator::Producer::TTSchema(3pm)
NAME
SQL::Translator::Producer::TTSchema -
Produces output using the Template Toolkit from a SQL schema
SYNOPSIS
use SQL::Translator;
my $translator = SQL::Translator->new(
from => 'MySQL',
filename => 'foo_schema.sql',
to => 'TTSchema',
producer_args => {
ttfile => 'foo_template.tt', # Template file to use
# Extra template variables
ttargs => {
author => "Mr Foo",
},
# Template config options
ttargs => {
INCLUDE_PATH => '/foo/templates',
},
},
);
print $translator->translate;
DESCRIPTION
Produces schema output using a given Template Tookit template.
It needs one additional producer_arg of "ttfile" which is the file name of the template to use. This template will be passed a variable
called "schema", which is the "SQL::Translator::Producer::Schema" object created by the parser. You can then use it to walk the schema via
the methods documented in that module.
Here's a brief example of what the template could look like:
database: [% schema.database %]
tables:
[% FOREACH table = schema.get_tables %]
[% table.name %]
================
[% FOREACH field = table.get_fields %]
[% field.name %] [% field.data_type %]([% field.size %])
[% END -%]
[% END %]
See t/data/template/basic.tt for a more complete example.
The template will also get the set of extra variables given as a hashref via the "tt_vars" producer arg.
You can set any of the options used to initiallize the Template object by adding a tt_conf producer_arg. See Template Toolkit docs for
details of the options. (Note that the old style of passing this config directly in the producer args has been deprecated).
$translator = SQL::Translator->new(
to => 'TT',
producer_args => {
ttfile => 'foo_template.tt',
ttargs => {},
tt_conf = {
INCLUDE_PATH => '/foo/templates/tt',
INTERPOLATE => 1,
}
},
);
You can use this producer to create any type of text output you like, even using it to create your own versions of what the other producers
make. For example, you could create a template that translates the schema into MySQL's syntax, your own HTML documentation, your own
Class::DBI classes (or some other code) -- the opportunities are limitless!
Producer Args
ttfile
The template file to generate the output with.
tt_vars
A hash ref of extra variables you want to add to the template.
tt_conf
A hash ref of configuration options to pass to the Template object's constructor.
AUTHOR
Mark Addison <grommit@users.sourceforge.net>.
TODO
More template vars? e.g. [% tables %] as a shortcut for [% schema.get_tables %].
SEE ALSO
SQL::Translator.
perl v5.14.2 2012-01-18 SQL::Translator::Producer::TTSchema(3pm)