psql generate_series() - how to use it to populate multiple columns in a table?
<p>I have a table with the following structure: </p>

<pre><code>widgetnumber - text
dd  - text 
refnumber - text
</code></pre>

<p>widgetnumber and refnumber need to be populated with the same value... one that's generated using generate_series.<br>
dd will be a static value that's set once. </p>

<p>I have the following code: </p>

<pre><code>INSERT INTO widgets(widgetnum, dd, refnum)
SELECT i
FROM generate_series(100, 150) AS t(i), 
'somestaticstring',
SELECT p
FROM generate_series(100, 150) AS t(p);
</code></pre>

<p>But I must have a syntax error somewhere because this is not working. 
I'm getting the following error: </p>

<pre><code>psql:addwidgets.sql:11: ERROR:  syntax error at or near "'somestaticstring'"
LINE 4: 'somestaticstring',
        ^
</code></pre>

<p><strong>What I've tried</strong></p>

<p>I've tried to change the single quotes around the static text to double.  I've also tried this:</p>

<pre><code>INSERT INTO widgets(widgetnum, dd, refnum)
SELECT i
FROM generate_series(100, 150) AS t(i), 
SELECT 'somestaticstring',
SELECT p
FROM generate_series(100, 150) AS t(p);
</code></pre>

<p>But that also fails with a syntax error </p>