返回时,informix存储过程错误“发生语法错误。”

时间:2019-05-22 15:18:44

标签: sql syntax procedure informix

我已经编写了此存储过程,并且不断收到以下错误“发生语法错误”。我的意思是,我在RETURN上用**标记了它(这不在我使用的代码中) 您能帮我生气吗? 我不想在这方面寻求帮助,但被告知“看起来您的帖子大部分是代码;请添加更多详细信息。”并为此我打字更公正,所以我可以张贴此问题rrrrrrg更多嘘T!那今天疯狂驾驶我。

drop procedure CustomerSOPDetails(char(10));

create procedure CustomerSOPDetails(account char(10))

returning


char(10),
char(3),
char(3),
char(3),
char(40),
char(10),
char(30),
char(30),
char(30),
char(30),
char(30),
char(10),
char(30),
char(8),
char(10);


define account char(10);
define uzbusman1 char(3);
define uzsalrep1 char(3);
define uzsalcor1 char(3);
define name char(40);
define alphcode char(10);
define addr1 char(30);
define addr2 char(30);
define addr3 char(30);
define addr4 char(30);
define addr5 char(30);
define postcode char(10);
define telephone char(30);
define lastdate char(8);
define addtype char(10);



foreach
select
oecus.oecus_account,
oecus.oecus_uzbusman1,
oecus.oecus_uzsalrep1,
oecus.oecus_uzsalcor1,
ndmas.ndm_name,
ndmas.ndm_alphcode,
ndmas.ndm_addr1,
ndmas.ndm_addr2,
ndmas.ndm_addr3,
ndmas.ndm_addr4,
ndmas.ndm_addr5,
ndmas.ndm_postcode,
ndmas.ndm_telephone,
ndmas.ndm_lastdate,
ndmas.ndm_addtype

from oecus
inner join ndmas 
on oecus.oecus_account=ndmas.ndm_ndcode

where oecus_account = account


RETURN **
 account,
 uzbusman1,
 uzsalrep1,
 uzsalcor1,
 name,
 alphcode, 
 addr1,
 addr2,
 addr3,
 addr4,
 addr5,
 postcode, 
 postcode,
 lastdate,
 addtype
with resume;

end foreach

end procedure;

1 个答案:

答案 0 :(得分:3)

尝试使用INTO子句:

--drop procedure CustomerSOPDetails(char(10));

create procedure CustomerSOPDetails(account char(10))

returning


char(10),
char(3),
char(3),
char(3),
char(40),
char(10),
char(30),
char(30),
char(30),
char(30),
char(30),
char(10),
char(30),
char(8),
char(10);


define uzbusman1 char(3);
define uzsalrep1 char(3);
define uzsalcor1 char(3);
define name char(40);
define alphcode char(10);
define addr1 char(30);
define addr2 char(30);
define addr3 char(30);
define addr4 char(30);
define addr5 char(30);
define postcode char(10);
define telephone char(30);
define lastdate char(8);
define addtype char(10);



foreach
    select
    oecus.oecus_account,
    oecus.oecus_uzbusman1,
    oecus.oecus_uzsalrep1,
    oecus.oecus_uzsalcor1,
    ndmas.ndm_name,
    ndmas.ndm_alphcode,
    ndmas.ndm_addr1,
    ndmas.ndm_addr2,
    ndmas.ndm_addr3,
    ndmas.ndm_addr4,
    ndmas.ndm_addr5,
    ndmas.ndm_postcode,
    ndmas.ndm_telephone,
    ndmas.ndm_lastdate,
    ndmas.ndm_addtype

    into 
     account,
     uzbusman1,
     uzsalrep1,
     uzsalcor1,
     name,
     alphcode, 
     addr1,
     addr2,
     addr3,
     addr4,
     addr5,
     postcode, 
     telephone,
     lastdate,
     addtype

    from oecus
    inner join ndmas 
    on oecus.oecus_account=ndmas.ndm_ndcode
    where oecus_account = account

    RETURN 
     account,
     uzbusman1,
     uzsalrep1,
     uzsalcor1,
     name,
     alphcode, 
     addr1,
     addr2,
     addr3,
     addr4,
     addr5,
     postcode, 
     telephone,
     lastdate,
     addtype
    with resume;

end foreach

end procedure;

下一次,尝试减少SQL,这使事情更容易看到;)