[BACK]Return to dbops.pm CVS log [TXT][DIR] Up to [local] / wpscripts / elist

File: [local] / wpscripts / elist / dbops.pm (download)

Revision 1.1, Fri Jun 3 09:28:47 2011 UTC (11 years, 4 months ago) by yason
Branch point for: MAIN

Initial revision

#!/usr/bin/perl
use DBI;
use warnings;

package dbops;

our $EPD_ZAYAVKA_T = 0;
our $EPD_PROBA_T = 1;

our $server = "MSSQL";
our $user = "it_men";
our $pass = "itmen712";
our $dsn = "DBI:Sybase:server=$server";
our $table = 'T$_EPD_File';
our $sth;

sub db_connect()
{
    $dbh = DBI->connect($dsn, $user, $pass) or die "unable to connect to server $DBI::errstr";
}


sub db_select()
{
    $dbh->do("use Manager");
}


sub db_disconnect()
{
    $dbh->disconnect();
}


sub db_fetch($$)
{
    my $file_type = shift;
    my $Ready = shift;
    my $i = 0;
    my @OrderNO;
    my @win_path;
    my @setDate;
    my @ReadyDate;
    
    
    $sth = $dbh->prepare ("SELECT OrderNO,win_path,setDate,ReadyDate FROM $table WHERE File_type=$file_type AND Ready=$Ready AND Backed_up=0")
	or die("fetch");
	
    $sth->execute( ) or die "unable to execute query! error $DBI::errstr";
    
    # initialize to zero everything
    $#OrderNO = $#win_path = $#setDate = $#ReadyDate = 0;

    while( ($OrderNO[$i], $win_path[$i], $setDate[$i], $ReadyDate[$i]) = $sth->fetchrow_array())
    {
	# fetch by row

	$i++;
    }
    
    $sth->finish();
    
    return( (\@OrderNO, \@win_path, \@setDate, \@ReadyDate) );

} # db_fetch()

return(1);