- 论坛徽章:
- 0
|
CREATE OR REPLACE FUNCTION addres() RETURNS varchar(20) AS $$
DECLARE
conf configure%ROWTYPE;
BEGIN
SELECT cnf_type, cnf_local, cnf_http INTO conf FROM configure WHERE auto_id = '1';
IF m_conf.cnf_type == 0 THEN
RETURN conf.cnf_local;
ELSE
RETURN conf.cnf_http;
END IF;
END;
$$ LANGUAGE plpgsql;
查询
SELECT * FROM addres();
总是报告
ERROR: invalid input syntax for integer: "UpLoad "
SQL 状态: 22P02
事件背景 L/pgSQL function "addres" line 4 at SQL statement
conf表结构
CREATE TABLE configure
(
auto_id integer NOT NULL DEFAULT 1,
cnf_type smallint NOT NULL DEFAULT 0::smallint,
cnf_local character(120),
cnf_http character(120),
CONSTRAINT configure_key PRIMARY KEY (auto_id),
CONSTRAINT "typeChk" CHECK (cnf_type = 0 OR cnf_type = 1)
); |
|