使用union all执行select语句并在Oracle上准备语句

时间:2018-01-31 08:54:54

标签: oracle pyodbc union-all bind-variables

我需要执行以下UNION ALL Select语句,我正在为WHERE条件使用绑定变量。我正在使用PyODBC for Oracle。当代码执行并返回结果时,与直接从TOAD运行相比,需要花费大量时间。任何想法是什么问题?

query = """
SELECT concat('Abstract ',display_order), abstract_text as field1, 
abstract_source_code, display_order 
From abstract
WHERE control_number = ? and control_level = ?
UNION ALL
SELECT 'cTitle', chapter_title, null as col2, null as col3 
From chapter
WHERE control_number = ? and control_level = ?
"""

result = cursor.execute(query, ['201728871', '005', '201728871', '005']).fetchall()
print(result)

0 个答案:

没有答案