title: Adding a check in arguments json_to_set in postgres
body: <p>So I have</p>
  <pre><code>WITH input_students as (select *
          from json_to_recordset(json_data :: json -&gt; 'users')
          as student (organization_id bigint, section text, class text,admission_number text))
  </code></pre>
  <p>Now ,  I wanna make sure that the organization_id is not &quot;&quot; (if so , null would be preferable as a value),however I am not able to use  <code>case when ... then end</code> inside of arguments (ignore it as a beginner's  mistake if it is one). I haven't found any other resource to fix the bug of handling an empty string scenario. Any help would be appreciated.
  I tried doing</p>
  <pre><code>WITH input_students as (select *
          from json_to_recordset(json_data :: json -&gt; 'users')
          as student (organization_id bigint, section text, class text,admission_number text))
          insert into students select nullif(a.organization_id,''),a.section,a.class ,a.admission_number,'1',2,3,'true' from input_students a; 
  </code></pre>
  <p>but it provides with an error
  <code>&quot;error&quot;: &quot;org.postgresql.util.PSQLException: ERROR: invalid input syntax for integer: \&quot;\&quot;\n  Where: PL/pgSQL function hsg_put_user_class_section_v2(text) line 22 at SQL statement&quot;</code>
  The function is :</p>
  <pre><code>create or replace function hsg_put_user_class_section_v2(json_data text)
  returns table(org_id bigint,
  admission_number text,
  status text)
  LANGUAGE plpgsql
  AS $function$
  declare
      error_organization_id_invalid character varying := 'Organization ID is invalid !';
      error_admission_number_invalid character varying := 'Admission Number is invalid !';
      error_user_does_not_exist character varying := 'User does not exist !';
      error_class_not_found character varying := 'Class not found !';
      error_section_not_found character varying := 'Section not found';
      success_message character varying :='Updated Successfully';
  begin
  CREATE TEMP TABLE students (
          organization_id bigint,
          section text,
          class text,
          admission_number text,
          admission_number_in_hsg text,
          organization_id_in_hsg bigint,
          user_id bigint,
          status text
          )
          ON COMMIT DROP;
      
          WITH input_students as (select *
          from json_to_recordset(json_data :: json -&gt; 'users')
          as student (organization_id bigint, section text, class text,admission_number text))
          insert into students select nullif(a.organization_id,0),a.section,a.class ,a.admission_number,'1',2,3,'true' from input_students a;
          return query select
                  s.organization_id,
                  s.admission_number,
                  s.status
                  from students s;
  end;
  $function$ ;
  </code></pre>