我在 Windows 上使用由 ActiveState 构建的 Perl v5.12.3。DBD::Oracle 版本 1.27。DBI 版本 1.616。我正在按此特定顺序选择下面的数据,并希望以相同的顺序检索结果数据。下面是代码示例和一些示例。
SQL 片段(下面 $report_sql 的内容)
select student_number, lastfirst, counselor,
a.dateenrolled as "Date Enrolled 1", a.dateleft as "Date Left 1", a.termid as "Term ID 1", a.course_number as "Course Number 1",
a.expression as "Expression 1", b.dateenrolled as "Date Enrolled 2", b.dateleft as "Date Left 2",
b.termid as "Term ID 2", b.course_number as "Course Number 2", b.expression as "Expression 2"
Perl 代码片段
## run the resulting query
my $report_result = $dbh->prepare( $report_sql );
$report_result->execute();
while( my $report_row = $report_result->fetchrow_hashref())
{
print Dumper(\$report_row); ## contents of this posted below
$report_row 的打印 Dumper 的内容
$VAR1 = \{
'Expression 2' => 'x',
'LASTFIRST' => 'xx',
'Term ID 1' => 'xx',
'Date Enrolled 2' => 'xx',
'Course Number 1' => 'xx',
'Term ID 2' => 'xx',
'STUDENT_NUMBER' => 'xx',
'Date Left 2' => 'xx',
'Expression 1' => 'xx',
'COUNSELOR' => 'xx',
'Date Left 1' => 'xx',
'Course Number 2' => 'xx',
'Date Enrolled 1' => 'xx'
};
订单我希望它被打印
$VAR1 = \{
'STUDENT_NUMBER' => 'xx',
'LASTFIRST' => 'xx',
'COUNSELOR' => 'xx',
'Date Enrolled 1' => 'xx',
'Date Left 1' => 'xx',
'Term ID 1' => 'xx',
'Course Number 1' => 'xx',
'Expression 1' => 'xx',
'Date Enrolled 2' => 'xx',
'Date Left 2' => 'xx',
'Term ID 2' => 'xx',
'Course Number 2' => 'xx',
'Expression 2' => 'x'
};
需要注意的一点是,正在运行的这个查询是正在运行的众多查询之一。此特定脚本运行一系列查询并根据返回的结果生成报告。查询与 perl 脚本一起存储在 hd 上的文件中。查询被读入然后运行。并不总是选择相同的列。