line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::SqlServer::DTS::Connection;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Win32::SqlServer::DTS::Connection - a Perl class to represent a Microsoft SQL Server 2000 DTS Connection object
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Win32::SqlServer::DTS::Application;
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $app = Win32::SqlServer::DTS::Application->new(
|
12
|
|
|
|
|
|
|
{
|
13
|
|
|
|
|
|
|
server => $server,
|
14
|
|
|
|
|
|
|
user => $user,
|
15
|
|
|
|
|
|
|
password => $password,
|
16
|
|
|
|
|
|
|
use_trusted_connection => 0
|
17
|
|
|
|
|
|
|
}
|
18
|
|
|
|
|
|
|
);
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $package = $app->get_db_package(
|
21
|
|
|
|
|
|
|
{ id => '', version_id => '', name => 'some_package', package_password => '' } );
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $iterator = $package->get_connections();
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
while ( my $conn = $iterator->() ) {
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
print $conn->get_name(), "\n";
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# or if you have $connection as a regular
|
32
|
|
|
|
|
|
|
# MS SQL Server Connection object
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $conn2 = Win32::SqlServer::DTS::Connection->new($connection);
|
35
|
|
|
|
|
|
|
print $conn2->to_string(), "\n";
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
C class represent a DTS Connection object, serving as a layer to fetch properties
|
40
|
|
|
|
|
|
|
from the DTS Connection stored in the C<_sibling> attribute.
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Although it's possible to create an C object directly (once a DTS Connection object is available), one
|
43
|
|
|
|
|
|
|
will probably fetch connections from a package using the C method from the L
|
44
|
|
|
|
|
|
|
module.
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 EXPORT
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
None by default.
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut
|
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
23414
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
53
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
54
|
1
|
|
|
1
|
|
6
|
use Carp;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
109
|
|
55
|
1
|
|
|
1
|
|
6
|
use base qw(Class::Accessor Win32::SqlServer::DTS);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
682
|
|
56
|
|
|
|
|
|
|
use Win32::OLE qw(in);
|
57
|
|
|
|
|
|
|
use Hash::Util qw(lock_keys);
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice;
|
60
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(
|
61
|
|
|
|
|
|
|
qw(oledb catalog datasource description id name password provider user));
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 METHODS
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Inherints all methods from L superclass.
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head3 new
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
The only expected parameter to the C method is an already available DTS Connection object. Returns a
|
70
|
|
|
|
|
|
|
C object.
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub new {
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $class = shift;
|
77
|
|
|
|
|
|
|
my $self = { _sibling => shift };
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
bless $self, $class;
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $sibling = $self->get_sibling;
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$self->{catalog} = $sibling->Catalog;
|
84
|
|
|
|
|
|
|
$self->{datasource} = $sibling->DataSource;
|
85
|
|
|
|
|
|
|
$self->{description} = $sibling->Description;
|
86
|
|
|
|
|
|
|
$self->{id} = $sibling->ID;
|
87
|
|
|
|
|
|
|
$self->{name} = $sibling->Name;
|
88
|
|
|
|
|
|
|
$self->{password} = $sibling->Password;
|
89
|
|
|
|
|
|
|
$self->{provider} = $sibling->ProviderID;
|
90
|
|
|
|
|
|
|
$self->{user} = $sibling->UserID;
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
$self->{oledb} = $self->_init_oledb_props;
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
lock_keys( %{$self} );
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
return $self;
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head3 get_type
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Fetchs the I value of the connection. It is an alias for the C method.
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub get_type {
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $self = shift;
|
109
|
|
|
|
|
|
|
return $self->get_provider();
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
}
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _init_oledb_props {
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
my $self = shift;
|
116
|
|
|
|
|
|
|
my %props;
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
foreach my $property ( in( $self->get_sibling->ConnectionProperties ) ) {
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $key = $property->Name;
|
121
|
|
|
|
|
|
|
$key =~ tr/ //d;
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$props{$key} = {
|
124
|
|
|
|
|
|
|
name => $property->Name,
|
125
|
|
|
|
|
|
|
property_id => $property->PropertyID,
|
126
|
|
|
|
|
|
|
property_set => $property->PropertySet,
|
127
|
|
|
|
|
|
|
value => ( defined( $property->Value ) ) ? $property->Value : ''
|
128
|
|
|
|
|
|
|
};
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# converting numeric code to string
|
133
|
|
|
|
|
|
|
if ( exists( $props{FileType} ) ) {
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
CASE: {
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
if ( $props{FileType}->{value} == 2 ) {
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$props{FileType}->{value} = 'UTF';
|
140
|
|
|
|
|
|
|
last CASE;
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
}
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
if ( $props{FileType}->{value} == 1 ) {
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$props{FileType}->{value} = 'ASCII';
|
147
|
|
|
|
|
|
|
last CASE;
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
}
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
if ( $props{FileType}->{value} == 4 ) {
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
$props{FileType}->{value} = 'OEM';
|
154
|
|
|
|
|
|
|
last CASE;
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
}
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
}
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
}
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
return \%props;
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
}
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head3 to_string
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Returns a string with all properties (but those returned by C method) from the a C
|
169
|
|
|
|
|
|
|
object. Each property will have a short description before the value and will be separated by new line characters.
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub to_string {
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
my $self = shift;
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
my $string =
|
178
|
|
|
|
|
|
|
"\tName: "
|
179
|
|
|
|
|
|
|
. $self->get_name
|
180
|
|
|
|
|
|
|
. "\n\tDescription: "
|
181
|
|
|
|
|
|
|
. $self->get_description
|
182
|
|
|
|
|
|
|
. "\n\tID: "
|
183
|
|
|
|
|
|
|
. $self->get_id
|
184
|
|
|
|
|
|
|
. "\n\tCatalog: "
|
185
|
|
|
|
|
|
|
. $self->get_catalog
|
186
|
|
|
|
|
|
|
. "\n\tData Source: "
|
187
|
|
|
|
|
|
|
. $self->get_datasource
|
188
|
|
|
|
|
|
|
. "\n\tUser: "
|
189
|
|
|
|
|
|
|
. $self->get_user
|
190
|
|
|
|
|
|
|
. "\n\tPassword: "
|
191
|
|
|
|
|
|
|
. $self->get_password
|
192
|
|
|
|
|
|
|
. "\n\tProvider: "
|
193
|
|
|
|
|
|
|
. $self->get_provider;
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
return $string;
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
}
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1;
|
200
|
|
|
|
|
|
|
__END__
|