[Zope-DB] how to insert values from select in one shot?

Charlie Clark charlie at egenix.com
Mon Mar 14 08:38:17 EST 2005


On 2005-03-14 at 14:09:14 [+0100], Jaroslav Lukesh <lukesh at seznam.cz> wrote:
> Dear sirs,
> 
> I need to past values from SELECT into INSERT to clone some values, but I
> receive error from MSSQL for SQL commands below (The name 'Customer_Id' is
> not permitted in this context. Only constants, expressions, or variables
> allowed here. Column names are not permitted.).
> 
> Would you like to know me, how I can successfully clone some filed values
> insde SQL sequence, please? Note, that jobs.Job_id is automatic index. Many
> thanks for your help.
> 

Hi Jaroslav,

depending on your DB this is quite easy using SELECT from within your 
INSERT, ie. invert the order of your statements. SQL is confusing and 
inconsistent like that. Check your documentation for complete details.

Charlie

INSERT INTO jobs

(Customer_Id, jobs.Problem,)
    
SELECT
    jobs.Job_id,
    jobs.Customer_Id,
    jobs.Problem,

FROM
    jobs

WHERE
    jobs.job_id = <dtml-sqlvar job_id type="int">


More information about the Zope-DB mailing list