Tut mir leid, dass ich mir da so schwer tue
Aber dann müsste ja es entweder so aussehen
Code:
CREATE OR REPLACE FUNCTION f_destination() RETURNS trigger AS $$
BEGIN
SELECT INTO call_test.destination destination.dialcode
FROM destination
WHERE (NEW.[call_test.ausgangsnummer]) ~~ (destination.dialcode || '%'::text)
ORDER BY char_length(destination.dialcode) DESC
LIMIT 1 AS "location" ;
RETURN NEW;
END;
$$ LANGUAGE plpgsql; Da sagt er der Fehler würde bei den INTO liegen, ersetzt das Select into das Insert into?
oder mit einem Declare:
Code:
CREATE OR REPLACE FUNCTION f_destination() RETURNS trigger AS $$
BEGIN
declare ort alias for (
SELECT destination.dialcode
FROM destination
WHERE (NEW.[call_test.ausgangsnummer]) ~~ (destination.dialcode || '%'::text)
ORDER BY char_length(destination.dialcode) DESC
LIMIT 1) ;
INSERT INTO Call_test (destination) VALUES (ort);
RETURN NEW;
END;
$$ LANGUAGE plpgsql; oder?
Lesezeichen