ORA-06550: 第 1 行,第 7 列:PLS-00306: 调用“INSERTBILL”时参数数量或类型错误;
您好,我在 Oracle 10g 服务器上调用存储过程时遇到问题。
这是我的表:
-- Create table
create table TMOBILE_R_BILLS
(
ID VARCHAR2(50) not null,
NO VARCHAR2(30) not null,
SURNAME VARCHAR2(60) not null,
NAME VARCHAR2(60) not null,
BILL_MONTH NUMBER not null,
VPS_TIME NUMBER not null,
VPS_PRICE_WITH_DISCOUNT NUMBER not null,
VPS_PRICE_WITHOUT_DISCOUNT NUMBER not null,
TMOBILE_TIME NUMBER not null,
TMOBILE_PRICE_WITH_DISCOUNT NUMBER not null,
TMOBILE_PRICE_WITHOUT_DISCOUNT NUMBER not null,
ORANGE_TIME NUMBER not null,
ORANGE_PRICE_WITH_DISCOUNT NUMBER not null,
ORANGE_PRICE_WITHOUT_DISCOUNT NUMBER not null,
O2_TIME NUMBER not null,
O2_PRICE_WITH_DISCOUNT NUMBER not null,
O2_PRICE_WITHOUT_DISCOUNT NUMBER not null,
INTER_TIME NUMBER not null,
INTER_PRICE_WITH_DISCOUNT NUMBER not null,
INTER_PRICE_WITHOUT_DISCOUNT NUMBER not null,
ROAMING_TIME NUMBER not null,
ROAMING_PRICE_WITH_DISCOUNT NUMBER not null,
ROAMING_PRICE_WITHOUT_DISCOUNT NUMBER not null,
GPRS_COUNT NUMBER not null,
GPRS_PRICE_WITH_DISCOUNT NUMBER not null,
GPRS_PRICE_WITHOUT_DISCOUNT NUMBER not null,
LM_TIME DATE not null,
TOTAL_TIME NUMBER not null,
TOTAL_PRICE_WITH_DISCOUNT NUMBER not null,
TOTAL_PRICE_WITHOUT_DISCOUNT NUMBER not null
)
这是存储过程:
CREATE OR REPLACE PROCEDURE INSERTBILL(
Id in varchar2, No in varchar2, Surname in varchar2, Name in varchar2,BillMonth in number,
VpsTime in number, VpsPriceWithDiscount in number,VpsPriceWithoutDiscount in number,
TmobileTime in number,TMobilePriceWithDiscount in number, TmobilePriceWithoutDiscount in number,
OrangeTime in number, OrangePriceWithDiscount in number, OrangePriceWithoutDiscount in number,
O2Time in number, O2PriceWithDiscount in number, O2PriceWithoutDiscount in number, InterTime in number,
InterPriceWithDiscount in number, InterPriceWithoutDiscount in number, RoamingTime in number,
RoamingPriceWithDiscount in number, RoamingPriceWithoutDiscount in number,
GprsTime in number,GprsPriceWithDiscount in number, GrpsPriceWithoutDiscount in number, LmTime in date,
TotalTime in number, TotalPriceWithDiscount in number, TotalPriceWithoutDiscount in number)
AS
BEGIN
INSERT INTO TMOBILE_R_BILLS (ID,NO,SURNAME,NAME,BILL_MONTH,
VPS_TIME,VPS_PRICE_WITH_DISCOUNT,VPS_PRICE_WITHOUT_DISCOUNT,
TMOBILE_TIME, TMOBILE_PRICE_WITH_DISCOUNT,TMOBILE_PRICE_WITHOUT_DISCOUNT,
ORANGE_TIME, ORANGE_PRICE_WITH_DISCOUNT,ORANGE_PRICE_WITHOUT_DISCOUNT,
O2_TIME, O2_PRICE_WITH_DISCOUNT, O2_PRICE_WITHOUT_DISCOUNT,
INTER_TIME, INTER_PRICE_WITH_DISCOUNT, INTER_PRICE_WITHOUT_DISCOUNT,
ROAMING_TIME, ROAMING_PRICE_WITH_DISCOUNT, ROAMING_PRICE_WITHOUT_DISCOUNT,
GPRS_COUNT, GPRS_PRICE_WITH_DISCOUNT,GPRS_PRICE_WITHOUT_DISCOUNT,
LM_TIME,
TOTAL_TIME, TOTAL_PRICE_WITH_DISCOUNT, TOTAL_PRICE_WITHOUT_DISCOUNT)
VALUES (Id,No,Surname, Name,BillMonth,
VpsTime,VpsPriceWithDiscount,VpsPriceWithoutDiscount,
TmobileTime,TMobilePriceWithDiscount,TmobilePriceWithoutDiscount,
OrangeTime,OrangePriceWithDiscount,OrangePriceWithoutDiscount,
O2Time, O2PriceWithDiscount, O2PriceWithoutDiscount,
InterTime,InterPriceWithDiscount,InterPriceWithoutDiscount,
RoamingTime,RoamingPriceWithDiscount,RoamingPriceWithoutDiscount,
GprsTime,GprsPriceWithDiscount,GrpsPriceWithoutDiscount,
LmTime,TotalTime,TotalPriceWithDiscount,TotalPriceWithoutDiscount);
END;
这是我的 C# 代码,我使用 SQL 批量插入:
public void InsertBills(List<CellPhoneBill> bills, int month)
{
var billsAsArrays = new BillDataAsArray(bills,month);
using (var conn = new OracleConnection(GenerateConnectionString()))
{
var cmd = new OracleCommand
{
Connection = conn,
CommandText = "INSERTBILL",
CommandType = CommandType.StoredProcedure,
ArrayBindCount = billsAsArrays.Ids.Count(),
};
cmd.Parameters.Add("Id", OracleDbType.Varchar2, billsAsArrays.Ids, ParameterDirection.Input);
cmd.Parameters.Add("No", OracleDbType.Varchar2, billsAsArrays.Numbers, ParameterDirection.Input);
cmd.Parameters.Add("Surname", OracleDbType.Varchar2, billsAsArrays.Surnames, ParameterDirection.Input);
cmd.Parameters.Add("Name", OracleDbType.Varchar2, billsAsArrays.Names, ParameterDirection.Input);
cmd.Parameters.Add("BillMonth", OracleDbType.Decimal, billsAsArrays.BillMonth, ParameterDirection.Input);
cmd.Parameters.Add("LmTime", OracleDbType.Date, billsAsArrays.LmTimes, ParameterDirection.Input);
cmd.Parameters.Add("VpsTime", OracleDbType.Decimal, billsAsArrays.VpsTimes, ParameterDirection.Input);
cmd.Parameters.Add("VpsPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.VpsPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("VpsPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.VpsPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TmobileTime", OracleDbType.Decimal, billsAsArrays.TmobileTimes, ParameterDirection.Input);
cmd.Parameters.Add("TmobilePriceWithDiscount", OracleDbType.Decimal, billsAsArrays.TmobilePriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TmobilePriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.TmobilePriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("OrangeTime", OracleDbType.Decimal, billsAsArrays.OrangeTimes, ParameterDirection.Input);
cmd.Parameters.Add("OrangePriceWithDiscount", OracleDbType.Decimal, billsAsArrays.OrangePriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("OrangePriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.OrangePriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("O2Time", OracleDbType.Decimal, billsAsArrays.O2Times, ParameterDirection.Input);
cmd.Parameters.Add("O2PriceWithDiscount", OracleDbType.Decimal, billsAsArrays.O2PriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("O2PriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.O2PriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("InterTime", OracleDbType.Decimal, billsAsArrays.InterTimes, ParameterDirection.Input);
cmd.Parameters.Add("InterPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.InterPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("InterPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.InterPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("RoamingTime", OracleDbType.Decimal, billsAsArrays.RoamingTimes, ParameterDirection.Input);
cmd.Parameters.Add("RoamingPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.RoamingPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("RoamingPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.RoamingPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("GprsTime", OracleDbType.Decimal, billsAsArrays.GprsTimes, ParameterDirection.Input);
cmd.Parameters.Add("GprsPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.GprsPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("GprsPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.GprsPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TotalTime", OracleDbType.Decimal, billsAsArrays.TotalTimes, ParameterDirection.Input);
cmd.Parameters.Add("TotalPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.TotalPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TotalPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.TotalPriceWithoutDiscounts, ParameterDirection.Input);
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
}
}
问题是,如果我在 PL/SQL Developer 中测试过程,则一切正常。但是,如果我尝试从 C# 代码调用此过程,则会收到此错误:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERTBILL'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERTBILL'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
抱歉,我发布了旧且错误的代码,“LmTime:参数位于 C# 代码中。但错误是相同的。我认为参数类型有问题。 在 oracle 中,所有内容都是数字,而在 C# 代码中,如果值是数字,则所有内容都是十进制。 我如何识别代码的问题部分?
谢谢您的建议。
Hi I have problem with calling store procedure on Oracle 10g server.
This is my table:
-- Create table
create table TMOBILE_R_BILLS
(
ID VARCHAR2(50) not null,
NO VARCHAR2(30) not null,
SURNAME VARCHAR2(60) not null,
NAME VARCHAR2(60) not null,
BILL_MONTH NUMBER not null,
VPS_TIME NUMBER not null,
VPS_PRICE_WITH_DISCOUNT NUMBER not null,
VPS_PRICE_WITHOUT_DISCOUNT NUMBER not null,
TMOBILE_TIME NUMBER not null,
TMOBILE_PRICE_WITH_DISCOUNT NUMBER not null,
TMOBILE_PRICE_WITHOUT_DISCOUNT NUMBER not null,
ORANGE_TIME NUMBER not null,
ORANGE_PRICE_WITH_DISCOUNT NUMBER not null,
ORANGE_PRICE_WITHOUT_DISCOUNT NUMBER not null,
O2_TIME NUMBER not null,
O2_PRICE_WITH_DISCOUNT NUMBER not null,
O2_PRICE_WITHOUT_DISCOUNT NUMBER not null,
INTER_TIME NUMBER not null,
INTER_PRICE_WITH_DISCOUNT NUMBER not null,
INTER_PRICE_WITHOUT_DISCOUNT NUMBER not null,
ROAMING_TIME NUMBER not null,
ROAMING_PRICE_WITH_DISCOUNT NUMBER not null,
ROAMING_PRICE_WITHOUT_DISCOUNT NUMBER not null,
GPRS_COUNT NUMBER not null,
GPRS_PRICE_WITH_DISCOUNT NUMBER not null,
GPRS_PRICE_WITHOUT_DISCOUNT NUMBER not null,
LM_TIME DATE not null,
TOTAL_TIME NUMBER not null,
TOTAL_PRICE_WITH_DISCOUNT NUMBER not null,
TOTAL_PRICE_WITHOUT_DISCOUNT NUMBER not null
)
here is store procedure:
CREATE OR REPLACE PROCEDURE INSERTBILL(
Id in varchar2, No in varchar2, Surname in varchar2, Name in varchar2,BillMonth in number,
VpsTime in number, VpsPriceWithDiscount in number,VpsPriceWithoutDiscount in number,
TmobileTime in number,TMobilePriceWithDiscount in number, TmobilePriceWithoutDiscount in number,
OrangeTime in number, OrangePriceWithDiscount in number, OrangePriceWithoutDiscount in number,
O2Time in number, O2PriceWithDiscount in number, O2PriceWithoutDiscount in number, InterTime in number,
InterPriceWithDiscount in number, InterPriceWithoutDiscount in number, RoamingTime in number,
RoamingPriceWithDiscount in number, RoamingPriceWithoutDiscount in number,
GprsTime in number,GprsPriceWithDiscount in number, GrpsPriceWithoutDiscount in number, LmTime in date,
TotalTime in number, TotalPriceWithDiscount in number, TotalPriceWithoutDiscount in number)
AS
BEGIN
INSERT INTO TMOBILE_R_BILLS (ID,NO,SURNAME,NAME,BILL_MONTH,
VPS_TIME,VPS_PRICE_WITH_DISCOUNT,VPS_PRICE_WITHOUT_DISCOUNT,
TMOBILE_TIME, TMOBILE_PRICE_WITH_DISCOUNT,TMOBILE_PRICE_WITHOUT_DISCOUNT,
ORANGE_TIME, ORANGE_PRICE_WITH_DISCOUNT,ORANGE_PRICE_WITHOUT_DISCOUNT,
O2_TIME, O2_PRICE_WITH_DISCOUNT, O2_PRICE_WITHOUT_DISCOUNT,
INTER_TIME, INTER_PRICE_WITH_DISCOUNT, INTER_PRICE_WITHOUT_DISCOUNT,
ROAMING_TIME, ROAMING_PRICE_WITH_DISCOUNT, ROAMING_PRICE_WITHOUT_DISCOUNT,
GPRS_COUNT, GPRS_PRICE_WITH_DISCOUNT,GPRS_PRICE_WITHOUT_DISCOUNT,
LM_TIME,
TOTAL_TIME, TOTAL_PRICE_WITH_DISCOUNT, TOTAL_PRICE_WITHOUT_DISCOUNT)
VALUES (Id,No,Surname, Name,BillMonth,
VpsTime,VpsPriceWithDiscount,VpsPriceWithoutDiscount,
TmobileTime,TMobilePriceWithDiscount,TmobilePriceWithoutDiscount,
OrangeTime,OrangePriceWithDiscount,OrangePriceWithoutDiscount,
O2Time, O2PriceWithDiscount, O2PriceWithoutDiscount,
InterTime,InterPriceWithDiscount,InterPriceWithoutDiscount,
RoamingTime,RoamingPriceWithDiscount,RoamingPriceWithoutDiscount,
GprsTime,GprsPriceWithDiscount,GrpsPriceWithoutDiscount,
LmTime,TotalTime,TotalPriceWithDiscount,TotalPriceWithoutDiscount);
END;
This is my C# code, I use SQL bulk insert:
public void InsertBills(List<CellPhoneBill> bills, int month)
{
var billsAsArrays = new BillDataAsArray(bills,month);
using (var conn = new OracleConnection(GenerateConnectionString()))
{
var cmd = new OracleCommand
{
Connection = conn,
CommandText = "INSERTBILL",
CommandType = CommandType.StoredProcedure,
ArrayBindCount = billsAsArrays.Ids.Count(),
};
cmd.Parameters.Add("Id", OracleDbType.Varchar2, billsAsArrays.Ids, ParameterDirection.Input);
cmd.Parameters.Add("No", OracleDbType.Varchar2, billsAsArrays.Numbers, ParameterDirection.Input);
cmd.Parameters.Add("Surname", OracleDbType.Varchar2, billsAsArrays.Surnames, ParameterDirection.Input);
cmd.Parameters.Add("Name", OracleDbType.Varchar2, billsAsArrays.Names, ParameterDirection.Input);
cmd.Parameters.Add("BillMonth", OracleDbType.Decimal, billsAsArrays.BillMonth, ParameterDirection.Input);
cmd.Parameters.Add("LmTime", OracleDbType.Date, billsAsArrays.LmTimes, ParameterDirection.Input);
cmd.Parameters.Add("VpsTime", OracleDbType.Decimal, billsAsArrays.VpsTimes, ParameterDirection.Input);
cmd.Parameters.Add("VpsPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.VpsPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("VpsPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.VpsPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TmobileTime", OracleDbType.Decimal, billsAsArrays.TmobileTimes, ParameterDirection.Input);
cmd.Parameters.Add("TmobilePriceWithDiscount", OracleDbType.Decimal, billsAsArrays.TmobilePriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TmobilePriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.TmobilePriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("OrangeTime", OracleDbType.Decimal, billsAsArrays.OrangeTimes, ParameterDirection.Input);
cmd.Parameters.Add("OrangePriceWithDiscount", OracleDbType.Decimal, billsAsArrays.OrangePriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("OrangePriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.OrangePriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("O2Time", OracleDbType.Decimal, billsAsArrays.O2Times, ParameterDirection.Input);
cmd.Parameters.Add("O2PriceWithDiscount", OracleDbType.Decimal, billsAsArrays.O2PriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("O2PriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.O2PriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("InterTime", OracleDbType.Decimal, billsAsArrays.InterTimes, ParameterDirection.Input);
cmd.Parameters.Add("InterPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.InterPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("InterPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.InterPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("RoamingTime", OracleDbType.Decimal, billsAsArrays.RoamingTimes, ParameterDirection.Input);
cmd.Parameters.Add("RoamingPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.RoamingPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("RoamingPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.RoamingPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("GprsTime", OracleDbType.Decimal, billsAsArrays.GprsTimes, ParameterDirection.Input);
cmd.Parameters.Add("GprsPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.GprsPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("GprsPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.GprsPriceWithoutDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TotalTime", OracleDbType.Decimal, billsAsArrays.TotalTimes, ParameterDirection.Input);
cmd.Parameters.Add("TotalPriceWithDiscount", OracleDbType.Decimal, billsAsArrays.TotalPriceWithDiscounts, ParameterDirection.Input);
cmd.Parameters.Add("TotalPriceWithoutDiscount", OracleDbType.Decimal, billsAsArrays.TotalPriceWithoutDiscounts, ParameterDirection.Input);
try
{
conn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
finally
{
conn.Close();
}
}
}
Problem is if I test procedure in PL/SQL developer everything works good. But if I try call this procedure from C# code I get this error:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERTBILL'
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'INSERTBILL'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
SORRY I PUBLISHED OLD AND BAD CODE, "LmTime: paramater is in C# code. But error is same. I think that something is bad with type of parameters.
In oracle all is number and in C# code all is decimal if value is number.
How can I identify problem part of code?
Thank you for advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您发布的 C# 代码中的参数顺序是否正确?在您的参数定义中,它是第六个参数。在过程参数列表中,它是倒数第四个。如果您发布的代码确实是您遇到错误的原因,那就可以解释了。
如果没有,那么我将如何修改我的过程以提供参数列表后半部分的默认值,并将它们从 C# 代码中删除。如果仍然失败,请为剩余参数的后半部分提供默认值,从代码中删除它们,然后再次运行。重复直到发现问题。
Is the order of your parameters in the C# code you posted correct? In your parameter definitions, it's the 6th parameter. In the procedure parameter list, it's 4th from the end. That would explain it if indeed your posted code is what you're getting the error with.
If not, then how I'd go about it is to modify my procedure to provide defaults for the second half of the parameter list, and take them out of your C# code. If it still fails, provide defaults for the second half of the remaining parameters, remove them from the code, and run again. Repeat until problem is identified.
您在 C# 调用中设置了 29 个参数,您的存储过程有 30 个参数。因此
调用“INSERTBILL”时参数的数量或类型错误
。编辑:您的 C# 代码中缺少
LmTime
参数。You set 29 parameters in your C# call, your stored procedure has 30 parameters. Hence
wrong number or types of arguments in call to 'INSERTBILL'
.EDIT: You're missing the
LmTime
parameter in your C# code.