Solved

PL-SQL Delete statement from VB.NET Application

Posted on 2011-02-23
3
624 Views
Last Modified: 2012-05-11
Hi,
I am trying to delete some rows from Oracle Table using simple VB.NET Application.

 
Dim ClearSTR As String = "DELETE FROM STATEMENTS A " & _
           " WHERE EXISTS ( select  A.ACCNO " & _
           " from  reverselines T " & _
           " WHERE A.ACCNO = T.ACCNO AND A.FIYID= T.FIYID AND A.PERID = T.PERID AND A.LINENO = T.LINENO ); "

Dim daDelete As Oracle.DataAccess.Client.OracleDataAdapter = New Oracle.DataAccess.Client.OracleDataAdapter

daDelete.SelectCommand = New Oracle.DataAccess.Client.OracleCommand(ClearSTR, GetConnection)
daDelete.SelectCommand.ExecuteNonQuery()

Open in new window


and I am getting the following error message:

 
-- 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, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, Boolean bCheck)
   at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
   at BankRecon.Main.BankRemoveReverse_Click(Object sender, EventArgs e) in C:\Users\Rafal\Documents\Visual Studio 2008\Projects\BankRecon\BankRecon\Main.vb:line 2099

Open in new window


I checked the statement in in PL/SQL Developer application and there is no error, the command execute without any problem.

So where is the problem?

Thank you for your help.
0
Comment
Question by:rkanabus
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
Comment Utility
remove the ";" from the statment.
0
 
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 250 total points
Comment Utility
I think you need to use delete command instade of select try thjis

daDelete.DeleteCommand = New Oracle.DataAccess.Client.OracleCommand(ClearSTR, GetConnection)
daDelete.DeleteCommand.ExecuteNonQuery()
0
 

Author Comment

by:rkanabus
Comment Utility
Yes, fixed. I had to remove the ; character and then change the code to DeleteCommand..

Thanks for help.

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now