database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
ㆍPostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
PostgreSQL Q&A 7004 게시물 읽기
No. 7004
저장프로시져에서 오류남.
작성자
초보자
작성일
2007-01-12 17:21
조회수
4,074

아래 저장 프로시져에서 계속해서 오류남니다. 도와 주세요.


create function invitation_view5(varchar) returns setof record as $$

declare

       node RECORD;

begin

  for node in

       select icourseid,istate,sum(ipass) as ipass

                ,sum(iunpass) as iunpass

                ,sum(icandidate)as icandidate

                ,sum(interviewsend) as interviewsend

                ,sum(interviewdelay) as interviewdelay

                ,sum(itake) as itake

       from invitationdata

       where icourseid in (select courseregisterid from courseregister where coursestate=$1)

       group by icourseid,istate loop

               return next node;

       end loop;

return;

end;

$$ language 'plpgsql';



위와같이 만들고 실행은

select * from invitation_view5() as 

   t(icourseid int4,istate char,ipass int2,iunpass int2,icandidate int2,interviewsend int2,interviewdelay int2,itake int2);



오류메세지는 

ERROR:  wrong record type supplied in RETURN NEXT

CONTEXT:  PL/pgSQL function "invitation_view5" line 14 at return next


어디가 잘못된건지 잘 이해가 안가요..


테이블 컬럼별 그룹합을 구하는 것인데요.. 

프로시져 저장할때는 오류가 없는데 실행시 오류가 나네요.

이 글에 대한 댓글이 총 3건 있습니다.
create temp table test as
select icourseid,istate,sum(ipass) as ipass

                ,sum(iunpass) as iunpass

                ,sum(icandidate)as icandidate

                ,sum(interviewsend) as interviewsend

                ,sum(interviewdelay) as interviewdelay

                ,sum(itake) as itake

       from invitationdata

       where icourseid in (select courseregisterid from courseregister where coursestate=$1)

       group by icourseid,istate

해보신 후에요

\d test
해서 row의 데이터 타입을 확인하신 후에 t(필드 타입, 필드 타입,...)에 맞게 써줘 보세요
그리고 실행할 때
invitation_view5() 에 invitation_view5('') 처럼 인자를 넣어보세요아니면 생성문에서

language 'plpgsql' RETURNS NULL ON NULL INPUT;

끝에 이렇게 해보세요
신기배(소타)님이 2007-01-13 00:23에 작성한 댓글입니다.

잘은 모르겠지만....


프로시져 사용 쿼리에서 sum 이 모두 int2 로 되어 있는데


프로시져 내에서 sum 중 어느 하나라도 int4 가 있는게 아닐까요?


이럴테면 컬럼 타입은 맞는데.. 합한 값이 int4 형이어야 한다던지...하는...

tyro님이 2007-01-13 00:30에 작성한 댓글입니다. Edit

두분 모두 감사 합니다.
리턴되는 테이블의 data type 이 int8 이더군요.
data type을 바로하니 원하는 결과가 잘 나오는 군요.

초보자님이 2007-01-13 13:47에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
7007multi column update [3]
사이베이스가 싫어
2007-01-17
4498
7006'\' 문자 저장 하는 방법점 알려주세요 [1]
정주호
2007-01-15
3918
7005rule 로 다수의 seq 를 변경할 수 있나요? [2]
송효진
2007-01-14
3917
7004저장프로시져에서 오류남. [3]
초보자
2007-01-12
4074
7003copy문쓰는데 에러가 [1]
김승일
2007-01-12
4005
7002PostgreSQL 8.2 윈도우에서 설치시 문제 [2]
이은주
2007-01-12
5622
6999[질문]\d 와 같은 명령어가 있는지요? [1]
가우나라
2007-01-09
4121
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.023초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다