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
운영게시판
최근게시물
Sybase Q&A 1313 게시물 읽기
No. 1313
고수님의 손길을...
작성자
spirit
작성일
2005-10-06 17:08ⓒ
2005-10-06 17:08ⓜ
조회수
3,687

아래 저장프로시저를 만들었습니다.
색깔로 표시된 부분에 유의해서 볼때
주황색으로 표시된 부분의 조건을 바꾸어서 하고 싶은데
특히 'and Ttype=@Ttype' 이 부분만 따로 떼어서 조건문으로 하고 싶습니다.
Ttype의 값이 있으면 검색 조건에 넣고 없으면 검색조건에서 빠지는 겁니다.
몇 가지 해 보았는데, 잘 안되는군요..
고수님의 손길을 부탁드립니다.

 

create proc ctl_multiboard
@page int = NULL, @rowcount int = null, @Ttype char(2) = null, @sFlag int = null, @sValue char(2) = null
as
declare @selcount int, @startrownum int, @endrownum int

select @selcount = @rowcount * @page
select @startrownum = (@page - 1) * @rowcount + 1
select @endrownum = @page * @rowcount

SET ROWCOUNT @selcount
SELECT rownum=identity(4), writeno,title,username,password,email,content,readcnt,regdate,parentwriteno,founderwriteno,replydepth,replyorder,userip,gubun,appendflag,filetitle,filename,Ttype
INTO #ctl_board_temp FROM ctl_board
WHERE writeno <> 0 and
Ttype=@Ttypeorder by founderwriteno desc, replyorder asc, replydepth asc

SET ROWCOUNT 0
select writeno,title,username,password,email,content,readcnt,regdate,parentwriteno,founderwriteno,replydepth,replyorder,userip,gubun,appendflag,filetitle,filename,Ttype
from #ctl_board_temp
where rownum >= @startrownum and rownum <= @endrownum
drop table #ctl_board_temp

이 글에 대한 댓글이 총 4건 있습니다.

조건절을 다음과 같이 하세요.

 

WHERE writeno <> 0

and

(
  ( @Ttype is not null and Ttype=@Ttype )

or

  ( @Ttype is null )

)

존넘님이 2005-10-06 17:24에 작성한 댓글입니다. Edit

명쾌하고 빠른 답변 감사합니다.

그럼 이런 조건을 넣으려면 어떻게 해야 하는지요?

 

IF @sFlag = 1
    and title LIKE
'%'+@sValue+'%' 

spirit님이 2005-10-06 18:18에 작성한 댓글입니다.
이 댓글은 2005-10-06 18:25에 마지막으로 수정되었습니다. Edit

WHERE writeno <> 0

and

(
  ( @Ttype is not null and Ttype=@Ttype )

or

  ( @Ttype is null )

)

and

(

  ( @sFlag != 1 )

or

  ( @sFlag = 1 and title like '%'+@sValue+'%')

)

존넘님이 2005-10-07 13:06에 작성한 댓글입니다. Edit

해결되었습니다.

감사합니다. ^^

spirit님이 2005-10-07 18:45에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
1316ASE 12.5 에서 MSSQL의 sp_executesql 와 같은 프로시저가 있는지요? [1]
김지수
2005-10-10
3109
1315sybae SDK를 이용하여 c로 asiq에 연결할때? [1]
초보
2005-10-07
2901
1314xp 사용시 에러화면 부탁드립니다 ㅡㅜ
이주원
2005-10-07
2894
1313고수님의 손길을... [4]
spirit
2005-10-06
3687
1312초보자 질문.... [2]
김충관
2005-10-06
4411
1310테이블 생성쿼리 [1]
김마리아
2005-10-05
3810
1309ASIQ 에서 ADD DBSpace 관련 질문입니다. [1]
2005-10-04
3199
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.017초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다