运行以下脚本:
import cx_Oracle
conn = cx_Oracle.connect(user = db_user, password = db_pwd, dsn = 'TULSA').
cur = conn.cursor()
sql = ("""
BEGIN
truncate table shop_ord_temp;
truncate table shop_ord_item_temp;
truncate table shop_cust_temp;
END;
""")
cur.execute(sql)
cur.close()
conn.close()运行此匿名块时收到此错误:
cx_Oracle.DatabaseError: ORA-06550: line 3, column 22:
PLS-00103: Encountered the symbol "TABLE" when expecting one of the following:
:= . ( @ % ;发布于 2020-09-04 08:08:45
您可以使用:
sql = ("""
BEGIN
execute immediate 'truncate table shop_ord_temp';
execute immediate 'truncate table shop_ord_item_temp';
execute immediate 'truncate table shop_cust_temp';
END;
""")这是一个PL/SQL功能,与Python无关。
https://stackoverflow.com/questions/63728178
复制相似问题