Skip to main content
Inspiring
May 8, 2007
Answered

ListRest Function in SQL

  • May 8, 2007
  • 1 reply
  • 415 views
Hello,

I have a table with a file name like mainstreet_233232. Now I have another column in the same table as listing number. I want to replace the existing value of the listing number with the numbers in the file name. Here is my query

<cfquery name="getMLSNum" datasource="reo">
SELECT *
FROM disclosures
Where active = '1'
AND mlsNUM = '30456910'

</cfquery>


<cfoutput query="getMLSNum">
<cfquery name="updDisclosure" datasource="reo">
Update disclosures
set mlsNum = '#ListRest(GetMLSNum.file_name, "_")#'
Where RowID ='#getMLSNum.ROWID#'
AND mlsNum = '30456910'
</cfquery>
</cfoutput>

I am getting an error of "Invalid position in list"

Please help.

Thanks

This topic has been closed for replies.
Correct answer voodoofrdr
Thank you for your response.

I have figured out my problem. There was a filename without '_' in my data. So i had to put that condition of #ListFind(getMLSNum.mlsNum, '_')# before I can update the table.

1 reply

Inspiring
May 8, 2007
Your code looks ok, maybe it's the data. After your first query, do this.

<cfdump var="#getMLSNum#">
<cfdump var="#getMLSNum.file_name#">
<cfdump var="#ListRest(GetMLSNum.file_name, "_")#">

and see where it fails. By the way, you don't need the cfoutput tag around your update query.
voodoofrdrAuthorCorrect answer
Inspiring
May 8, 2007
Thank you for your response.

I have figured out my problem. There was a filename without '_' in my data. So i had to put that condition of #ListFind(getMLSNum.mlsNum, '_')# before I can update the table.