[Dbix-class] subquery insert for MSSQL

fREW Schmidt frioux at gmail.com
Thu Jul 23 22:27:06 GMT 2009


On Thu, Jul 23, 2009 at 4:48 PM, Peter Rabbitson
<rabbit+dbic at rabbit.us<rabbit%2Bdbic at rabbit.us>
> wrote:

> On Wed, Jul 22, 2009 at 09:30:19AM -0500, fREW Schmidt wrote:
> >
> > Indeed.  The following works:
> >
> >
> > > INSERT INTO WorkScopeOperations (
> > >    department,
> > >    description,
> > >    id,
> > >    signature_required,
> > >    work_order_id,
> > >    work_scope_id
> > > ) SELECT
> > >    ?
> > >    '?,
> > >    MAX(id) + 1,
> > >    ?,
> > >    ?,
> > >    ?
> > >       FROM WorkScopeOperations me
> > >       WHERE ( ( work_order_id =3D ? AND work_scope_id =3D ? ) )
> >
> >
> >
>
> I don't quite follow... What are the bind values that the top placeholders
> take? Also '?, seems to be a typo... I think.
>

yeah, '? is a typo.  Sorry about that.

I'm not really sure what you don't understand about the above.  I'll retype
it without the placeholders I guess:

INSERT INTO WorkScopeOperations (
>    department,
>    description,
>    id,
>    signature_required,
>    work_order_id,
>    work_scope_id
> ) SELECT
>    'department foo',
>    'description blah',
>    MAX(id) + 1,
>    'mechanics sig required',
>    1121, -- work_order_id
>    2  -- work_scope_id
>       FROM WorkScopeOperations me
>       WHERE ( ( work_order_id =3D 1121 AND work_scope_id =3D 1 ) )
>

 Does that answer the question?
-- =

fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20090723/334=
97683/attachment.htm


More information about the DBIx-Class mailing list