Jul 11, 2009, 10:46 PM
Post #1 of 2
Can I use a file with DBI?
I want to rewrite my ksh scripts to take advantage of perl's speed, but I don't know how to make this isql faster.
I have a script that gets index information from a txt file, to create an index for a table in Sybase. The tables can have 1 to 12 indexes, which is all in the txt file. The file first checks to see if the index exists; if it does, it drops the index before creating it.
Here is an example of one of the text files (this only has one index, but for a table with multiple indexes, the information is in the same format for each index)
print '<<<<< CREATING Index - "TBL_ONE_PRIMARY" >>>>>'
IF EXISTS (SELECT 1 FROM sysindexes i, sysobjects o, sysusers u WHERE o.id = i.id AND o.uid = u.uid AND i.name = 'TBL_ONE_PRIMARY' AND u.name = 'dbo')
drop index TBL_ONE.TBL_ONE_PRIMARY
IF (@@error != 0)
PRINT "Error CREATING Index 'TBL_ONE_PRIMARY'"
create unique clustered index TBL_ONE_PRIMARY
on tiger1.dbo.TBL_ONE(TBL_ID, TBL_TYPE, PDVC_EFF_DT, PDVC_SEQ_NO) with sorted_data
In ksh, I use an isql statement with the -I parameter to use the text file, and -O<file name> to write any results of the command. This is the command I use:
isql -U$suser -P$spass -S$senv -I$file -O$outfile
In perl, I put the isql statement in a system() call, and run it
system("isql -U$suser -P$spass -S$senv -I$file -O$outfile");
The time was basically the same as it was when I ran the ksh script.
Is there anyway make this isql statement faster in perl? Any help would be appreciated.
(This post was edited by stonemonolith on Jul 13, 2009, 10:09 AM)