【问题标题】:Error when calling oracle stored procedure using LSX使用 LSX 调用 oracle 存储过程时出错
【发布时间】:2013-09-19 13:10:31
【问题描述】:

我从以下复制了示例 LC LSX 代理以调用 Oracle 存储过程。

http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.main.doc%2FH_EXAMPLE_SAMPLE_LC_LSX_AGENT_TO_CALL_AN_ORACLE_STORED_PROCEDURE_9674_OVER.html

我用相关值修改了 .Server、.username 等。当我运行代理时,它会生成以下错误:

"此操作不能在没有字段的字段列表上执行"

遵循存储过程(从 sqlplus 客户端运行时可以正常工作)

PROCEDURE test_conn_txt1 ( p_in IN VARCHAR2 ,p_out OUT VARCHAR2) IS
l_out VARCHAR2(100);
BEGIN 

   --p_out :=p_in;
   l_out := 'Testing';--||to_char(p_in);
   p_out := l_out;  
   insert into xx_test1 values (to_char(p_in),to_char(p_out));
   commit;

END ;

下面是代理代码

Option Public
Option Explicit

UseLSX "*lsxlc"

Sub Initialize  
    Dim sess As New LCSession   
    Dim conn As New LCConnection ("oracle8")        

    'set the connection parameters...   
    conn.Server = "ora_prod"    
    conn.UserId = "user1"   
    conn.Password = "password"

    src.OracleTextFormat = "UTF8"


    'connect to the database... conn.Connect        
    'set the stored procedure owner and stored procedure name...    
    'conn.Owner = "OWNER"   
    conn.Procedure = "test_conn_txt1"
    conn.connect        

    'set Fieldnames property with any output parameters declared in the stored procedure... 
    'conn.Fieldnames = "p_out"      

    'declare any fields and fieldlists for input/output data... 
    Dim input_fieldlist As New LCFieldList  
    Dim output_parms As New LCFieldlist 
    Dim in_field_int As New LCField (1, LCTYPE_INT) 
    Dim in_field_text As New LCField (1, LCTYPE_TEXT)   
    Dim out1 As New LCField (1, LCTYPE_INT) 
    Dim out2 As New LCField (1, LCTYPE_TEXT)    
    Dim out As Double       

    'set the input parameters of the stored procedure...        
    Set in_field_text = input_fieldlist.Append ("p_in", LCTYPE_TEXT)    
    in_field_text.Text = "testing of stored procedure for input values"     

    'Set in_field_text = input_fieldlist.Append ("p_out", LCTYPE_TEXT)  
    'in_field_text.Text = "testing of stored procedure for input values"        

    Set out2 = output_parms.Append ("p_out", LCTYPE_TEXT)   
    out2.Text = "testing of stored procedure for input values"      


    'with the input parameters set, call the stored procedure...    
    'the declared output_parms fieldlist will hold the output parameters of the stored procedure... 

    out = conn.Call (input_fieldlist, 1, output_parms)  

    'fetch parameter(s) into the output_parms fieldlist...  

    out = conn.Fetch (output_parms)     
    'retrieve the parameter(s) from the output_parms fieldlist...   

    Set out1 = output_parms.GetField (1)    
    'Set out2 = output_parms.GetField (2)       
    'use the output parameter value(s) in your script...    

    Print "Output parameter 1 is " & out1.Value(0)  
    'Print "Output parameter 2 is " & out2.Text(0)      

    conn.Disconnect 

End Sub

【问题讨论】:

  • 您需要告诉我们脚本在哪个语句上失败。
  • 在 out = conn.Call (input_fieldlist, 1, output_parms) 之后代码在 out = conn.Fetch (output_parms) 失败

标签: lotus-domino lotus connector


【解决方案1】:

调用方法只支持存储过程的输入参数。如果要从存储过程中输出数据,则必须将其放入结果集中。然后可以使用Fetch 语句读取结果集。

经过进一步研究,我发现文档中存在冲突。你只需要尝试一些事情,然后告诉我们它是如何工作的。

这是一个链接:publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.designer.domino.main.doc/H_148034CHAPTER_9_ORACLE_8_CONNECTOR.html

尝试注释掉代理中以Set out2 = ... 和out2.Text = ... 开头的行。

【讨论】:

  • 我明白必须将结果字段列表对象传递给 .fetch 以获取存储过程输出,但结果字段没有任何数据。我运行了脚本,我得到“无法在没有字段的字段列表上执行此操作”错误,因为结果字段列表对象没有任何数据。我还被告知 lc lsx 不支持 oracle RECORD 数据类型作为输出。我想现有的工作示例代码供参考会有所帮助
猜你喜欢
  • 2014-08-16
  • 2015-12-12
  • 2015-12-23
  • 1970-01-01
  • 2015-09-17
  • 2013-12-18
  • 2018-10-04
  • 2012-05-18
  • 1970-01-01
相关资源
最近更新 更多