What a weird thing… Here I am coding along with everything happy. Basically, I’m just writing a utility program that will read records from one table, do a little processing and then write the data to another database.
One of my statements reads like this:
strSelectText = "SELECT * FROM VALID_TERM_TYPE;"
That’s cool… it works just like I would think it would. Another statement needs some criteria on it. That statement reads like this:
strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS='P';"
No problem, right? Buuzzzzzz…. When I try to execute that statement, I get the following error:
“Oracle.DataAccess.Client.OracleException ORA-00911: invalid character at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at MajorsImporter.Form1.Button1_Click(Object sender, EventArgs e) in C:\svn\MajorsDB2K8\MajorsImporter\Form1.vb:line 239″ “Oracle.DataAccess.Client.OracleException ORA-00911: invalid character at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure) at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src) at Oracle.DataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.DataAccess.Client.OracleDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at MajorsImporter.Form1.Button1_Click(Object sender, EventArgs e) in C:\svn\MajorsDB2K8\MajorsImporter\Form1.vb:line 239″
What the heck?!
I examine the statement again and everything looks right. Maybe I need to use double quotes instead:
strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS=""P"";"
NOPE. Arg…. mabye if I escape them like in C or something…:
strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS=\"P\";"
NOPE. Double Arg. I do a little researching and discover that when I add the criteria to the select statement, I have to leave the semi-colon off the end!!
strSelectText = "SELECT * FROM MJR_PGM WHERE PGM_STATUS='P';"
WOW… who would have thought that with no criteria, you the semi-colons are optional, but with criteria they’re forbidden.
Stupid computers…. who needs’em?