title: Passing parameter to callableSatatement - ORA-01008: not all variables bound
body: <p>I have a PL/SQL query with parameter:</p>
  <pre class="lang-java prettyprint-override"><code>plSqlQuery =    &quot;declare &quot;
                + &quot;  num integer := 1000;&quot;
                + &quot;  myStr varchar2(100):= ?;&quot;
                + &quot;begin &quot;
                + &quot;  dbms_output.put_line('abc');&quot;
                + &quot;  dbms_output.put_line('hello');&quot;
                + &quot;  dbms_output.put_line(myStr);&quot;
                + &quot;end;&quot;
  </code></pre>
  <p>My Java method is something like this:</p>
  <pre class="lang-java prettyprint-override"><code>public static void getData(String sqlQuery) throws SQLException, IOException{
      Statement s =conn.createStatement();
      try{
      s.executeUpdate(&quot;begin dbms_output.enable();end;);
      s.executeUpdate(sqlQuery);
      
      try{
      CallableStatement call = conn.prepareCall(&quot;declare num integer = 10000; begin dbms_output.get_lines(?, num); end;)
      }
      call.registerOutParameter(1,Types.ARRAY, &quot;DBMSOUTPUT_LINESARRAY&quot;);
      call.execute();
      
       Array array = null;
                      try {
                          array = call.getArray(1);
                          System.out.println(Arrays.asList((Object[]) 
                   array.getArray()));
                      }
                      finally {
                          if (array != null)
                              array.free();
                      }
  </code></pre>
  <p>Having both above now, I would like to execute my getData method, but I don't know how to pass a parameter to it (myStr).</p>
  <p>Can you please tell my where in my Java method I should set my string parameter?</p>
  <p>Should it be something like</p>
  <pre><code>s.setString(x, &quot;abcdefg&quot;);
  </code></pre>
  <p>or</p>
  <pre><code>call.setString(2, &quot;abcdefg&quot;);
  </code></pre>
  <p>it gives me an Oracle error like</p>
  <blockquote>
  <p>ORA-01008: not all variables bound</p>
  </blockquote>
  <p>I tried both to be honest but did not succeed.</p>