Is there a way to return the generated_key value

Hi All,

If I have a query like this in a function:

return queryExecute("
    INSERT
        INTO myTable
        SET colName = :colValue
    ",
    {
        colValue = {
            value = arguments.colValue,
            sqltype = 'string'
        }
    }
);

Is there a way to return the generated_key value… I’ve tried adding
.GENERATED_KEY at the end of the queryExecute but it just complains the
column doesn’t exist, which is fair enough… If I add a result = 'myVar'
and remove the return and then return myVar.GENERATED_KEY that works
fine… just trying to be clean and have a single call.

Thanks.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon - mso http://www.mso.net - Lucee
Association Member http://lucee.org

Andrew,

I tried this to see if it would chain:

s = {};
WriteDump( s.insert( ‘hello’,‘there’ ).hello );

And it does on Lucee 5, but not on ACF 11, (however the structInsert()
version errors on both).

Reminds me of method chaining in jQuery. Have you ever done this elsewhere
in CFML?

Aria Media Sagl
+41 (0)76 303 4477 cell
skype: ariamediaOn Mon, Feb 13, 2017 at 12:11 AM, Andrew Dixon <@Andrew_Dixon> wrote:

Hi All,

If I have a query like this in a function:

return queryExecute("
    INSERT
        INTO myTable
        SET colName = :colValue
    ",
    {
        colValue = {
            value = arguments.colValue,
            sqltype = 'string'
        }
    }
);

Is there a way to return the generated_key value… I’ve tried adding
.GENERATED_KEY at the end of the queryExecute but it just complains the
column doesn’t exist, which is fair enough… If I add a result = 'myVar'
and remove the return and then return myVar.GENERATED_KEY that works
fine… just trying to be clean and have a single call.

Thanks.

Kind regards,

Andrew
about.me http://about.me/andrew_dixon - mso http://www.mso.net - Lucee
Association Member http://lucee.org


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/
msgid/lucee/CAG1WijURCfRDLGpqYv1hU-CqL4S7D83W%3DmOCqPs41mOSw2W1vQ%40mail.
gmail.com
https://groups.google.com/d/msgid/lucee/CAG1WijURCfRDLGpqYv1hU-CqL4S7D83W%3DmOCqPs41mOSw2W1vQ%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.