Ask a Question related to Coldfusion Database Access, Design and Development.
-
dj shane #1
Looping a list in SQL 2000 SPROC
Hey guys, just trying to learn something new today and wanted to convert one of
my cf pages to a sproc. This page just sets up security for the application. In
Coldfusion, all I'm doing is looping over a list.
The list is generated from a group of checkboxes, and looks like this.
<cfif isDefined("form.tech")>
<cfloop index="i" list="#form.tech#">
<cfquery name="UpdateTech" datasource="#application.dsn#">
INSERT INTO Q_SecurityUser_TBL
(Employee_ID, Security_ID, Lob_ID)
VALUES(<cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#i#">, 1,
<cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#Lob_ID#">)
</cfquery>
</cfloop>
</cfif>
How would I loop over this list in SQL?
dj shane Guest
-
Sproc Result as Comma Seperated List
Hey guys, I had built some photoblogging software in the past and am currently just revising it to bring it up to validated xhtml and running... -
parsing and looping over a list
All, I need to parse a list that looks like this: de={ts '2004-08-06 12:14:00'}|s=title header|entID=15,de={ts '2004-08-06 13:05:00'}|s=title... -
looping over a list problem
I am having a problem looping over a list with some elements that are empty. Here is a sample of the list: address_street=8349+White+Dr custom=... -
[PHP] Looping through a list - Newbie question
There are a lot of methods. The most common is using an array: $_SESSION = Array ("1","2","3","4","5"); foreach($_SESSION as $id) { echo $id; }... -
Looping through a list - Newbie question
explode() and then foreach are your friends :) explode() using the comma as your separator and then traverse the array using foreach. ... -
philh #2
Re: Looping a list in SQL 2000 SPROC
Hi Shane,
<cfquery name="UpdateTech" datasource="#application.dsn#">
INSERT INTO Q_SecurityUser_TBL
(Employee_ID, Security_ID, Lob_ID)
VALUES(<cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#i#">, 1,
<cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#Lob_ID#">)
</cfquery>
It's best to issue as few DB transactions as possible. I'd construct a bulk
insert string from the list:
<cfset myquery = "INSERT INTO Q_SecurityUser_TBL
(Employee_ID, Security_ID, Lob_ID)
SELECT ">
<cfloop index="i" list="#form.tech#">
<cfset myquery = myquery & i &", 1," & lob_id & "UNION SELECT ">
</cfloop>
<cfset myquery = mid(myquery,1,len(myquery-13))>
<cfoutput>#myquery#</cfoutput><!--- to see what the loop constructed --->
<cfquery name="UpdateTech" datasource="#application.dsn#">
#myquery#
</cfquery>
HTH,
philh Guest



Reply With Quote

