-- Buat fungsi execute_sql untuk digunakan oleh pendekatan SQL custom
-- Function to execute dynamic SQL (untuk administrator dan debugging)
CREATE OR REPLACE FUNCTION execute_sql(sql_query text)
RETURNS text
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
BEGIN
  EXECUTE sql_query;
  RETURN 'SQL executed successfully';
EXCEPTION WHEN OTHERS THEN
  RETURN 'Error executing SQL: ' || SQLERRM;
END;
$$; 