title: Executing Postgres procedure from bash script
body: <p>I have a bash script that will call a sql file holding a postgres stored procedure and passing the parameter variables</p>
  <pre><code>if [ &quot;$process_list&quot; != &quot;&quot; ]; then
   echo 'Processing 1:'$process_list;
  
   psql -h $PPC_Postgres -p $PPC_Postgres_Port -d $PPC_Postgres_DB -U $PPC_Postgres_User -o ${TXT_FILE} -a -f @$PUBDIR/printidsprocedure.sql -v p_list=$process_list
  fi
  </code></pre>
  <p>Inside the stored_procedure.sql file i defined a stored procedure which would accept a parameter.</p>
  <pre><code>create or replace procedure printids(
     id_array varchar
  )
  language plpgsql    
  as $$
  declare
  cur REFCURSOR;
  id int;
  begin
  
  open cur for select trim(token) from unnest(string_to_array(id_array,',')) token;
  
  loop
  
  fetch cur into id;
  exit when not found;
  raise notice '%','processing id:' || id;
  
  end loop;
  
  end;$$
  
  call printids(:'p_list'); //calling the procedure defined above with sql file
  </code></pre>
  <p>My question is, i am creating the procedure in sql file and trying to call the procedure with parameters within the same sql file?</p>