gpt4 book ai didi

sql - Oracle SQL 存储过程重复错误和多行

转载 作者:行者123 更新时间:2023-12-04 13:39:22 26 4
gpt4 key购买 nike

我正在尝试为 ORACLE SQL 创建一个存储过程,但它不断抛出错误:

Error(1,1): PLS-00410: duplicate fields in RECORD,TABLE or argument list are not permitted

我没有看到任何重复的字段,所以我想知道为什么会发生这种情况(程序如下)。另外存储过程似乎只允许查询返回一行,有没有办法让它返回多于一行?

我看到了很多关于返回多行的问题,但都不是很清楚。我还需要多个存储过程,所以我想知道是否有任何变量冲突之类的。
CREATE OR REPLACE PROCEDURE ARTIST_CHECK(
p5_checkartist IN VARCHAR2,
p5_artist OUT TESTTABLE.artist%TYPE,
p5_thisweekpos OUT TESTTABLE.thisweekpos%TYPE,
p5_lastweekpos OUT TESTTABLE.lastweekpos%TYPE,
p5_title OUT TESTTABLE.title%TYPE,
p5_artist OUT TESTTABLE.artist%TYPE,
p5_entrydate OUT TESTTABLE.entrydate%TYPE,
p5_entrypos OUT TESTTABLE.entrypos%TYPE,
p5_peakpos OUT TESTTABLE.peakpos%TYPE,
p5_totalweek OUT TESTTABLE.totalweek%TYPE,
p5_thisweekdate OUT TESTTABLE.thisweekdate%TYPE)
IS
BEGIN
select t.THISWEEKPOS ,t.LASTWEEKPOS ,t.TITLE ,t.ARTIST ,t.ENTRYDATE ,t.ENTRYPOS ,t.PEAKPOS ,t.TOTALWEEK ,t.THISWEEKDATE
into p5_thisweekpos, p5_lastweekpos, p5_title, p5_artist, p5_entrydate, p5_entrypos, p5_peakpos, p5_totalweek, p5_thisweekdate
from(select artist as match, max(thisweekdate) as recent from testtable where upper(artist) like '%p5_checkartist%' group by artist), testtable t
where t.ARTIST = match and t.THISWEEKDATE = recent;
END;

最佳答案

下面有两次 .. 尝试每个代码省略一个

p5_artist OUT TESTTABLE.artist%TYPE,

关于sql - Oracle SQL 存储过程重复错误和多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27228986/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com