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 2998 게시물 읽기
No. 2998
Operator --- IMP (>>> operator as logical implication)
작성자
정재익
작성일
2001-06-21 23:47
조회수
1,805

원본출처 : http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=189

 

 

Submitted on: 04-24-2001

Description:

Uses the >>> operator as logical implication (called IMP in many systems, including Microsoft Access. The truth table for IMP is

1 T F

T t f

F t t

 

It can be used for things like 'if condition one is true, condition two must be true; otherwise, it doesn't really matter' I use it frequently as a quick shorthand in CHECK clauses.

Code:

 

-- author: joel burton (jburton@scw.org)

-- public domain

 

CREATE FUNCTION "imp" (boolean,boolean) RETURNS boolean AS '

begin

if ($2) or (not $1) then return ''t'';

end if;

return ''f'';

END;

' LANGUAGE 'plpgsql' WITH ( iscachable );

 

COMMENT ON FUNCTION "imp" ( boolean,boolean ) IS 'Logical implication';

 

CREATE OPERATOR >>> (PROCEDURE = imp ,

LEFTARG = boolean ,

RIGHTARG = boolean );

[Top]
No.
제목
작성자
작성일
조회
3001Retrive comma separated PK attributes
정재익
2001-06-22
1906
3000Delete duplicate records in a table
정재익
2001-06-22
1910
2999Error catching
정재익
2001-06-21
1836
2998Operator --- IMP (>>> operator as logical implication)
정재익
2001-06-21
1805
2997Aggregate Function (2) -- first(), last()
정재익
2001-06-21
1733
2996Aggregate Function (1) -- comma-ify a list
정재익
2001-06-21
1868
2995Last-Change Updater
정재익
2001-06-21
1897
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.022초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다