我必须对 oracle 查询执行词法分析,并将查询分成 perl 中的各个部分(基于子句)。例如,考虑:
Select deleteddate,deletedby from temptable where id = 10;
我需要打印
select : deleteddate , deletedby
from : temptable
where : id = 10
我使用了这个代码片段:
my $parser= SQL::Statement->new();
$parser->{PrinteError}=1;
my $query = SQL::Statement->new("select deleteddate,deletedby from temptable where id =10",$parser);
my @columns = $query->columns();
print $columns[0]->name();
虽然这会打印 deleteddate,但当我在 select 子句中给出子查询时会失败:
Select deleteddate,deletedby,(select 1+1 from dual) from temptable where id = 10;
你能指出我正确的方向吗?
谢谢。