Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 15th, 2007, 04:09 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
Executing scripts via batch processing

Hi,

i have to migrate data from one database model to another.

To test the whole process i have to drop and create the database frequently and run various scripts for that. To do this more comfortable i would like to do this in a batch processing manner.
In detail i would like to call only one file and this executes all steps of the process. There are ddl and dml statements in various sql scripts.
I'm using Firebird 2.0 on Windows XP SP2.

So i want to create a batch file which maybe creates the database itself and calls the ddl and dml statements by executing the sql script files.

How does this works? How can i create an connection from an dos batch file and execute sql scripts in other files?

thanks a lot,

hennig

Reply With Quote
  #2  
Old January 15th, 2007, 04:20 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,907 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 9 h 21 m 6 sec
Reputation Power: 279
You can, call the command line client (isql)

Reply With Quote
  #3  
Old January 15th, 2007, 04:58 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
But how do i call ddl or dml statemtents in external script files?

for expample i write the following lines in a file 'test.bat':

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

@echo off


isql servername:dbname -user 'test' -password '12345'

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

The connetion is established correctly, but how could i say that isql now executes the statements in file 'xyz.sql'?

Reply With Quote
  #4  
Old January 15th, 2007, 05:13 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 7,907 pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level)pabloj User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Months 3 Weeks 3 Days 9 h 21 m 6 sec
Reputation Power: 279
Check my signature for a tutorial I once wrote, ("Getting started with Firebird" pdf) it shows you how to do this, basically it's
Quote:
Loading data from a DDL (*.sql) file
You can also execute a DDL file (a file made of SQL statements) this way:
isql -i your_script.sql
the script must contain login statements, or you can add them to the command line as
described above.

Reply With Quote
  #5  
Old January 16th, 2007, 02:20 AM
upscene upscene is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 223 upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level)upscene User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 7 h 14 m 50 sec
Reputation Power: 8
You can use INPUT to include other files.


Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle & MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Comments on this post
pabloj agrees: Nice trick, I'll add this to my guide

Reply With Quote
  #6  
Old January 16th, 2007, 03:55 AM
shennig shennig is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 18 shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level)shennig User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 7 h 33 m 54 sec
Reputation Power: 0
Thank you!

but better as to put the connect string in every sql script, you can connect and give isql the file

isql databasename -user 'User' -password 12345 -i script_name.sql

this line you could generate for every script to execute.

this works fine!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Executing scripts via batch processing


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT