| Win32-SqlServer-DTS documentation | Contained in the Win32-SqlServer-DTS distribution. |
perldoc.perldoc.perldoc.perldoc.Win32::SqlServer::DTS::Connection - a Perl class to represent a Microsoft SQL Server 2000 DTS Connection object
use Win32::SqlServer::DTS::Application;
my $app = Win32::SqlServer::DTS::Application->new(
{
server => $server,
user => $user,
password => $password,
use_trusted_connection => 0
}
);
my $package = $app->get_db_package(
{ id => '', version_id => '', name => 'some_package', package_password => '' } );
my $iterator = $package->get_connections();
while ( my $conn = $iterator->() ) {
print $conn->get_name(), "\n";
}
# or if you have $connection as a regular
# MS SQL Server Connection object
my $conn2 = Win32::SqlServer::DTS::Connection->new($connection);
print $conn2->to_string(), "\n";
Win32::SqlServer::DTS::Connection class represent a DTS Connection object, serving as a layer to fetch properties
from the DTS Connection stored in the _sibling attribute.
Although it's possible to create an Win32::SqlServer::DTS::Connection object directly (once a DTS Connection object is available), one
will probably fetch connections from a package using the get_connections method from the Win32::SqlServer::DTS::Package
module.
None by default.
Inherints all methods from DTS (DTS) superclass.
The only expected parameter to the new method is an already available DTS Connection object. Returns a
Win32::SqlServer::DTS::Connection object.
Fetchs the provider value of the connection. It is an alias for the get_provider method.
Returns a string with all properties (but those returned by get_oledb method) from the a Win32::SqlServer::DTS::Connection
object. Each property will have a short description before the value and will be separated by new line characters.
Fetchs the name of the connection.
Fetchs the description of the connection.
Fetchs the datasource value of the connection.
Fetchs the catalog value of the connection, if available.
Fetchs the connection ID. This ID is used as an connection reference by the tasks in a DTS package that needs a connection.
Fetchs the provider name of the connection. Althought DTS Connection object support various types of connections,
at this version, Win32::SqlServer::DTS::Connection will work only with DTSFlatFile and SQLOLEDB providers.
Fetchs the user used in the authentication of the connection.
Fetchs the password used in the authentication of the connection.
Returns an hash reference with all OLEDB properties used by the connection, being each key (a property) value a hash reference itself.
Being a property a hash reference, it contaings by default the following keys: name, value, property_id
and property_set. These keys correspond to the properties Name, Value, PropertyID and PropertySet
from the original property defined in the DTS API.
Only for the property FileType, that is a convertion from numeric code to the proper string.
This class should be subclassed very soon to two new classes: Win32::SqlServer::DTS::Connection::FlatFile and
Win32::SqlServer::DTS::Connection::OLEBD to enable polymorphic method calls.
perldoc.perldoc.perldoc.perldoc.This API is incomplete. There are much more properties defined in the MS SQL Server 2000 DTS API.
Alceu Rodrigues de Freitas Junior, <arfreitas@cpan.org>
Copyright (C) 2006 by Alceu Rodrigues de Freitas Junior
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
| Win32-SqlServer-DTS documentation | Contained in the Win32-SqlServer-DTS distribution. |
package Win32::SqlServer::DTS::Connection;
use 5.008008; use strict; use warnings; use Carp; use base qw(Class::Accessor Win32::SqlServer::DTS); use Win32::OLE qw(in); use Hash::Util qw(lock_keys); our $VERSION = '0.02'; __PACKAGE__->follow_best_practice; __PACKAGE__->mk_ro_accessors( qw(oledb catalog datasource description id name password provider user));
sub new { my $class = shift; my $self = { _sibling => shift }; bless $self, $class; my $sibling = $self->get_sibling; $self->{catalog} = $sibling->Catalog; $self->{datasource} = $sibling->DataSource; $self->{description} = $sibling->Description; $self->{id} = $sibling->ID; $self->{name} = $sibling->Name; $self->{password} = $sibling->Password; $self->{provider} = $sibling->ProviderID; $self->{user} = $sibling->UserID; $self->{oledb} = $self->_init_oledb_props; lock_keys( %{$self} ); return $self; }
sub get_type { my $self = shift; return $self->get_provider(); } sub _init_oledb_props { my $self = shift; my %props; foreach my $property ( in( $self->get_sibling->ConnectionProperties ) ) { my $key = $property->Name; $key =~ tr/ //d; $props{$key} = { name => $property->Name, property_id => $property->PropertyID, property_set => $property->PropertySet, value => ( defined( $property->Value ) ) ? $property->Value : '' }; } # converting numeric code to string if ( exists( $props{FileType} ) ) { CASE: { if ( $props{FileType}->{value} == 2 ) { $props{FileType}->{value} = 'UTF'; last CASE; } if ( $props{FileType}->{value} == 1 ) { $props{FileType}->{value} = 'ASCII'; last CASE; } if ( $props{FileType}->{value} == 4 ) { $props{FileType}->{value} = 'OEM'; last CASE; } } } return \%props; }
sub to_string { my $self = shift; my $string = "\tName: " . $self->get_name . "\n\tDescription: " . $self->get_description . "\n\tID: " . $self->get_id . "\n\tCatalog: " . $self->get_catalog . "\n\tData Source: " . $self->get_datasource . "\n\tUser: " . $self->get_user . "\n\tPassword: " . $self->get_password . "\n\tProvider: " . $self->get_provider; return $string; } 1; __END__