Google Answers Logo
View Question
 
Q: ColdFusion web development/database ( No Answer,   3 Comments )
Question  
Subject: ColdFusion web development/database
Category: Computers > Programming
Asked by: jaseaux-ga
List Price: $5.00
Posted: 08 Sep 2005 13:41 PDT
Expires: 08 Oct 2005 13:41 PDT
Question ID: 565780
If I have a database field called ID and I have a number of cells in
that field, starting with GGL001, GGL002, and so on, and I have a
field called IDNew, what would my Cold Fusion code look like that
would take GGL001 and insert G001 in the IDNew cell (basically
removing the second G and the L) and then take GGL002 and insert G002
in the IDNew cell, and so on?
Answer  
There is no answer at this time.

Comments  
Subject: Re: ColdFusion web development/database
From: gustavoborges-ga on 13 Sep 2005 09:55 PDT
 
Which database are you using?
Subject: Re: ColdFusion web development/database
From: n8do2xg-ga on 15 Sep 2005 11:03 PDT
 
<!--------------------------------------------------------
This example will work with several database programs, such
as MS Access, SQL Server, Informix, Oracle.
--------------------------------------------------------->
<!--------------------------------------------------------
Declare an array...
--------------------------------------------------------->
<CFSET records = ArrayNew(1)>

<!--------------------------------------------------------
Get all records...

1) Replace 'myODBCDSN' in BOTH queries below with your 
   ODBC or OLE DB connection 
   to your database - under Cold Fusion Administrator -> ODBC 
   section. The connection to your database must have read and
   update permissions.

2) Replace 'myTableName' with the name of the table.

--------------------------------------------------------->
<CFQUERY Name="getMyRecords" DataSource="myODBCDSN">
	SELECT ID
	FROM myTableName
</CFQUERY>

<!--------------------------------------------------------
Set all records...
--------------------------------------------------------->
<CFLOOP QUERY="getAllCustomerIds">
	<CFSET records[ArrayLen(records)+1]=#ID#>
</CFLOOP>

<!--------------------------------------------------------
For each array element...
--------------------------------------------------------->
<CFLOOP Index="index" FROM="1" TO="#ArrayLen(records)#" STEP="1">
	<CFSET ID2 = records[index]>
	<CFSET IDNew = Mid(ID2, 1, 1) & Mid(ID2, 4, Len(ID2)-3)>
	<CFQUERY Name="updateMyRecords" DataSource="myODBCDSN">
		UPDATE myTableName
		SET IDNew = #IDNew#
	</CFQUERY>
</CFLOOP>
Subject: Re: ColdFusion web development/database
From: sigepjedi-ga on 17 Nov 2005 10:21 PST
 
I think this is your answer, assuming you always want it to start with G:

<!--- JUST TO SET ID TO SHOW YOU --->
<cfscript>
sampleID = 'GGL001';
</cfscript>

<cfoutput>
'G#removechars(sampleID , 1, 3)#'
</cfoutput>

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy