Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

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 10th, 2013, 09:26 AM
terrykhatri531 terrykhatri531 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 8 terrykhatri531 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 23 m 47 sec
Reputation Power: 0
How can I change my script to make multiple connections to do the job

Hi,
The following script does the job with one connection to the database however I need to add routines to make multiple connections to the database to do the job like adding another variable for example $conn=20; and avoid the table name conflicts, can someone please help me do that.

Code:
#!/usr/bin/perl
use strict;
use warnings;
use DBI;

my $tables=1000;
my $rows=100000;

my $dbh = DBI->connect ('DBI:Oracle:host=EM12;sid=orcl',"hr","hr")
        or die "Failed to connect to database: " . DBI->errstr;

for my $i (1..$tables) {
my $sql = "CREATE TABLE test_data$i(".
                                "id PRIMARY KEY,".
                                "group_id NOT NULL,".
                                "created_at NOT NULL,".
                                "text NOT NULL) AS ".
                                        "SELECT ".
                                                "rownum,".
                                                "MOD(rownum, 5),".
                                                "TO_DATE('1-jan-07', 'dd-mon-yy') + INTERVAL '1' MINUTE * rownum,".
                                                "CAST ('xyz' || rownum AS VARCHAR2(50)) ".
                                          "FROM dual ".
                                          "CONNECT BY LEVEL <= $rows";

$dbh->do($sql) or die DBI->errstr;

}

$dbh->disconnect;


Thank you very much in advance.
Regards
Terry

Reply With Quote
  #2  
Old January 10th, 2013, 05:50 PM
Laurent_R Laurent_R is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2012
Posts: 503 Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level)Laurent_R User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 4 Days 18 h 53 m 5 sec
Reputation Power: 385
Perhaps the use of threads will provide you with the right tools.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > How can I change my script to make multiple connections to do the job

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap