首页 > 解决方案 > 如何将此 Pro*c 查询转换为 plsql 过程?

问题描述

''' select_wk910_exist() {

/* changes done for k3 */
MEMSET(wk910_exist_ccno);

EXEC SQL SELECT CARD_CUST_NO INTO :TAB1_exist_ccno FROM TAB1
         WHERE APPLN_BATCH_NO!=:app_batch_no
           AND CIF_NO=:cif_no AND  CODE = code and rownum<2 ;

if ( SQL_ERROR )
            {
                sprintf(error_mesg,"App batch no....%s    App serial no....%ld",
                                     app_batch_no.arr,app_serial_no);
                err130_details("Error while selecting EXIST CARD_CUST_NO from TAB1");
            }
    NULL_TERM(card_cust_no);

if (FOUND)
{
    MEMSET(card_cust_no);
    card_cust_no.len=sprintf(card_cust_no.arr,"%s",wk910_exist_ccno.arr);
    SET_LEN(card_cust_no);
    NULL_TERM(card_cust_no);
    MEMSET(cust_no);
    cust_no.len=sprintf(cust_no.arr,"%s",wk910_exist_ccno.arr);
    SET_LEN(cust_no);
    NULL_TERM(cust_no);
    cif_no_exist=1;
}'''

标签: oraclestored-proceduresplsqlprocedureproc

解决方案


根据您的评论,看看这是否有帮助:

declare
  l_ccn tab1.card_cust_no%type;
begin
  select card_cust_no 
    into l_ccn
    from tab1
    where appln_batch_no <> :app_batch_no
      and cif_no = :cif_no
      and code = :code
      and rownum < 2;
      
   -- query returned something, continue the procedure
   
   -- your code goes here; I don't know how to call Pro*C code from PL/SQL, sorry.
   
exception
  when no_data_found then
    -- select didn't return anything; handle the exception. As you didn't say how to handle
    -- it, I'm just doing nothing
    null;    
end;
/    

推荐阅读