Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# PL/SQL调用不';t返回整个varchar2返回值_C#_Oracle - Fatal编程技术网

C# PL/SQL调用不';t返回整个varchar2返回值

C# PL/SQL调用不';t返回整个varchar2返回值,c#,oracle,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 Num

我用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#代码:

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


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

VarChar2是有限类型:SQL中多达4000字节,这对于@DmitryBychenkoI正在使用的托管客户端的那些字符来说已经足够了,您的代码在这里工作得很好。可能您必须使用
CLOB
/
NCLOB
LONG
(但是,
LONG
已经过时,不推荐使用)您能展示一下您的整个过程吗?另外,您的代码在这里返回-1,这会导致问题吗?
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");
    }