title: Oracle 00932. 00000 - "inconsistent datatypes: expected %s got %s"
body: <p>well i'm still new in oracle, i'm trying to query a table with a subquery..it looks like this</p>
  
  <pre><code>select id_user, count(*) as jumlah from (select * from users where username = 'usr' and pass = 'pwd' and company_id = 'PAN' and status = 1) 
  group by id_user;
  </code></pre>
  
  <p>the above code works. but when i try to put it inside a stored procedure i got some errors like this</p>
  
  <p>here's the stored procedure</p>
  
  <pre><code>create type login_obj is object(jumlah integer);
  create type login_table is table of login_obj;
  create or replace function startLogin(u varchar, p varchar, cid varchar)
  return login_table
  is
    tabel login_table := login_table();
    the_count integer;
    the_sql varchar(200);
  begin
    the_sql := 'select id_user, count(*) as jumlah from (select * from users where username = ''' || u || ''' and pass = ''' || p || ''' and company_id = ''' || cid || ''' and status = 1) GROUP BY id_user';
    execute immediate the_sql into the_count;
  
    if the_count IS NOT NULL
    then
    begin
      tabel.extend;
      tabel(1) := login_obj(the_count);
    end;
    end if;
    return tabel;
  end;
  </code></pre>
  
  <p>then executing it by </p>
  
  <pre><code>select * from table (startLogin('usr','pwd','PAN'));
  </code></pre>
  
  <p>and here are the errors</p>
  
  <pre><code>SQL Error: ORA-00932: inconsistent datatypes: expected - got -
  ORA-06512: at "LUKI.STARTLOGIN", line 14
  00932. 00000 -  "inconsistent datatypes: expected %s got %s"
  </code></pre>
  
  <p>any idea?</p>