Query formatting for Parameterized Queries
<p>I am using <code>pg-promise</code> to execute select query with like clause in PostgreSQL. Unfortunately the query is failing with error code as <code>08P01</code> and error message</p>

<blockquote>
  <p>bind message supplies 1 parameters, but prepared statement "" requires
  0</p>
</blockquote>

<p>The query is as follows</p>

<pre><code>select user_name, user_id from users where user_name like '$1#%'
</code></pre>

<p>I am using Parameterized query as</p>

<pre><code>var userQuery:pgp.ParameterizedQuery = new pgp.ParameterizedQuery("&lt;above_query&gt;", [userName]);
</code></pre>

<p>The API used for executing query is</p>

<pre><code>each(query:TQuery, values:any, cb:(row:any, index:number, data:Array&lt;any&gt;)=&gt;void, thisArg?:any):XPromise&lt;Array&lt;any&gt;&gt;;
</code></pre>

<p>I looked at the pg-promise examples but it ain't using LIKE clause with Parameterized Query.</p>

<p><strong>Environment Details are</strong></p>

<blockquote>
  <p>pg-promise: 4.3.2 </p>
  
  <p>PostgreSQL: 9.6 </p>
  
  <p>Node: 5.7.1</p>
</blockquote>

<p><strong>UPDATE: 1</strong>
I am able to run the query using <code>query</code> API (plain text sql) but not with <code>each</code>. Can anyone please explain why the LIKE clause is failing with <code>each</code> while using <code>Parameterized</code> API.</p>