By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,541 Members | 1,525 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,541 IT Pros & Developers. It's quick & easy.

perl help

P: 2
Hi
I want to search for columns start_dt and end_dt in all my tables ,wrote shell sript to find the list of tables .I am new to perl want to do it same in perl.Any help it would be appericiated

Expand|Select|Wrap|Line Numbers
  1. for name in `cat list.txt`
  2. do 
  3. tabname=`awk  /CREATE TABLE /{table=$2; start=0; }
  4.  /START_DT/ { start++ }
  5.  /END_DT/ && start  { print table }'  "$name.sql"`
  6. echo $tabname
  7. done
  8.  
Thanks,
MR
Sep 20 '08 #1
Share this Question
Share on Google+
4 Replies


P: 2
Hi

I want to search for columns start_dt and end_dt in all my tables ,wrote shell sript to find the list of tables .I am new to perl want to do it same in perl.Any help it would be appericiated.

Expand|Select|Wrap|Line Numbers
  1. for name in `cat list.txt`
  2. do 
  3. tabname=`awk  /CREATE TABLE /{table=$2; start=0; }
  4.  /START_DT/ { start++ }
  5.  /END_DT/ && start  { print table }'  "$name.sql"`
  6. echo $tabname
  7. done
  8.  
  9.  
Thanks,
MR
Sep 20 '08 #2

numberwhun
Expert Mod 2.5K+
P: 3,503
First, you need to please learn to use code tags. eWish has corrected them for you, but you need to really use them when posting code in the forums. The example is in the Reply Guidelines to the right of your reply window.

As for you code, that is not the proper way to access a database. You really want to use the DBI module from CPAN as it is the proper way to access a database.

Regards,

Jeff
Sep 20 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
First, you need to please learn to use code tags. eWish has corrected them for you, but you need to really use them when posting code in the forums. The example is in the Reply Guidelines to the right of your reply window.

As for you code, that is not the proper way to access a database. You really want to use the DBI module from CPAN as it is the proper way to access a database.

Regards,

Jeff
He appears to be searching through a text file, but my awk is not good enough to read the code.

I suggest he posts on www.unix.com in the Shell Scripting Forum top get an answer to this question.
Sep 20 '08 #4

numberwhun
Expert Mod 2.5K+
P: 3,503
He appears to be searching through a text file, but my awk is not good enough to read the code.

I suggest he posts on www.unix.com in the Shell Scripting Forum top get an answer to this question.
The file he is searching through is the exported data from a table. When you export it to a file, it has all the statements inside of the file to re-create the table when "imported". (including the CREATE TABLE statement he has referenced.

My suggestion to him is, if he is going to seach a table for data, that he do it on the actual table in the database, instead of the back up file. Off hand, I don't remember the format of the backup file for the data portion.

Regards,

Jeff
Sep 20 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.