I'm trying to make a redshift procedure that will give output on any table like say a row count for example. But I can't figure out how you are supposed to pass in a table name dynamically and get output. I'm trying to do something like this:
CREATE OR REPLACE PROCEDURE my_schea.test(t in varchar, o out varchar)
LANGUAGE plpgsql
AS $$
BEGIN
execute 'SELECT count(*) into ' || o || ' FROM ' || t || ';';
-- or something more complicated
END
$$
;
then I call like this:
call my_schema.test('myschema.mytable');
I can't seem to get the syntax right, any help would be appreciated. this specific syntax above gives me an error of:
cannot EXECUTE a null query string;