Subversion Repositories DevTools

Rev

Rev 6910 | Rev 6915 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6910 Rev 6912
Line 89... Line 89...
89
$rmCred = $opt_pulse ? $newRMCred : $oldRMCred; 
89
$rmCred = $opt_pulse ? $newRMCred : $oldRMCred; 
90
$rmCred->[0] = $opt_server if defined $opt_server; 
90
$rmCred->[0] = $opt_server if defined $opt_server; 
91
$rmCred->[1] = $opt_user if defined $opt_user; 
91
$rmCred->[1] = $opt_user if defined $opt_user; 
92
$rmCred->[2] = $opt_passwd if defined $opt_passwd; 
92
$rmCred->[2] = $opt_passwd if defined $opt_passwd; 
93
 
93
 
94
my ($newData, $colNames) = getDataFromRm('Data', $ARGV[0], $rmCred, {dump => $opt_verbose, oneRow => 0, 'error' => 'No data found'});
94
my ($newData, $colData) = getDataFromRm('Data', $ARGV[0], $rmCred, {dump => $opt_verbose, oneRow => 0, 'error' => 'No data found'});
95
 
-
 
96
#
95
#
97
#   Determine the max width of every dislpay column (except the last)
96
#   Determine the max width of every dislpay column (except the last)
98
#       Add Colum Names as the first row of Data
97
#       Add Column Names as the first row of Data
99
#       Process column names and raw data
98
#       Process column names and raw data
100
#
99
#
-
 
100
my @colNames;
-
 
101
foreach my $entry ( @{$colData}) {
-
 
102
    $entry =~ s~^(.*?):~~;
-
 
103
    push @colNames, $1;
-
 
104
}
101
my @colWidth;
105
my @colWidth;
102
my $colNum = ($#$colNames) - 1;
106
my $colNum = ($#$colData) - 1;
103
unshift @{$newData}, $colNames;
107
unshift @{$newData}, \@colNames;
104
 
108
 
105
foreach my $entry ( @{$newData}) {
109
foreach my $entry ( @{$newData}) {
106
    for my $i (0 .. $colNum) {
110
    for my $i (0 .. $colNum) {
107
        if (!defined $entry->[$i] ) {
111
        if (!defined $entry->[$i] ) {
108
            $entry->[$i] = ''
112
            $entry->[$i] = ''
Line 130... Line 134...
130
#
134
#
131
foreach my $entry ( @{$newData}) {
135
foreach my $entry ( @{$newData}) {
132
    printf($fmtline, @{$entry});
136
    printf($fmtline, @{$entry});
133
}
137
}
134
 
138
 
135
 
-
 
136
#-------------------------------------------------------------------------------
139
#-------------------------------------------------------------------------------
137
# Function        : getDataFromRm 
140
# Function        : getDataFromRm 
138
#
141
#
139
# Description     : Get an array of data from RM 
142
# Description     : Get an array of data from RM 
140
#
143
#
Line 147... Line 150...
147
#                                       dump    - show results
150
#                                       dump    - show results
148
#                                       oneRow  - Only feth one row
151
#                                       oneRow  - Only feth one row
149
#                                       error   - Must find data
152
#                                       error   - Must find data
150
#                                       
153
#                                       
151
# Returns         : ref to array of data
154
# Returns         : ref to array of data
152
#                   ref to array of Column Names
155
#                   ref to array of Column Data
153
#
156
#
154
sub getDataFromRm
157
sub getDataFromRm
155
{
158
{
156
    my ($name,$m_sqlstr, $rmRef, $options ) = @_;
159
    my ($name,$m_sqlstr, $rmRef, $options ) = @_;
157
    my @row;
160
    my @row;
158
    my $data;
161
    my $data;
159
    my $colNames;
162
    my $colData;
160
 
163
 
161
    if (ref $options ne 'HASH') {
164
    if (ref $options ne 'HASH') {
162
        $options = {}; 
165
        $options = {}; 
163
    }
166
    }
164
 
167
 
Line 172... Line 175...
172
    }
175
    }
173
    my $sth = $RM_DB->prepare($m_sqlstr);
176
    my $sth = $RM_DB->prepare($m_sqlstr);
174
    if ( defined($sth) )
177
    if ( defined($sth) )
175
    {
178
    {
176
        if ( $sth->execute( ) ) {
179
        if ( $sth->execute( ) ) {
177
            $colNames = $sth->fetch_colNames();
180
            $colData = $sth->fetch_columndata();
178
            if ( $sth->rows ) {
181
            if ( $sth->rows ) {
179
                while ( @row = $sth->fetchrow_array ) {
182
                while ( @row = $sth->fetchrow_array ) {
180
                    if ($options->{data}) {
183
                    if ($options->{data}) {
181
                        Message ("$name: @row");
184
                        Message ("$name: @row");
182
                    }
185
                    }
Line 204... Line 207...
204
    }
207
    }
205
 
208
 
206
    if ($options->{dump}) {
209
    if ($options->{dump}) {
207
        DebugDumpData("$name", $data);
210
        DebugDumpData("$name", $data);
208
    }
211
    }
209
    return $data, $colNames;
212
    return $data, $colData;
210
}
213
}
211
 
214
 
212
#-------------------------------------------------------------------------------
215
#-------------------------------------------------------------------------------
213
#   Documentation
216
#   Documentation
214
#
217
#