OracleDataAdapter.Fill 抛出 "SQL command not properly ended"

OracleDataAdapter.Fill throws "SQL command not properly ended"

OracleDataAdapter.Fill 抛出异常:"ORA-00933: SQL command not properly ended"。根据许多帖子,通常的罪魁祸首是末尾有一些空格或分号。我复制了语句并在 Oracle "Sql Developer" 上执行,它有效..

这是我的代码(有点)

var stmt = "SELECT fmly.fmly_id, fmly.fmly_key, fmly.fmly_db_view_nm, MI_DBUMS_UTIL.GET_BASELINE_TABLE_NAME(fmly.fmly_id) blTableName " +
                                    "FROM mi_families AS fmly WHERE fmly.fmly_type_cd = 'ENFA' " +
                                    "AND fmly.fmly_id not in (SELECT fmly_id from mi_exclude_families WHERE context_cd = 'REVERT') " +
                                    "AND EXISTS " + "(SELECT 1 FROM mi_entities_bl AS enty_bl WHERE fmly.fmly_id = enty_bl.fmly_id);";    

var conn = new OracleConnection("<connection string>");
var cmd = new OracleCommand(stmt, conn)
IDataAdapter adapter = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();

conn.Open();
cmd.CommandTimeout = 0;
adapter.Fill(ds)

有人可以帮我解决抛出异常的原因吗?

试试这个?

var stmt = "SELECT fmly.fmly_id, fmly.fmly_key, fmly.fmly_db_view_nm, MI_DBUMS_UTIL.GET_BASELINE_TABLE_NAME(fmly.fmly_id) blTableName " +
                                    "FROM mi_families AS fmly WHERE fmly.fmly_type_cd = 'ENFA' " +
                                    "AND fmly.fmly_id not in (SELECT fmly_id from mi_exclude_families WHERE context_cd = 'REVERT') " +
                                    "AND EXISTS " + "(SELECT 1 FROM mi_entities_bl AS enty_bl WHERE fmly.fmly_id = enty_bl.fmly_id)";    

var conn = new OracleConnection("<connection string>");
var cmd = new OracleCommand(stmt, conn);
IDataAdapter adapter = new OracleDataAdapter(cmd);
DataSet ds = new DataSet();

conn.Open();
cmd.CommandTimeout = 0;
adapter.Fill(ds);

删除 SELECT 语句末尾的分号,它应该可以工作。