문제

I'm getting an error when a trigger is run and trying to run the following function

CREATE OR REPLACE FUNCTION insert_new_sessions()
    RETURNS trigger AS
$$
DECLARE
BEGIN
SELECT dblink_exec('dbname=billing  port=5432','INSERT INTO md.radacct_test(radacctid,acctsessionid,acctuniqueid,username) select New.radacctid,New.acctsessionid,New.acctuniqueid,New.username' );

    RETURN NULL;
    EXCEPTION    WHEN OTHERS THEN RAISE NOTICE 'insert_new_sessions SQL ERROR: %', SQLERRM;

    RETURN NULL;
END;
$$  LANGUAGE plpgsql;

The error:

ERROR insert_new_sessions SQL ERROR: missing FROM-clause entry for table "new"
도움이 되었습니까?

해결책

Because you have NEW inside the string, thus interpreted as a string? Try concatenating the NEW.xxx values with the rest of the string. Eg. INSERT INTO md.radacct_test(...) SELECT ' || NEW.radacctid ||', ' || NEW.acctsessionid || ', ' || NEW.acctuniqueid || ', ' || quote_nullable(NEW.username));

다른 팁

I believe that the OLD and NEW keywords are case sensitive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top