This is the sub routine that alters the sybase database. the alter command can run for a extended period of time.
sub _grow_db() { my ( $dbh, $dbname, $increase, $tran_size, $data_pool, $log_pool ) = @ +_; my $log_increase = int ( $increase * $params->get("Device.Log.Percent" +) / 100 ); my $max_tran_size = int ( $params->get("Max.Tran.Size") ); my $sql = "use master"; $$dbh->do($sql) or $app->log($FATAL, "Can't do SQL statement [ $sql ] :: $DBI::errst +r"); $app->log($INFO,"Altering database $dbname. Increasing data segment b +y $increase MB"); my $sql="alter database $dbname on "; foreach my $device ( @$data_pool ) { next if ( $$device{free} == 0 ); if ( $increase >= $$device{free} ) { $sql .= "$$device{name}=$$device{free},"; $increase -= $$device{free}; $$device{free} = 0; } else { $sql .= "$$device{name}=$increase,"; $$device{free} -= $increase; $increase = 0; } last if ( $increase == 0 ); } if ( $tran_size < $max_tran_size ) { $app->log($INFO,"Altering database $dbname. Increasing log segment by +$log_increase MB"); $sql =~ s/,$//; $sql .= " log on "; foreach my $device ( @$log_pool ) { next if ( $$device{free} == 0 ); if ( $log_increase >= $$device{free} ) { $sql .= "$$device{name}=$$device{free},"; $log_increase -= $$device{free}; $$device{free} = 0; } else { $sql .= "$$device{name}=$log_increase,"; $$device{free} -= $log_increase; $log_increase = 0; } last if ( $log_increase == 0 ); } } $sql =~ s/,$//; #$$dbh->do($sql) # or $app->log($FATAL,"Can't do SQL statement [ $sql ] :: $DBI::err +str"); my $sth = $$dbh->prepare($sql) or $app->log($FATAL,"Can't prepare SQL statement [ $sql ] :: $DBI: +:errstr"); $sth->execute(); $sth->finish();
this is the output from a alter database command.
alter database D_IGT_IMP on data023device = 43 log on
log003device = 5
2> go
Extending database by 22016 pages on disk data023device
Extending database by 2560 pages on disk log003device
Warning: Using ALTER DATABASE to extend the log segment
will cause user thresholds on the log segment within 128
pages of the last
chance threshold to be disabled.
} This is the sub routinne that fails if run after the alter database.
sub get_table_info() { my ( $dbh, $table ) = @_; my @columns = (); my $sql = "exec sp_getcol2 $table"; my $sth = $$dbh->prepare( $sql ) or $app->log($FATAL,"Can't prepare SQL statement [ $sql ] :: $DBI: +:errstr"); $sth->execute() or $app->log($FATAL,"Can't prepare SQL statement [ $sql ] :: $DBI: +:errstr"); while ( my (@results) = $sth->fetchrow_array() ) { my $col_ref = { 'name' => $results[0], 'type' => $results[1], 'length' => $results[2], 'prec' => $results[3], 'scale' => $results[4], 'null' => $results[5], 'identity' => $results[8] }; push @columns, $col_ref; } $sth->finish(); return \@columns; }

In reply to Re^2: How to determine when sybase process complete by mnlight
in thread How to determine when sybase process complete by mnlight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.