Hola Jose, si entiendo bien lo que necesitas, esto lo vas a tener que hacer llevando tú los metadatos de las tablas, pues acceder a *comand* (plano) del la funcion *pg_event_trigger_ddl_commands* puede sercomplicado, pues como dice la doc este campo es : "A complete representation of the command, in internal format. This cannot be output directly, but it can be passed to other functions to obtain different pieces of information about the command." y es un tipo bastante diferente *pg_ddl_command*. Detalle aparte, en el campo *command_tag* vas a encontrar los tags listados en *https://www.postgresql.org/docs/current/event-trigger-matrix.html <https://www.postgresql.org/docs/current/event-trigger-matrix.html>*, no el nombre de la tabla. el cual puedes encontrar en *schema_name.*
*Saludos* El mar, 4 mar 2025 a las 2:15, Jose Mario Trujillo (<miac...@gmail.com>) escribió: > Saludos, > > Estoy buscando la forma de crear un trigger, lo que busco es que si se > agrega un atributo a una tabla, este se agregue tambien a a otra tabla. > > > Este es el codigo que tengo, pero la verdad no he podido ni imprimir las > linas de depuracion. > > CREATE OR REPLACE FUNCTION sync_test_base_claims() > > RETURNS event_trigger > > LANGUAGE plpgsql > > AS $$ > > DECLARE > > stmt TEXT; > > BEGIN > > RAISE NOTICE 'Trigger activated! Checking for ALTER TABLE commands...'; > > FOR stmt IN > > SELECT 'ALTER TABLE public.test_base_claims ' || substring(command_tag, 12 > ) > > FROM pg_event_trigger_ddl_commands() > > WHERE command_tag LIKE 'ALTER TABLE public.claims%' > > LOOP > > RAISE NOTICE 'Executing: SQL%', stmt; > > EXECUTE stmt; > > END LOOP; > > END; > > $$; > > > > CREATE EVENT TRIGGER sync_test_base_claims_trigger > > ON ddl_command_end > > WHEN TAG IN ('ALTER TABLE') > > EXECUTE FUNCTION sync_test_base_claims(); > > > ALTER table public.claims ENABLE TRIGGER ALL > > Algun consejo? > > > Jose Mario Trujillo > 2B5F B819 533E B033 AD55 D965 A2B5 D2AF 0FDF 371E >