Esta es la funcion original
Código:
Al intentar pasarlo no logro encontrar la relacion entre las tablas y los sequences.CREATE OR REPLACE FUNCTION "public"."get_sequence" ("sTabla" varchar, "sCampo" varchar) RETURNS varchar AS $body$ DECLARE sTabla ALIAS FOR $1; sCampo ALIAS FOR $2; sSecuencia VARCHAR; BEGIN SELECT s.relname INTO sSecuencia FROM information_schema.columns c, information_schema.tables t, pg_catalog.pg_statio_user_sequences s WHERE t.table_schema = 'public' AND c.table_name = t.table_name AND c.table_schema = 'public' AND c.table_name = sTabla AND c.column_name = sCampo AND -- c.column_default = 'nextval(''public.' || s.relname || '''::text)' AND c.column_default LIKE 'nextval(''public.' || s.relname || '%' AND s.schemaname = 'public'; RETURN sSecuencia; END; $body$
Asi esta la funcion en Oracle, aunque no funciona
Código:
Espero me puedan ayudar CREATE or replace FUNCTION get_sequence(sTabla IN VARCHAR2, sCampo IN VARCHAR2) RETURN VARCHAR2 AS sSecuencia VARCHAR2(255); BEGIN begin SELECT s.sequence_name INTO sSecuencia FROM all_sequences s, all_cons_columns c WHERE c.table_name = sTabla AND c.column_name = sCampo AND s.sequence_owner = 'PUBLIC'; EXCEPTION WHEN NO_DATA_FOUND THEN NULL; end; RETURN sSecuencia; END;