Skip to main content
June 11, 2008
Answered

cfquery columnlist on insert?

  • June 11, 2008
  • 2 replies
  • 570 views
Is Columnlist available off of query name, or ever result name in the query, after only an insert is performed using cfquery? I am unable to access it, and in doing a dump of the resultname, I do not see it in the struct.

If it isn't, wasn't it available in 7? Is there a reference to handling the change in any docs?

Thanks in advance for any direction.
    This topic has been closed for replies.
    Correct answer Dan_Bracuk
    For this,
    After an Insert through a query, we would run a 'collectFieldsFromQuery' and loop off of the ColumnList to build information back in to the cfobject 'self'

    Could you not do this?

    <cfset fields = "field1,field2,etc">
    <cfquery>
    insert into yourtable
    (#fields#)
    etc

    and then loop through the same variable to do whatever you were going to do with the columnlist?

    2 replies

    Dan_BracukCorrect answer
    Inspiring
    June 11, 2008
    For this,
    After an Insert through a query, we would run a 'collectFieldsFromQuery' and loop off of the ColumnList to build information back in to the cfobject 'self'

    Could you not do this?

    <cfset fields = "field1,field2,etc">
    <cfquery>
    insert into yourtable
    (#fields#)
    etc

    and then loop through the same variable to do whatever you were going to do with the columnlist?
    June 11, 2008
    Yes, we could do what you are saying. We are already discussing different ways to respond to ColumnList unavailability.

    ColumnList in an insert query allowed for dynamic usage from many pages. Without ColumnList on an Insert, it will mean more coding.

    Thanks again for your response.
    Inspiring
    June 11, 2008
    Only select queries have columns to list. Why were you looking for one? There might be other ways to achieve that objective.
    June 11, 2008
    We have a legacy application that uses cfobjects. After an Insert through a query, we would run a 'collectFieldsFromQuery' and loop off of the ColumnList to build information back in to the cfobject 'self'.

    I understand what you mean by 'Only select queries have columns to list' but I have to wonder why ColumnList is not in the variables as listed at http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_p-q_17.html#1102316.

    I can recode based on it being gone, but would like to know that it is truly unavailable before I start.

    When I use result="myResult" in the query with the insert, these are the variables seen in the dump of myResult:
    cached
    executiontime
    identitycol
    recordcount
    sql
    sqlparameters.

    But no ColumnList?

    Thanks for your response!