line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::SqlServer::DTS::Task::ExecutePackage;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Win32::SqlServer::DTS::Task::ExecutePackage - a subclass of Win32::SqlServer::DTS::Task to represent a DTSExecutePackageTask object
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use warnings;
|
10
|
|
|
|
|
|
|
use strict;
|
11
|
|
|
|
|
|
|
use Win32::SqlServer::DTS::Application;
|
12
|
|
|
|
|
|
|
use Test::More;
|
13
|
|
|
|
|
|
|
use XML::Simple;
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $xml = XML::Simple->new();
|
16
|
|
|
|
|
|
|
my $config = $xml->XMLin('test-config.xml');
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $app = Win32::SqlServer::DTS::Application->new($config->{credential});
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $package =
|
21
|
|
|
|
|
|
|
$app->get_db_package({ id => '', version_id => '', name => $config->{package}, package_password => '' } );
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $total_exec_pkgs = $package->count_execute_pkgs;
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
plan tests => $total_exec_pkgs;
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
SKIP: {
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
skip 'The package has no Execute Package task', 1
|
30
|
|
|
|
|
|
|
unless ( $total_exec_pkgs > 0 );
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my $package_name;
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $iterator = $package->get_execute_pkgs();
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
while ( my $execute_pkg = $iterator->() ) {
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$package_name = 'Execute Package task "' . $execute_pkg->get_name() . '"';
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
is( $execute_pkg->get_package_id(),
|
41
|
|
|
|
|
|
|
'', "$package_name must have Package ID empty" );
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$package_name = '';
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
C class represents a DTS ExecutePackage task.
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 EXPORT
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Nothing.
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut
|
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
|
41813
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
61
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
62
|
1
|
|
|
1
|
|
5
|
use Carp;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
99
|
|
63
|
1
|
|
|
1
|
|
5
|
use base qw(Win32::SqlServer::DTS::Task Class::Accessor);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
617
|
|
64
|
|
|
|
|
|
|
use Hash::Util qw(lock_keys);
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 METHODS
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
All methods from L are also available.
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__PACKAGE__->follow_best_practice;
|
73
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(
|
74
|
|
|
|
|
|
|
qw(package_id package_name package_password repository_database_name server_name
|
75
|
|
|
|
|
|
|
server_password server_username file_name)
|
76
|
|
|
|
|
|
|
);
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head3 new
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Overrides the superclass C C method by defining the following attributes:
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=over
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item *
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
package_id
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item *
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
package_name
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item *
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
package_password
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item *
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
repository_database_name
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item *
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
server_name
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item *
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
server_password
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item *
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
server_username
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item *
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
use_repository
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item *
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
use_trusted_connection
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item *
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
file_name
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item *
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
input_global_variable_names
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=back
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub new {
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $class = shift;
|
135
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_);
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
$self->{package_id} = $self->get_sibling->Properties->Parent->PackageID;
|
138
|
|
|
|
|
|
|
$self->{package_name} = $self->get_sibling->Properties->Parent->PackageName;
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
$self->{package_password} =
|
141
|
|
|
|
|
|
|
$self->get_sibling->Properties->Parent->PackagePassword;
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
$self->{repository_database_name} =
|
144
|
|
|
|
|
|
|
$self->get_sibling->Properties->Parent->RepositoryDatabaseName;
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$self->{server_name} = $self->get_sibling->Properties->Parent->ServerName;
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
$self->{server_password} =
|
149
|
|
|
|
|
|
|
$self->get_sibling->Properties->Parent->ServerPassword;
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
$self->{server_username} =
|
152
|
|
|
|
|
|
|
$self->get_sibling->Properties->Parent->ServerUsername;
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
$self->{use_repository} =
|
155
|
|
|
|
|
|
|
$self->get_sibling->Properties->Parent->UseRepository;
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
$self->{use_trusted_connection} =
|
158
|
|
|
|
|
|
|
$self->get_sibling->Properties->Parent->UseTrustedConnection;
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
$self->{file_name} = $self->get_sibling->Properties->Parent->FileName;
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
$self->{input_global_variable_names} =
|
163
|
|
|
|
|
|
|
$self->get_sibling->Properties->Parent->InputGlobalVariableNames;
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
lock_keys( %{$self} );
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
return $self;
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
}
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head3 get_input_vars
|
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Returns the C property from a C task, which is a string
|
174
|
|
|
|
|
|
|
containing each global variable name separated by a semicolon character (;), optionally double-quoted
|
175
|
|
|
|
|
|
|
or single-quoted list. Quoting is required only when the name contains an embedded delimiter
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut
|
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub get_input_vars {
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $self = shift;
|
182
|
|
|
|
|
|
|
return $self->{input_global_variable_names};
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
}
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head3 get_ref_input_vars
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Same as C, but returns an array reference instead of a string. Single or double quotes are
|
189
|
|
|
|
|
|
|
removed too (but only those ones at the start and end of the global variable name).
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub get_ref_input_vars {
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
my $self = shift;
|
196
|
|
|
|
|
|
|
my @list = split( /\;/, $self->get_input_vars );
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
foreach (@list) {
|
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
tr/\"//d;
|
201
|
|
|
|
|
|
|
tr/\'//d;
|
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
}
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
return \@list;
|
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
}
|
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head3 uses_repository
|
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Returns true or false depending if the C object uses MS SQL Server 2000 Meta Data
|
212
|
|
|
|
|
|
|
Services. Same thing as C property of DTS ExecutePackage task.
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut
|
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub uses_repository {
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
my $self = shift;
|
219
|
|
|
|
|
|
|
return $self->{use_repository};
|
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
}
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head3 use_trusted
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Returns true or false whether the C object uses a B to authenticate
|
226
|
|
|
|
|
|
|
against a SQL Server.
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=cut
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub use_trusted {
|
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
my $self = shift;
|
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
return $self->{use_trusted_connection};
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
}
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head3 to_string
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Overrides superclass C method C to return strings for all defined attributes
|
241
|
|
|
|
|
|
|
of the object.
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=cut
|
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub to_string {
|
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
my $self = shift;
|
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
return "\tTask name: "
|
250
|
|
|
|
|
|
|
. $self->get_name
|
251
|
|
|
|
|
|
|
. "\r\n\t"
|
252
|
|
|
|
|
|
|
. 'Task description: '
|
253
|
|
|
|
|
|
|
. $self->get_description
|
254
|
|
|
|
|
|
|
. "\r\n\t"
|
255
|
|
|
|
|
|
|
. 'Task type: '
|
256
|
|
|
|
|
|
|
. $self->get_type
|
257
|
|
|
|
|
|
|
. "\r\n\t"
|
258
|
|
|
|
|
|
|
. 'Package ID: '
|
259
|
|
|
|
|
|
|
. $self->get_package_id
|
260
|
|
|
|
|
|
|
. "\r\n\t"
|
261
|
|
|
|
|
|
|
. 'Package name: '
|
262
|
|
|
|
|
|
|
. $self->get_package_name
|
263
|
|
|
|
|
|
|
. "\r\n\t"
|
264
|
|
|
|
|
|
|
. 'Package password: '
|
265
|
|
|
|
|
|
|
. $self->get_package_password
|
266
|
|
|
|
|
|
|
. "\r\n\t"
|
267
|
|
|
|
|
|
|
. 'Server name: '
|
268
|
|
|
|
|
|
|
. $self->get_server_name
|
269
|
|
|
|
|
|
|
. "\r\n\t"
|
270
|
|
|
|
|
|
|
. 'Server username: '
|
271
|
|
|
|
|
|
|
. $self->get_server_username
|
272
|
|
|
|
|
|
|
. "\r\n\t"
|
273
|
|
|
|
|
|
|
. 'Server password: '
|
274
|
|
|
|
|
|
|
. $self->get_server_password
|
275
|
|
|
|
|
|
|
. "\r\n\t"
|
276
|
|
|
|
|
|
|
. 'Repository is used? '
|
277
|
|
|
|
|
|
|
. ( ( $self->uses_repository ) ? 'true' : 'false' )
|
278
|
|
|
|
|
|
|
. "\r\n\t"
|
279
|
|
|
|
|
|
|
. 'Filename: '
|
280
|
|
|
|
|
|
|
. $self->get_file_name
|
281
|
|
|
|
|
|
|
. "\r\n\t"
|
282
|
|
|
|
|
|
|
. 'Connection trusted based? '
|
283
|
|
|
|
|
|
|
. ( ( $self->use_trusted ) ? 'true' : 'false' )
|
284
|
|
|
|
|
|
|
. "\r\n\t"
|
285
|
|
|
|
|
|
|
. 'Input global variables: '
|
286
|
|
|
|
|
|
|
. $self->get_input_vars . "\r\n";
|
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
}
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
1;
|
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
__END__
|