PL / SQL调用不返回整个varchar2返回值

时间:2016-04-25 09:49:45

标签: c# oracle

我在PL / SQL中编写了一个过程。在程序结束时我有这个:

    create or replace procedure Lottery_TitleBook(pout_count out varchar2) is
--get all the title-book.
cursor s1 is select * from gilads.titlebook;

rand Float;
randG VARCHAR2(100);
titleName VARCHAR2(100);
counter Number(38);
temp number(38);
res_row s1%rowtype; 

begin
 counter := 0;
 temp:=0;
--make random number generator:
randG := TO_CHAR(SYSTIMESTAMP,'YYYYDDMMHH24MISSFFFF');
DBMS_RANDOM.seed (val => randG);


--count how many title-book are in the cursor s1
open s1;
 loop
 fetch s1 into res_row;
 exit when s1%NOTFOUND;
 counter := counter +1;
 end loop;
close s1;

--the random number from  1 to counter 
rand := DBMS_RANDOM.value(low => 1, high => counter);

--get the titlebook.ID that determined by the random number:
open s1;
  loop
     fetch s1 into res_row;
     exit when s1%NOTFOUND;
     titleName := res_row.title;
   temp := temp + 1;
        if temp >= rand or temp = counter then exit;
        end if;
 end loop;
close s1;
--print the title book:
pout_count:='The winner book is:' ||chr(13)||titleName;

end;

当我从C#打电话给我时,我只得到“胜利者嘘声”。我的所有功能都存在这个问题。

这是我的C#代码:

using (OracleConnection con = new OracleConnection(connect))
{
    string temp;
    OracleCommand cmd = new OracleCommand();
    cmd.Connection = con;

    cmd.CommandText = "gilads.Lottery_TitleBook";//שם של פרוצדורה
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add("pout_count", OracleType.VarChar, 3200).Direction =
      ParameterDirection.Output;

    try
    {
        con.Open();
        int test = cmd.ExecuteNonQuery();
        if (test == 1)
            textBlock.Text = cmd.Parameters["pout_count"].Value.ToString();
        con.Close();
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message, "Exception Caught");
    }

当我将参数的大小设置为32000时,没有任何变化。有什么想法是错的吗?也许它与oracle有关在localhost ant上我需要做一些设置吗?因为在我的大学这段代码正常运作

我注意到每次运行该函数时都会得到不同长度的字符串

0 个答案:

没有答案