¾�ΥС�������ʸ�� �� 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9.6 | 9.5 | 9.4 | 9.3 | 9.2 | 9.1 | 9.0 | 8.4 | 8.3 | 8.2 | 8.1 | 8.0 | 7.4 | 7.3 | 7.2

40.2. PL/Tcl�ؿ��Ȱ���

PL/Tcl����Ǵؿ����������ˤϡ��ʲ���ɸ��Ū��CREATE FUNCTION��ʸ����Ѥ��Ƥ���������

CREATE FUNCTION funcname (argument-types) RETURNS return-type AS $$
    # PL/Tcl�ؿ�����
$$ LANGUAGE pltcl;

PL/TclU�Ǥ⡢�����pltclu����ꤷ�ʤ���Фʤ�ʤ����ʳ���Ʊ�ͤǤ���

�ؿ����Τϡ�ñ�ʤ뾮����Tcl������ץȤǤ��� �ؿ����ƤӽФ��줿�����������ͤ�Tcl������ץȤ�$1 ... $n�Ȥ����ѿ��Ȥ����Ϥ���ޤ��� ��̤��̾��̤�returnʸ����Ѥ���Tcl�Υ����ɤ����֤���ޤ���

�㤨�С�2�Ĥ������Τ����礭�������֤��ؿ��ϰʲ��Τ褦������Ǥ��ޤ���

CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS $$
    if {$1 > $2} {return $1}
    return $2
$$ LANGUAGE pltcl STRICT;

STRICT������դ��Ƥ��������� ����ˤ��ץ�����ޤϡ����Ϥ�NULL�ͤ�Ϳ����줿����Ƥ�����֤�ʤ����Ȥ��Ǥ��ޤ��� NULL���Ϥ��줿��硢�ؿ��Ϥޤä����ƤӽФ��줺��ñ��NULL�Ȥ�����̤���ưŪ���֤���ޤ���

��̩��strict�ˤǤʤ��ؿ��Ǥϡ������μºݤ��ͤ�NULL�Ǥ����硢�б�����$n�ѿ��϶�ʸ��������ꤵ��ޤ��� ���������NULL���ɤ����򸡽Ф��뤿��ˤϡ�argisnull�ؿ�����Ѥ��Ƥ��������� �㤨�С�������������NULL���⤦��������NULL�Ǥ��äơ�NULL�ǤϤʤ�����NULL�ΰ����������֤�tcl_max��ͤ���ȡ��ʲ��Τ褦�ˤʤ�ޤ���

CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS $$
    if {[argisnull 1]} {
        if {[argisnull 2]} { return_null }
        return $2
    }
    if {[argisnull 2]} { return $1 }
    if {$1 > $2} {return $1}
    return $2
$$ LANGUAGE pltcl;

��Ǽ������̤ꡢNULL�ͤ�PL/Tcl�ؿ������֤�����ˤϡ�return_null��¹Ԥ��Ƥ��������� ����ϡ��ؿ�����̩���ɤ����˴ط��ʤ����¹Ԥ��뤳�Ȥ��Ǥ��ޤ���

ʣ�緿�ΰ����ϡ�Tcl����Ȥ��ƴؿ����Ϥ���ޤ��� ���������̾��ʣ�緿��°��̾�Ǥ��� �Ϥ��줿�Ԥ�°����NULL�ͤξ�硢����°����������ˤϸ���ޤ��� �ʲ�����򼨤��ޤ���

CREATE TABLE employee (
    name text,
    salary integer,
    age integer
);

CREATE FUNCTION overpaid(employee) RETURNS boolean AS $$
    if {200000.0 < $1(salary)} {
        return "t"
    }
    if {$1(age) < 30 && 100000.0 < $1(salary)} {
        return "t"
    }
    return "f"
$$ LANGUAGE pltcl;

���ΤȤ�����ʣ�緿������ͤ��֤���ǽ�佸����֤���ǽ�ϥ��ݡ��Ȥ���Ƥ��ޤ���

���ΤȤ���PL/Tcl�ϥɥᥤ�󷿤����˥��ݡ��Ȥ��Ƥ��ޤ��� �ɥᥤ��򤽤��ظ�ˤ��륹���鷿��Ʊ�ͤ˰����ޤ��� ����ϡ��ɥᥤ��˴�Ϣ�������󤬶�������ʤ����Ȥ��̣���Ƥ��ޤ��� ����ϴؿ��ΰ����Ǥ����ꤢ��ޤ��󤬡�PL/Tcl�ؿ���ɥᥤ�󷿤��֤��褦������������ϴ����Ǥ���