0
目標是在PostgreSQL中導入和使用過程(通過pgAdmin和Shell)。我的實驗結束於錯誤screen of mistake here。的代碼(從教程)在PostrgeSQL中推廣程序
例子:
CREATE OR REPLACE FUNCTION add_event(
title text,
starts TIMESTAMP,
ends TIMESTAMP,
venue text,
postal VARCHAR(9),
country CHAR(2)
)
RETURNS BOOLEAN
AS $$
DECLARE
did_insert BOOLEAN := FALSE;
found_count INTEGER;
the_venue_id INTEGER;
BEGIN
SELECT venue_id INTO the_venue_id
FROM venues v
WHERE v.postal_code=postal
AND v.country_code=country
AND v.name LIKE venue
LIMIT 1;
IF the_venue_id IS NULL THEN
INSERT INTO venues (name, postal_code, country_code)
VALUES (venue, postal, country)
RETURNING venue_id INTO the_venue_id;
did_insert := TRUE;
END IF;
RAISE NOTICE ‘Venue found %’, the_venue_id;
INSERT INTO events (title, starts, ends, venue_id)
VALUES (title, starts, ends, the_venue_id);
RETURN did_insert;
END;
$$ LANGUAGE plpgsql;
請將錯誤文本發佈到問題中而不是圖像中。這使我們可以更輕鬆地爲您提供幫助,並將錯誤消息編入索引以進行搜索。 – Graham