?
Solved

usage of isql.exe form a batchfile

Posted on 2003-02-20
5
Medium Priority
?
7,596 Views
Last Modified: 2013-12-09
Hi,

I 'm using   isql -page 5000 -i Controler.SQL
to run some questions in a batchfile

But now i still have to add the outputfile in the controler.sql
egg.
CONNECT   "database.gdb" USER "user" PASSWORD "pass";
OUTPUT     ABCDE.txt;
Select * from table where field like "ABCDE"


Can I use somekind of parameter to set the outputfile?
Can I use a parameter within the select statement to run more selections to a set of txt-files. with several inputs instead of ABCDE

thanks,
kokjoh






0
Comment
Question by:kokjoh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 6

Expert Comment

by:BAlexandrov
ID: 8007962
I don't know. Surelly you can find complete reference in Interbase docs and findout if there is such option. Also you can try ibescript - command line utility comming with ibexpert - Ibexpert.com (ibescript, i think is free)

Regards,
Bojidar Alexandrov
0
 

Expert Comment

by:Brcko
ID: 8015038
ad. 1
try
isql -page 5000 -i Controler.SQL -o ABCDE.txt
:-)

ad. 2
If I've been unterstand, you can't
coz OUTPUT file is solely future of isql.exe and have nothing to do with SQL

Brcko
0
 
LVL 1

Expert Comment

by:vogonPoet
ID: 8040050
Here's what I was able to do:

Create an SQL file to run the desired queries:
( I called this one test_output.sql )


---------------------------------------------------

/* connect to the db */
CONNECT 'C:\PROJECTS\test.GDB'
USER 'SYSDBA' PASSWORD 'masterkey';

/* prepare the output file */
OUTPUT "c:\projects\test_text.txt";


SELECT "People: "||COUNT(*) from Person;

SELECT "Employees: "||COUNT(*) from Employee;

COMMIT;

---------------------------------------------------

Once the script above is saved you can run it like this :
( assuming that isql.exe is in a path or it's copied to the local directory )



isql -i test_output.sql


does that help ?
0
 
LVL 1

Accepted Solution

by:
vogonPoet earned 100 total points
ID: 8040186
OOPS...

I realized that i really hadn't solved anything....

IF you're working in Windows ( or DOS... scary! ) here's
a batch file that can create a script:
Include everything between the dashed lines name it
it CREATE_SQL.BAT
------------------------------------------------------
@echo off
rem start bat
if %1.==.  goto HELPBAT
if %2.==.  goto HELPBAT
echo CONNECT 'C:\PROJECTS\test.GDB'                      >curr_script.sql
echo USER 'SYSDBA' PASSWORD 'masterkey';                 >>curr_script.sql
echo.                                                    >>curr_script.sql
echo OUTPUT "%1";                                        >>curr_script.sql
if %2.==. goto ARGSDONE                                    
echo SELECT Select * from table1 where field like "%2";   >>curr_script.sql
if %3.==. goto ARGSDONE
echo SELECT Select * from table1 where field like "%3";   >>curr_script.sql
if %4.==. goto ARGSDONE
echo SELECT Select * from table1 where field like "%4";   >>curr_script.sql
if %5.==. goto ARGSDONE
echo SELECT Select * from table1 where field like "%5";   >>curr_script.sql
if %6.==. goto ARGSDONE
echo SELECT Select * from table1 where field like "%6";   >>curr_script.sql
if %7.==. goto ARGSDONE
echo SELECT Select * from table1 where field like "%7";   >>curr_script.sql
:ARGSDONE
echo.                                                     >>curr_script.sql
echo COMMIT;                                              >>curr_script.sql
GOTO ENDBAT
:HELPBAT
Echo.
echo Create SQL batch file
echo.
echo creates an interbase script based on command line parameters.
echo.
echo USAGE:
echo create_sql ouputfile field1 [ field2 .. field7 ]
echo

:ENDBAT
-----------------------------------------------------


simply run:

create_sql ouputfile.txt curly larry moe


to create the script:
----------------------------------------------------
CONNECT 'C:\PROJECTS\test.GDB'                      
USER 'SYSDBA' PASSWORD 'masterkey';                
                                                   
OUTPUT "outputfile.txt";                                        
SELECT Select * from table1 where field like "curly";  
SELECT Select * from table1 where field like "larry";  
SELECT Select * from table1 where field like "moe";  
                                                     
COMMIT;                                              
----------------------------------------------------

and run it:
isql -i curr_script.sql

note: curr_script.sql gets overwritten on every pass.
IMPORTANT: It looks like word-wrapping may damage the batch file... let me know, and I'll try to email it to you..

IF you are not using Windows, it probably wouldn't be too hard to do this in PHP or something like that.

0
 

Author Comment

by:kokjoh
ID: 8179358
I thought I already accepted you comment as an answer.
Sorry for taking so long.

Kokjoh
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this article, we’ll look at how to deploy ProxySQL.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question