Hallo liebe Community,
ich habe mir ein Back-End in ASP NET Core erstellt, welches eine PostgreSQL-Datenbank mit dem Entity Framework anspricht. Jetzt möchte ich einen Trigger schreiben, der mir beim erstellen eines neuen Tupels eine Meldung ausgibt.
Dies habe ich (da ich noch keine große erfahrung hab) so (in pgAdmin 4) gemacht:
BEGIN
PERFORM pg_notify('new_Id', Id);
RETURN new;
END
aber wenn ich jetzt etwas zu meiner Datenbank hinzufügen will erhalte ich folgende Meldung von meinem Back-End:
An error occurred while updating the entries. See the inner exception for details.
---> Npgsql.PostgresException (0x80004005): 42703: Spalte »id« existiert nicht
at Npgsql.NpgsqlConnector.<ReadMessage>g__ReadMessageLong|194_0(NpgsqlConnector connector, Boolean async, DataRowLoadingMode dataRowLoadingMode, Boolean readingNotifications, Boolean isReadingPrependedMessage)
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
atMicrosoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
atMicrosoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
atMicrosoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
Exception data:
Severity: FEHLER
SqlState: 42703
MessageText: Spalte »id« existiert nicht
InternalPosition: 28
InternalQuery: SELECT pg_notify('new_Id', Id)
Where: PL/pgSQL-Funktion "Test"() Zeile 3 bei PERFORM
File: d:\pginstaller_12.auto\postgres.windows-x64\src\backend\parser\parse_relation.c
Line: 3359
Routine: errorMissingColumn
--- End of inner exception stack trace ---
BTW: Eine Spalte Id existiert ;-)
Seit bitte gnädig ;-) ich habe wie schon geschreiben keine große Erfahrung von Triggern
Über hilfe würde ich mich sehr freuen.
lg