title: Getting error could not determine data type of parameter $2 while putting $2 in CONCAT()
body: <p>I'm trying to update story column using the CONCAT function in psql, but somehow keep getting error saying it could not determine data type of parameter $2. Where did I do wrong?</p>
  <pre><code>router.put('/:id', (req,res) =&gt; {
      db.query(`UPDATE stories SET story = CONCAT(story, $2) WHERE id = $1`,[req.params.id, 'text'])
        .then(response =&gt; {
          res.json({contribution:req.body.contribution_data, id:req.params.id});
        })
        .catch(err =&gt; console.log('Edit story error', err.message));
    });
  </code></pre>
  <h1>Update May, 06, 2021</h1>
  <p>Thanks for the suggestion @Ayzrian</p>
  <p>I did the PREPARE statement as suggested, but now I got a different error:</p>
  <blockquote>
  <p>&quot;error cannot insert multiple commands into a prepared statement&quot;</p>
  </blockquote>
  <p>I did basically the same format as suggested in the documentation:</p>
  <pre class="lang-js prettyprint-override"><code>router.put(&quot;/:id&quot;, (req, res) =&gt; {
  
      db.query(
        `
       PREPARE testStory (int, text ) AS UPDATE stories SET story = CONCAT(story, $2) WHERE id = $1;
       EXECUTE testStory ($1, $2);`,
        [req.params.id, &quot;text&quot;]
      )
  </code></pre>
  <h1>Update Solution</h1>
  <p>Turns out I can set the data type by doing the ::text after the paramterized value($1 in this case). Here's the solution code:</p>
  <pre><code>db.query(
        `
       UPDATE stories
       SET story = CONCAT(story, $1::text)
       WHERE id = $2;
       `,
        [&quot;testinggg&quot;, req.params.id]
      )
  </code></pre>
  <p>Thanks for the help anyways!</p>