Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
377 views
in Technique[技术] by (71.8m points)

c# - How to write parameterized oracle insert query?

I am using oracle as my back end and i write insert query as follows, i don't know is it correct way are not,

insert into Emp_table (SL_NO,empane,empid,salaray) values(1,'sree',1002 ,:salary);

here in query i am calculating salary with stored procedure and getting as my out parameter salary so i has to pass that to my insert query so how can i write. if i write like as shown i am getting below errors

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

kindly help me.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Microsoft deprecated their Oracle provider (System.Data.OracleClient) so use a third party provider such as Oracle's Data Provider for .NET. The code example below is essentially the same as FSX's answer, just without the convenience of the AddWithValue method.

command.Parameters.Add(new OracleParameter("SL_NO", 1));
command.Parameters.Add(new OracleParameter("empane", "sree"));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...