[Zope] RE: Dynamic SQL problem

Aaron Watters arw@ifu.net
Mon, 19 Apr 1999 10:21:32 -0400


Dear François-Régis Chalaoux,

You have a gadfly problem.

There are too many layers of syntax here for my
myopic eyes, however looking real hard at the following:

    insert into softdomain (idsoftware,iddomain)
    values( (select idsoftware from software where
    name = <!--#sqlvar name type=string-->),
    <!--#sqlvar iddomain type=string-->)

Gadfly only supports *literals* in "INSERT ... VALUES (...)"
You cannot put a query inside the parens.   Instead of

    insert into table (a,b) values ((select max(a) from table), 5)

you can do this

    insert into table (a,b)
    select max(a) as a, 5 as b from table

or even (Gadfly 1.0, not beta whatever)

   insert into table (a,b)
   select (select max(a) from table) as a, 5 as b from dual

And you can always do a rewrite similar to the second one I think.
And if "select * from dual" doesn't work upgrade.

The "INSERT INTO...VALUES" is highly optimized using the assumption
that no queries ever occur in the values...

Regards,  -- Aaron Watters http://www.chordate.com

===
stop procrastinating tomorrow.