Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7694
  • Last Modified:

usage of isql.exe form a batchfile

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
kokjoh
Asked:
kokjoh
1 Solution
 
BAlexandrovCommented:
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
 
BrckoCommented:
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
 
vogonPoetCommented:
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
 
vogonPoetCommented:
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
 
kokjohAuthor Commented:
I thought I already accepted you comment as an answer.
Sorry for taking so long.

Kokjoh
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now