title: Postgres : array value must start with "{" or dimension information
body: <p>I have created postgreSQL function in which i am executing the query like :  </p>
  
  <pre><code>CREATE OR REPLACE FUNCTION eapar.get_eform_detail(frm_id bigint,lvl_codes text)
  RETURNS TABLE(eform_detail_id bigint)
  AS
  $BODY$   
  
  DECLARE
  query text;
  level_codes text[];
  BEGIN
  query := 'SELECT eform_detail_id from eform_detail where form_id='||$1||' ';
  
  --some sql code
  --$2 is lvl_codes
  
  select into level_codes string_to_array($2, ','); --uptil here no problem
  
  RAISE NOTICE '%',level_codes; --printing {SRV,SAA} for 'SRV,SAA'::text
  
  query:= query || 'AND level_code = ANY('''||level_codes||''') '; --problem area
  
  --remaining sql code
  </code></pre>
  
  <p>Function has been created successfully but when i am calling like:  </p>
  
  <pre><code>select * from eapar.get_eform_detail(265,'SRV,SAA'::text)  
  </code></pre>
  
  <p>It gives the error:  </p>
  
  <pre><code>ERROR:  array value must start with "{" or dimension information
  LINE 1: ...orm_detail || 'AND level_code = ANY('''||level_codes||''') '
  </code></pre>
  
  <p>I am new to postgres functions. Don't know how to substitute array of text into variable using ANY operator, and get it executed. Please help. Thank you</p>