Ask a Question related to Coldfusion Database Access, Design and Development.
-
JPrice #1
update database
I have a database where I need to input values that I calculate. I only need to
do this once, so I wanted to write a template to do this quickly. I am new to
CF, so I'm totally confused.
I have a query:
<cfquery name="qu_1" datasource="Drugs">
SELECT dose_country.uid, drugs.CompoundName AS Compound, drugs.Lowest AS
LowestSolubility, Dose_Country.MinDose
AS MinimumDose, Dose_Country.MaxDose AS MaximumDose, Country_ref.CountryName
AS Country, Dose_Country.MinDoNum AS MinDo, Dose_Country.MaxDoNum AS MaxDO
FROM ((drugs LEFT JOIN Dose_Country ON Dose_Country.CompoundName=drugs.ID)
LEFT JOIN Country_ref ON Country_ref.ID=Dose_Country.country)
</cfquery>
Then I calculate my values and display them on the screen:
<cfoutput query="qu_1">
<cfif #qu_1.LowestSolubility# EQ "">
<cfset MinDoNum="">
<cfset maxDoNum="">
<cfelseif #qu_1.country# EQ "JP">
<cfset MinDoNum=#qu_1.MinimumDose#/150/#qu_1.LowestSolubility#>
<cfset maxDoNum=#qu_1.MaximumDose#/150/#qu_1.LowestSolubility#>
<cfelse>
<cfset
MinDoNum=#qu_1.MinimumDose#/250/#qu_1.LowestSolubility#>
<cfset maxDoNum=#qu_1.MaximumDose#/250/#qu_1.LowestSolubility#>
</cfif>
<tr>
<td>#qu_1.Compound#</td>
<td>#qu_1.LowestSolubility#</td>
<td>#qu_1.MinimumDose#</td>
<td>#qu_1.MaximumDose#</td>
<td>#qu_1.Country#</td>
<td>#MinDoNum#</td>
<td>#maxDoNum#</td>
</tr>
</cfoutput>
In my table, I have zeros for the MinDoNum and MaxDoNum. I want to replace the
zeros with the calculated ones. What do I need to do to update my table?
Thanks,
Judy
JPrice Guest
-
Access Database will not update
I've got CF7 running on WinXP SP2 with Access 2000 database. Very simple table - 4 fields, all text except the Key. I can view, I can Insert, but... -
Use a CFC to update a database with a date
Hi All, I am trying to input a date in a database field with the current date. The datefield is in one table and I only want the date to be inserted... -
scheduled update of database
Hi, I am using MS Access as database. I need to update the table on the 1st day of every quarter. Is there anyway to achieve ASP or MSAccess. ... -
Update database using dataset
I have a number of text boxes that are all data bound to a data set. I would like the user to be able to make changes to these text boxes and then... -
update from between database
I have a Informix Database on Solaris and a SQL database. I need to update from Informix to SQL daily. Is there any easy way of doing it? BTW, I... -
Vbprog40 #2
Re: update database
So you would just like a basic update script.
<CFQUERY NAME="update_table" datasource="Drugs">
UPDATE Dose_Country
SET MinDoNum = #MinDoNum#,
MaxDoNum = #MaxDoNum#,
WHERE ID = #qu_1.UNIQUE RECORD ID#
</CFQUERY>
You will need to replace the WHERE ID with whatever you use to uniquely
identify your records. Also I asummed you had MinDoNum and MaxDoNum set as
Number Format in database. If this is not the case add ? ? around the value.
Hope this helps
Vbprog40 Guest
-
JPrice #3
Re: update database
I tried putting this in, but got a syntax error in the update statement. It
didn't like the WHERE statement. I have a primary key in my Dose_Country
table, called UID. So I put
WHERE ID=#qu_1.uid#
This is the error:
SQL UPDATE Dose_Country SET MinDoNum = 0.0524017475978, MaxDoNum =
0.0524017475978, WHERE ID = 44
DATASOURCE Drugs
VENDORERRORCODE -3503
SQLSTATE 42000
"Vbprog40" <webforumsuser@macromedia.com> wrote in message
news:dajogi$mkg$1@forums.macromedia.com...value.> So you would just like a basic update script.
>
> <CFQUERY NAME="update_table" datasource="Drugs">
> UPDATE Dose_Country
> SET MinDoNum = #MinDoNum#,
> MaxDoNum = #MaxDoNum#,
> WHERE ID = #qu_1.UNIQUE RECORD ID#
> </CFQUERY>
>
> You will need to replace the WHERE ID with whatever you use to uniquely
> identify your records. Also I asummed you had MinDoNum and MaxDoNum set as
> Number Format in database. If this is not the case add ? ? around the>
> Hope this helps
>
JPrice Guest
-
JMGibson3 #4
Re: update database
Somehow an extra comma wound up in your version of VB's sample:
MaxDoNum = 0.0524017475978,
JMGibson3 Guest
-
JPrice #5
Re: update database
Thanks! That did it.
"JMGibson3" <webforumsuser@macromedia.com> wrote in message
news:dak09c$4r2$1@forums.macromedia.com...> Somehow an extra comma wound up in your version of VB's sample:
>
> MaxDoNum = 0.0524017475978,
JPrice Guest
-
JPrice #6
Re: update database
"Vbprog40" <webforumsuser@macromedia.com> wrote in message
news:dajogi$mkg$1@forums.macromedia.com...value.> So you would just like a basic update script.
>
> <CFQUERY NAME="update_table" datasource="Drugs">
> UPDATE Dose_Country
> SET MinDoNum = #MinDoNum#,
> MaxDoNum = #MaxDoNum#,
> WHERE ID = #qu_1.UNIQUE RECORD ID#
> </CFQUERY>
>
> You will need to replace the WHERE ID with whatever you use to uniquely
> identify your records. Also I asummed you had MinDoNum and MaxDoNum set as
> Number Format in database. If this is not the case add ? ? around thePardon my ignorance, but what did you mean by adding ?? around the value?>
I've got another update which happens to be a string, and I'm getting a
syntax error.> Hope this helps
>
JPrice Guest
-
Vbprog40 #7
Re: update database
Thats cool. With SQL Statments you don't add ' ' around number / data-time
formated columns.
Example. If you have a column:
MyIDNUMBER = #MinDoNum# And this column is Number formated in the database
you would write it like this.
If you ahve a column like this:
MyFIRSTNAME = '#FNAME#' And this column is a non-number format, you would
add ' ' around the value.
Hope this helps.
Vbprog40 Guest



Reply With Quote

