0
Simple Query Not Working
New Here
,
/t5/coldfusion-discussions/simple-query-not-working/td-p/111566
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
I have a pretty straight forward query and for the life of
me, when I try to output data from a field, I get an error:
Variable VEHICLESTOCK is undefined. (this pops up after inserting into page)
Here is my query:
<cfquery name="getUsedVehicles" datasource="#datasource#">
SELECT *
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
</cfquery>
When I try to use vehicleStock anywhere in the page, I get that error. I have checked db and fields are text. Not sure what I'm doing wrong.
Thanks
Terry
Variable VEHICLESTOCK is undefined. (this pops up after inserting into page)
Here is my query:
<cfquery name="getUsedVehicles" datasource="#datasource#">
SELECT *
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
</cfquery>
When I try to use vehicleStock anywhere in the page, I get that error. I have checked db and fields are text. Not sure what I'm doing wrong.
Thanks
Terry
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/coldfusion-discussions/simple-query-not-working/m-p/111567#M10838
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
Well your pulling info from 2 tables with the same column
name. I think you have to tell the query which table information to
pull from like
SELECT tbl_vehicle.vehicleStock as Stock1, tbl_images.vehicleStock as Stock1
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
and then output that #getUsedVehicle.Stock1# or
#getUsedVehicle.Stock2#
SELECT tbl_vehicle.vehicleStock as Stock1, tbl_images.vehicleStock as Stock1
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
and then output that #getUsedVehicle.Stock1# or
#getUsedVehicle.Stock2#
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/simple-query-not-working/m-p/111568#M10839
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
SELECT *
This may be causing problems. There are expected problems with this do
to the various systems trying their best to improve performance and thus
caching what they can. What happens is that when the query is run the
fields that are returned by SELECT * are cached. Then if the the
database design is changed, new fields are not found because the cached
list does not request them or or removed fields are attempted to be
returned causing another type of error.
Try listing out the required fields in the SELECT statement.
If that does not work, <cfdump var="#getUsedVehicles#"> is a great way
to make sure you are actually getting the expected record set returned
by the database.
Finally if your problem is with output, showing the output code is very
helpful.
This may be causing problems. There are expected problems with this do
to the various systems trying their best to improve performance and thus
caching what they can. What happens is that when the query is run the
fields that are returned by SELECT * are cached. Then if the the
database design is changed, new fields are not found because the cached
list does not request them or or removed fields are attempted to be
returned causing another type of error.
Try listing out the required fields in the SELECT statement.
If that does not work, <cfdump var="#getUsedVehicles#"> is a great way
to make sure you are actually getting the expected record set returned
by the database.
Finally if your problem is with output, showing the output code is very
helpful.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
WhozitsPop
AUTHOR
New Here
,
/t5/coldfusion-discussions/simple-query-not-working/m-p/111569#M10840
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
SELECT
tbl_vehicle.vehicleStock as Stock1,
tbl_vehicle.vehicleMake,
tbl_vehicle.vehicleModel,
tbl_vehicl.vehicleCondition,
tbl_images.vehicleStock as Stock2,
tbl_images.vehicleImage
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
But I get this error:
Error Executing Database Query.
No value given for one or more required parameters.
I just modified the query to this for the time being to see if I could see the dump. I have not referenced the vehicleStock in any cfoutput tag yet. The following URL shows the dump. I know the query won't work, but I had to do something to get the cfdump to display.
http://www.buysmp.ca/tradein.cfm
SELECT tbl_vehicle.*, tbl_images.*
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
tbl_vehicle.vehicleStock as Stock1,
tbl_vehicle.vehicleMake,
tbl_vehicle.vehicleModel,
tbl_vehicl.vehicleCondition,
tbl_images.vehicleStock as Stock2,
tbl_images.vehicleImage
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
But I get this error:
Error Executing Database Query.
No value given for one or more required parameters.
I just modified the query to this for the time being to see if I could see the dump. I have not referenced the vehicleStock in any cfoutput tag yet. The following URL shows the dump. I know the query won't work, but I had to do something to get the cfdump to display.
http://www.buysmp.ca/tradein.cfm
SELECT tbl_vehicle.*, tbl_images.*
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleStock = tbl_images.vehicleStock
AND tbl_vehicle.vehicleCondition = 'trade'
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
/t5/coldfusion-discussions/simple-query-not-working/m-p/111570#M10841
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
WhozitsPop wrote:
> But I get this error:
> Error Executing Database Query.
> No value given for one or more required parameters.
That is Access's not-very-informative way of saying the sql contains a column reference it does not understand.
One of the column references in your select is misspelled. It should probably be tbl_vehicle.vehicleCondition instead of tbl_vehicl.vehicleCondition,
> But I get this error:
> Error Executing Database Query.
> No value given for one or more required parameters.
That is Access's not-very-informative way of saying the sql contains a column reference it does not understand.
One of the column references in your select is misspelled. It should probably be tbl_vehicle.vehicleCondition instead of tbl_vehicl.vehicleCondition,
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
WhozitsPop
AUTHOR
New Here
,
/t5/coldfusion-discussions/simple-query-not-working/m-p/111571#M10842
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
Typo fixed, but still doing it. Is it possible I'm not
listing all fields necessary?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
/t5/coldfusion-discussions/simple-query-not-working/m-p/111572#M10843
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
Still doing which, returning an error "No value given for
..." or saying VEHICLESTOCK is undefined? VEHICLESTOCK is not a
column in your new query. You renamed those columns to: Stock1 and
Stock2. So those are the variable names you must use in your
output.
SELECT
tbl_vehicle.vehicleStock as Stock1,
...
tbl_images.vehicleStock as Stock2,
SELECT
tbl_vehicle.vehicleStock as Stock1,
...
tbl_images.vehicleStock as Stock2,
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
WhozitsPop
AUTHOR
New Here
,
/t5/coldfusion-discussions/simple-query-not-working/m-p/111573#M10844
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
<cfquery name="getUsedVehicles" datasource="buysmp">
SELECT tbl_vehicle.vehicleStock as stock1, tbl_vehicle.vehicleMake, tbl_vehicle.vehicleModel, tbl_images.vehicleStock as stock2, tbl_images.vehicleImage
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleCondition = 'trade'
AND tbl_vehicle.vehicleStock = tbl_images.vehicleStock
</cfquery>
it's working now thank you. Just decided to retype everything. Apparently I need a stronger prescription for my contacts 🙂 Thank you for your help.
SELECT tbl_vehicle.vehicleStock as stock1, tbl_vehicle.vehicleMake, tbl_vehicle.vehicleModel, tbl_images.vehicleStock as stock2, tbl_images.vehicleImage
FROM tbl_vehicle, tbl_images
WHERE tbl_vehicle.vehicleCondition = 'trade'
AND tbl_vehicle.vehicleStock = tbl_images.vehicleStock
</cfquery>
it's working now thank you. Just decided to retype everything. Apparently I need a stronger prescription for my contacts 🙂 Thank you for your help.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
WhozitsPop
AUTHOR
New Here
,
LATEST
/t5/coldfusion-discussions/simple-query-not-working/m-p/111574#M10845
Sep 12, 2008
Sep 12, 2008
Copy link to clipboard
Copied
I have more questions comng 🙂
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

