473,325 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

perl help

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
4 1008
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
3,509 Expert Mod 2GB
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
4,059 Expert 2GB
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
3,509 Expert Mod 2GB
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

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

Similar topics

3
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then...
9
by: Martin Foster | last post by:
Hi. I would like to be able to mimic the unix tool 'uniq' within a Perl script. I have a file with entries that look like this 4 10 21 37 58 83 111 145 184 226...
4
by: Firewalker | last post by:
Hey guys, I am newbie to perl. I am trying to deal with dates ( such trying to find what the date would be after month). Is therea function or date class( I am a java programmer, I couldnt find...
1
by: smsabu2002 | last post by:
Hi, I am facing the build problem while installing the DBD-MySql perl module (ver 2.9008) using both GCC and CC compilers in HP-UX machine. For the Build using GCC, the compiler error is...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
2
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.