473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Update statement won't work

I have an update statement that I'm executing against Oracle database
from my C# code and it won't work.

UPDATE MenuCaptions SET Caption = N@Caption WHERE MenuId = @MenuId AND
CultureId = @CultureId

Caption is an nvarchar type. MenuId and CultureId are integers.
I get Exception with the following message: ORA-00933: SQL command not
properly ended.
It seems that problem lies in Caption column, because when I changed
command text to:

UPDATE MenuCaptions SET MenuId = @MenuId WHERE MenuId = @MenuId AND
CultureId = @CultureId

it would execute with no exceptions. Also, when I tried to execute
following statement from SQL editor in TOAD:

UPDATE MenuCaptions SET Caption = N'My Caption' WHERE MenuId = 1 AND
CultureId = 1

it would successfully update the record. I can't figure out why I am
getting exception.
Any help would be appreciated.

Feb 12 '07 #1
5 3434
Are you using OracleParameter objects wih this update SQL Statement? Not
enough info in your post to really figure out exactly what's wrong. What's
the Provider?
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Slavan" wrote:
I have an update statement that I'm executing against Oracle database
from my C# code and it won't work.

UPDATE MenuCaptions SET Caption = N@Caption WHERE MenuId = @MenuId AND
CultureId = @CultureId

Caption is an nvarchar type. MenuId and CultureId are integers.
I get Exception with the following message: ORA-00933: SQL command not
properly ended.
It seems that problem lies in Caption column, because when I changed
command text to:

UPDATE MenuCaptions SET MenuId = @MenuId WHERE MenuId = @MenuId AND
CultureId = @CultureId

it would execute with no exceptions. Also, when I tried to execute
following statement from SQL editor in TOAD:

UPDATE MenuCaptions SET Caption = N'My Caption' WHERE MenuId = 1 AND
CultureId = 1

it would successfully update the record. I can't figure out why I am
getting exception.
Any help would be appreciated.

Feb 12 '07 #2
Hi,

"Slavan" <vy*****************@gmail.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
|I have an update statement that I'm executing against Oracle database
| from my C# code and it won't work.
|
| UPDATE MenuCaptions SET Caption = N@Caption WHERE MenuId = @MenuId AND
| CultureId = @CultureId
|
| Caption is an nvarchar type. MenuId and CultureId are integers.
| I get Exception with the following message: ORA-00933: SQL command not
| properly ended.
| It seems that problem lies in Caption column, because when I changed
| command text to:

Can you post the actual code?

It seems you are missuing a " or a ' somewhere
--
Ignacio Machin
machin AT laceupsolutions com
Feb 12 '07 #3
I'm using Relational classes that were developed by my company and
there are specific classes for different databases like Oracle, SQL
server and DB2. Parameters should not create any problems, because
they work fine with other queries. There is something wrong with the
query itself or with the way I'm passing Caption value.
Here's some code, although I don't think it will be very helpfull,
since Command object is just a wrapper to make calls to back end.
Anyways:

string UpdateMenuCaptionsQuery = "UPDATE MenuCaptions SET Caption =
N@Caption WHERE MenuId = @MenuId AND CultureId = @CultureId";

Database db = DatabaseFactory.CreateDatabase("Oracle");
DBCommandWrapper command =
db.GetSqlStringCommandWrapper(UpdateMenuCaptionsQu ery);

command.AddInParameter("@Caption", DBDataTypeWrapper.UnicodeString,
caption.GetAttribute("value"));
command.AddInParameter("@MenuId", DBDataTypeWrapper.Int,
int.Parse(inputDoc.DocumentElement.GetAttribute("m enuid")));
command.AddInParameter("@CultureId", DBDataTypeWrapper.Int,
int.Parse(caption.GetAttribute("cultureid")));

db.ExecuteNonQuery(command);

Hopefully this gives more info to my problem.

Feb 12 '07 #4
Have you tried removing the "N" from "SET Caption = N@Caption"?
It probably doesn't belong there, since you are using a typed parameter.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Slavan" wrote:
I'm using Relational classes that were developed by my company and
there are specific classes for different databases like Oracle, SQL
server and DB2. Parameters should not create any problems, because
they work fine with other queries. There is something wrong with the
query itself or with the way I'm passing Caption value.
Here's some code, although I don't think it will be very helpfull,
since Command object is just a wrapper to make calls to back end.
Anyways:

string UpdateMenuCaptionsQuery = "UPDATE MenuCaptions SET Caption =
N@Caption WHERE MenuId = @MenuId AND CultureId = @CultureId";

Database db = DatabaseFactory.CreateDatabase("Oracle");
DBCommandWrapper command =
db.GetSqlStringCommandWrapper(UpdateMenuCaptionsQu ery);

command.AddInParameter("@Caption", DBDataTypeWrapper.UnicodeString,
caption.GetAttribute("value"));
command.AddInParameter("@MenuId", DBDataTypeWrapper.Int,
int.Parse(inputDoc.DocumentElement.GetAttribute("m enuid")));
command.AddInParameter("@CultureId", DBDataTypeWrapper.Int,
int.Parse(caption.GetAttribute("cultureid")));

db.ExecuteNonQuery(command);

Hopefully this gives more info to my problem.

Feb 12 '07 #5
On Feb 12, 2:51 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Have you tried removing the "N" from "SET Caption = N@Caption"?
It probably doesn't belong there, since you are using a typed parameter.
Peter
Yes, that solved the problem. Thanks.

Feb 12 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Falco Vermeer | last post by:
Hi, I tried to use the following query to update a value in one table with a value from another table: UPDATE tbl1 SET col1 = tbl2.col2 FROM tbl1, tbl2 WHERE tbl1. = tbl2.
2
by: MAS | last post by:
Below is a simple UPDATE that I have to perform on a table that has about 2.5 million rows (about 4 million in production) This query runs for an enourmous amount of time (over 1 hour). Both the...
0
by: M. David Johnson | last post by:
I cannot get my OleDbDataAdapter to update my database table from my local dataset table. The Knowledge Base doesn't seem to help - see item 10 below. I have a Microsoft Access 2000 database...
20
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
6
by: FayeC | last post by:
I really need help figuring this out. i have a db with mostly text fields but 2. The user_id field is an autonumber (key) and the user_newsletter is a number (1 and 0) field meaning 1 yes the ...
9
by: Acupuncture | last post by:
Hi, I am developing a JDBC application and I encountered this problem (DB2 for ISeries). I want to do a select for update and also use the fetch first rows clause. This is my sql statement: ...
2
by: Brett | last post by:
My database has 2 tables: Table1 & Table2. If a field is not null on a record in table2, then the not null fields in table1 that correspond to the records in table1 needs to be updated to match the...
6
by: clark070 | last post by:
Hi Guys, I mainly develop my program on a package tool provided by PHP Triad (from a long time ago) and I was running them solely on my notebook with no problem at all. I have this code that...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.