Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an Insert Statement in VB

strSTMT = "INSERT INTO TABLE_ONE (T_NUM, T_BATCH_ID,CREATE_DATE,LAST_UPDATE_DATE) " & _
"SELECT '" & iStoreNum & "', T_BATCH_ID,SYSDATE,SYSDATE FROM Tbl_BATCH a" & _
" WHERE T_BATCH_TYPE = 'C'" & _
" AND T_BATCH_AUTO_ASSIGN = 'Y'" & _
" AND NOT EXISTS (SELECT ROWID FROM TABLE_ONE b WHERE T_NUM = " & iStoreNum & _
" AND a.T_BATCH_ID = b.T_BATCH_ID )"

whenever i tried to execute the statement, it throws exception : 

ORA-06550: line 1, column 351:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 1, column 7:
PL/SQL: SQL Statement ignored

I took the same Statement and executed in Oracel SQL developer tool, 
It does not throws any error. 


What I have tried:

I even ended the statement with ; semi colon, but did not work.
To shed more light,Application was written on .NET 2.0, I changed it to 4.5. Previously app was refrencing to oracle.dataaccess.client dll but since it isn't supported any more I installed OracleManagedAccess Client, is it because of this?
Posted
Updated 9-Feb-17 23:49pm

1. Replace the strSTMT with a OracleCommand object, passing in the SQL query.
2. Change the SQL Query to be parameterised e.g.
SELECT :iStoreNum,
and
WHERE T_NUM = :iStoreNum and so on.
3. Construct the Oracle Parameters objects on the Oracle Command before executing it.
Here is an example:
c# - OracleCommand SQL Parameters Binding - Stack Overflow[^]
 
Share this answer
 
Your query seems wrong

C#
<pre>strSTMT = "INSERT INTO TABLE_ONE (T_NUM, T_BATCH_ID,CREATE_DATE,LAST_UPDATE_DATE) " & _
"SELECT '" & iStoreNum & "', T_BATCH_ID,SYSDATE,SYSDATE FROM Tbl_BATCH a" & _
" WHERE T_BATCH_TYPE = 'C'" & _
" AND T_BATCH_AUTO_ASSIGN = 'Y'" & _
" AND (Missing Column Name) NOT EXISTS (SELECT ROWID FROM TABLE_ONE b WHERE T_NUM = " & iStoreNum & _
" AND a.T_BATCH_ID = b.T_BATCH_ID )"



You missed a column name in where condition, Indicate a correct column name instead (Missing Column Name)

Let me know if it will not going to work.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900