あなたは(のみINSERT文、ないタイプのキャスティングまたはものではありません)に行くために私たちに
を多くを与えるが、ここでそれを行う方法を示したテストケースではありませんでした。
create table numTest(numA number(3) ,
numB number(10,8) ,
numC number(10,2))
/
--test insert
insert into numTest(numA, numB, numC) values (123, 12.1241, 12.12)
/
select * from numTest
/
/*
NUMA NUMB NUMC
---------------------- ---------------------- ----------------------
123 12.1241 12.12
*/
--delete to start clean
rollback
/
/*by marking these table.col%type we can change the table type and not have to worry about changing these in the future!*/
create or replace procedure odpTestNumberInsert(
numA_in IN numTest.numA%type ,
numB_in IN numTest.numB%type ,
numC_in IN numTest.numC%type)
AS
BEGIN
insert into numTest(numA, numB, numC) values (numA_in, numB_in, numC_in) ;
END odpTestNumberInsert ;
/
begin
odpTestNumberInsert(numA_in => 10
,numB_in => 12.55678
,numC_in => 13.13);
odpTestNumberInsert(numA_in => 20
,numB_in => 30.667788
,numC_in => 40.55);
end ;
/
select *
from numTest
/
/*
NUMA NUMB NUMC
---------------------- ---------------------- ----------------------
10 12.55678 13.13
20 30.667788 40.55
*/
rollback
/
大丈夫、私たちはテーブルを作成して、その中のデータは、(それを削除)しまった、それが動作を確認するための手順を作成した(その後、変更をロールバック)、すべてがよさそうです。だから、
OracleCommand cmd = new OracleCommand("odpTestNumberInsert", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.BindByName = true;
OracleParameter oparam0 = cmd.Parameters.Add("numA_in", OracleDbType.Int64);
oparam0.Value = 5 ;
oparam0.Direction = ParameterDirection.Input;
decimal deciVal = (decimal)55.556677;
OracleParameter oparam1 = cmd.Parameters.Add("numB_in", OracleDbType.Decimal);
oparam1.Value = deciVal ;
oparam1.Direction = ParameterDirection.Input;
OracleParameter oparam2 = cmd.Parameters.Add("numC_in", OracleDbType.Decimal);
oparam2.Value = 55.66 ;
oparam2.Direction = ParameterDirection.Input;
cmd.ExecuteNonQuery();
con.Close();
con.Dispose();
(私はC#のを仮定します)のは、.NET側に行ってみましょう。そして、物事を終えるために:
select *
from numTest
/
NUMA NUMB NUMC
---------------------- ---------------------- ----------------------
5 55.556677 55.66
私たちのすべてのデータが挿入されました。
あなたの部分にコードが追加されていない限り、正しいparamが渡されることを確認することをお勧めします。インサートに。上記は動作することを証明します。パラメータを作成するときに、あなたがそうすることができたときに
あなたははTO_NUMBER経由で変数を再キャストべきではありません。
お返事ありがとうございました。 – Emmanuel