为 DB2 中的函数提取 DDL 时出错
Error in extracting DDL for functions in DB2
我使用以下语句在 DB2 中使用 python 为特定函数提取 ddl。
函数名 = 'DEPTEMPLOYEES'
DDL = "select text from syscat.routines where routineschema = {}
and routinename = {} and routinetype = 'F'".format(user_schema,objs.upper())
cursor.execute(DDL)
但是当我尝试执行这条语句时出现错误。
ibm_db_dbi::ProgrammingError: SQLNumResultCols failed: [IBM][CLI
Driver][DB2/NT64] SQL0206N "DEPTEMPLOYEES" is not valid in the
context where it is used. SQLSTATE=42703\r SQLCODE=-206
谁能帮我解决这个错误
您是否尝试过类似的方法,在字符串周围添加单引号?
DDL = "select text from syscat.routines where routineschema = '{}'
and routinename = '{}' and routinetype = 'F'".format(user_schema,objs.upper())
cursor.execute(DDL)
根据错误,您的参数似乎已打印,引号丢失。这将参数变成了关键字,因此出现了错误消息。
我使用以下语句在 DB2 中使用 python 为特定函数提取 ddl。
函数名 = 'DEPTEMPLOYEES'DDL = "select text from syscat.routines where routineschema = {}
and routinename = {} and routinetype = 'F'".format(user_schema,objs.upper())
cursor.execute(DDL)
但是当我尝试执行这条语句时出现错误。
ibm_db_dbi::ProgrammingError: SQLNumResultCols failed: [IBM][CLI
Driver][DB2/NT64] SQL0206N "DEPTEMPLOYEES" is not valid in the
context where it is used. SQLSTATE=42703\r SQLCODE=-206
谁能帮我解决这个错误
您是否尝试过类似的方法,在字符串周围添加单引号?
DDL = "select text from syscat.routines where routineschema = '{}'
and routinename = '{}' and routinetype = 'F'".format(user_schema,objs.upper())
cursor.execute(DDL)
根据错误,您的参数似乎已打印,引号丢失。这将参数变成了关键字,因此出现了错误消息。