Can you review this code and suggest improvements or possibly alternative approaches?…
- User
Can you review this code and suggest improvements or possibly alternative approaches?
CREATE OR REPLACE FUNCTION oprisk.parse_sql(p_sql character varying) RETURNS TABLE(attnum smallint, attname name, sql_type text) LANGUAGE plpgsql AS DECLARE c_temp_view_name constant varchar := 'parse_sql_temp_view$'; BEGIN execute format('drop view if exists %I', c_temp_view_name); execute format('create temp view %I as %s', c_temp_view_name, p_sql);
codereturn query select a.attnum, a.attname, format_type(a.atttypid, a.atttypmod) as sql_type from pg_attribute a inner join pg_class c on c.oid = a.attrelid where c.relname = c_temp_view_name and c.relkind = 'v'; execute format('drop view %I', c_temp_view_name); END;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.