Function - insert

HI everyone,

I’m new in metabase and I know that this is for reporting and statistics topic.

From metabase can I execute an insert to one table ? I did the test and this was not possible.

I tried creating a function(inside to do a insert) and from metabase to do the call a la function with a select but it did not work.

For example:
function:

CREATE OR REPLACE FUNCTION sbs.crear_reporte(fecha_corte DATE, correo TEXT, reporte TEXT)
RETURNS TEXT
AS $$

DECLARE codigo TEXT;
BEGIN

SELECT array_to_string(ARRAY(SELECT chr((65 + round(random() * 25)) :: integer)
FROM generate_series(1,5)), ‘’) || ‘-’ || fecha_corte as codigo into codigo;

INSERT INTO SBS_MANAGEMENT.REPORTES (codigo, reporte, fecha_corte, correo, fecha_alta)
VALUES (codigo, reporte, fecha_corte, correo, current_timestamp);

RETURN codigo;
END;
$$
LANGUAGE ‘plpgsql’;

Call from metabase:

SELECT sbs.crear_reporte(‘2012-12-15’, ‘jarivera@email’, ‘reporte_novedades’);

I did the testing from posgresql and work fine but from metabase did not work.

Is this possible ?
How can I do a insert from metabase?

I’m using the verison v0.27.1

Thanks

Jose Rivera

Also asked and discussed on GitHub here:

Another related topic here: Add action (delete) button on table view