在我的代码中,我有如下定义的视图。
VIEW Company_Person_Sd IS
Prompt = 'Company'
Company.Prompt = 'Company ID'
SELECT company_id company_id,
emp_no emp_no,
Get_Person(company_id, emp_no) person_id,
cp.rowid objid,
to_char(cp.rowversion) objversion,
rowkey objkey
FROM companies cp;
一个文件中可以定义多个视图(通常有20个或更多)。
我对下面这样的方法做了同样的事情,使用下面的正则表达式。(而且效果很好)
methodRegex = r"^\s*((FUNCTION|PROCEDURE)\s+(\w+))(.*?)BEGIN(.*?)^END\s*(\w+);"
methodMatches = re.finditer(methodRegex, fContent, re.DOTALL | re.MULTILINE | re.IGNORECASE | re.VERBOSE)
for methodMatchNum, methodMatch in enumerate(methodMatches, start=1):
methodContent=methodMatch.group()
methodNameFull=methodMatch.group(1)
methodType=methodMatch.group(2)
methodName=methodMatch.group(3)
方法示例
PROCEDURE Prepare___ (
attr_ IN OUT VARCHAR2 )
IS
----
BEGIN
--
END Prepare___;
PROCEDURE Insert___ (
attr_ IN OUT VARCHAR2 )
IS
----
BEGIN
--
END Insert___;
当我尝试对视图执行相同操作时,它会给出错误的输出。
事实上,我找不到如何抓住风景的尽头。我也尝试使用分号,结果输出错误。
查看我的正则表达式
viewRegex = r"^\s*(VIEW\s+(\w+))(.*?)SELECT(.*?)^FROM\s*(\w+);"
请帮我找出哪里做错了。提前谢谢。