Valuelist Function in MX vs CF 5
Used cfquery to return integer data type.
MX Example:
<cfset myList = valuelist(query.integerData)>
Output: 1.0,2.0,3.0,4.0
CF 5 Example:
<cfset myList = valuelist(query.integerData)>
Output: 1,2,3,4
Observation
You would notice that MX appends a decimal digit towards the
end of each internet using ValueList Function.
How do I get rid of that??
Thanks Dan.
Here is the problem.
You cant use numberformat inside valuelist or any other
function.
eg:
valuelist(numberformat(query.integerData)) - cant work.
More Analysis:
I just ran a simple output from my code:
Using <cfoutput query>
It returns as 1,2,3,4
After using the same query with valuelist
It returns as 1.0,2.0,3.0,4.0
And the field in the database 10g is number.
Similar Messages
-
Equivalent of ValueList function in SQL
Hi,
Is there an equivalent of valueList function in SQL? Here's
what I am trying to do:
Suppose I have the following table:
Name -- Color
John -- Green
John -- Red
Mike -- White
I want to do a query such that the colors are aggregated as a
list. So the result would be:
Name -- Color List
John -- Green, Red
Mike -- White
The only way I could think of doing this is to loop through
each name in the table and doing ValueList in each loop. Is there a
better way?
Thanks.
Min> I want to do a query such that the colors are aggregated
as a list.
If it _must_ be done in sql, there are some database options.
Such as the one mentioned above. There are also some interesting
approaches using xml path and cross apply with MS SQL 2005. I do
not know about other databases.
http://databases.aspfaq.com/general/how-do-i-concatenate-strings-from-a-column-into-a-sing le-row.html
Bear in mind there are some performance implications with all
of the methods. For example, a udf would execute once for each
name. So the more records, the greater the impact.
Another possibility is to use cfoutput's group attribute to
create a list for each name. Assuming that is feasible .. -
ValueList function error after migrating CF8 to CF10
Hi All,
We are migrating our reports from CF8 to CF10. (uninstalled existing CF8 and installed CF10) in 32bit OS.
After upgradation of CF10, tried to open our report, then we got the below error.
----------------------error --------------------------
The ValueList() function has an invalid parameter: DS_ODBC_LIST.entry.Parameter 1 of function ValueList which is now DS_ODBC_LIST.entry must be pointing to a valid query name.
------------------error-----------------------
-------------original code -----------------------------------
<CFREGISTRY
ACTION=GETALL
NAME="DS_ODBC_List"
TYPE="ANY"
BRANCH="HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI">
<cfset DSNnames = valueList(DS_ODBC_LIST.Entry)>
-----------------------------original code--------------------------
Then tried to dump / print the DS_ODBC_List using CFoutput/cfdump then we got error like:
Variable DS_ODBC_LIST is undefined
in CF Administrator the tag CFREGISTRY is in enabled tags list.
can some one suggest me what the alternate tag / any patch I can use to solve the issue ?
Thanks in advance!!!At a guess it may be choking on the underscores in the query name. You could try referencing it like:
<cfset DSNnames = valueList(variables["DS_ODBC_LIST"].Entry)> -
i have 2 text boxes from the form for user to enter an email address. those are not requied, meaning sometime i have one email, or two emails. I stored both emails into one field in the table. such as: [email protected] [email protected] .
On the edit page, i want to retireve both emails but each email will go into one text box.
i am thinking about values list
<cfset emailList = ValueList(qry.email , ',' />
but i am getting an error "Complex construct are not supported with fuction ValueList." and i am not sure if i am going to the right direction?
thanks
ktThe purpose of the ValueList() function is to take values in a field from multiple records in the record set and make a list out of them. Which, if you had a well normalize database design, you would be retreiving.
I.E. qry_email
ID
EMAIL
1
[email protected]
2
[email protected]
3
[email protected]
<cfoutput>#valueList(qry_email.email)#</cfoutput>
will return "[email protected],[email protected],[email protected]".
You have a un-normalized table field that contains a list of values. I presume you would like to process the items in that list individually.
The list functions are probably what you would like to use.
I.E.
<cfloop list="#qry_email.email#" item="x">
<cfoutput>#x#</cfoutput>
</cfloop>
There are many other list functions you can use, listFirst(), listLast(), listGetAt(), etc.
Of course the professional in me would suggest that you properly normaize your database design if at all possible. -
How do I write a select statement to see if table field is in variable list
I was wondering if someone knew the best way to write a query to pull back rows where a table field is found in a a variable string. I'm using Cold Fusion 10 on Microsoft SQL Server.
The table has a series of fields such as
carcode carname
G Garage
C Carport
A Attached
D Detached
And another query pulls back a field that stores as text all the abbreviations that apply
I want to pull back all the carnames that would match the abbreviations stored in that field. I thought I could use a contains line but that does not work. How do I pull back matches against a variable string... I tried an IN statment but that didn't work.
CFQUERY...
Select carname from CarTable WHERE CONTAINS (carcode, '#query.carlist#') does not work.
select carname from CarTable WHERE CONTAINS(carcode, 'G,A')
I'm stumped. The list of abbreviations could be very LOOOONG or short and I just need to translate those abbreviations into the full names by grabbing it from another table. It isn't just one abbreviation so I can't use LIKE in the one to one sense.
Thank you so much.If you have records with these values,
G,A
0
then your first mistake is that you designed your database poorly. Storing lists in a single field is essentially stroring unuseable data. A one to many relationship is better. If you don't know what that is, I've heard good things about the book, Database Design for Mere Mortals.
Next, this syntax, #queryname.car_storage#, only returns the first record. To get all the records, use the valuelist function.
Next, in sql, if you have a list of strings, each one has to be quoted. Something like this.
where myfield in ('a', 'b', 'c')
The best way to achieve this in ColdFusion is to use the cfqueryparam tag with the list attribute set to yes. -
Get variantclass from KMAT in report
Hello Community,
I want to program a "F4-valuelist-function" in my zreport where the user can find
all dependent characteristics from the variantclass (type 300) of the
KMAT. The KMAT is the select-option in my report. So the program
should find the right class and then use a bapi to list all characteristics,
so the user could choose the chosen characteristic for his request.
I can't find the association between KMAT (MARA) and CLASS in SAP.
Can anybody guide me?
Thanks
Markus PawlinkaHello Markus,
For a KMAT , you can get the link via the following tables and fields
Enter materials number as OBJEK in table INOB. From that you can get CUOBJ.
With that CUOBJ , please check table KSSK. Enter KSSK-OBJEK as INOB-CUOBJ.
You will get CLINT from table KSSK. Which is the class ID.You can the access the characteristics from table KSML.Please be carefull with overwritten characteristics.
As for the object values , you can simply use BAPI BAPI_OBJCL_GETDETAIL_KEY or BAPI_OBJCL_GETDETAIL.
Also please review note 1547034 - How are characteristic values updated in table AUSP?
It has detailed information on how the characteristics are saved,
Thanks
Amber -
How can I reference the query in the cfreport to use
ValueList function?Ensure that you are obtaining Null values from the table.
Sripathy. -
Displaying query values horizontally
I have a subreport with a query that returns a single field.
WHat I'd like to do is display it as a list on one line, as opposed
to showing each item on its own line. I couldn't find a
straightforward way to do this, so I tried to come up with a hack
but it's not working too well. What I did was simply output one
field with ValueList(query.FieldName, ", ") and then set the Print
When on the band to query.CurrentRow EQ 1 . Unfortunately the
ValueList() function doesn't seem to be working properly for this.
I tried setting the query to advanced and specifying a query name,
then using that query name in the function and that doesn't work
either. Anybody has any idea how to get ValueList() working or how
to solve my particular problem?I came up with a solution for this, here it is for the
benefit of others. Basicaly, I created a report function that would
build the list for me. The function is as follows:
<cffunction name="outputAsList">
<cfargument name="qData" />
<cfargument name="col" />
<cfset list = "" />
<cfloop from="1" to="#qData.recordcount#" index="i">
<cfif i GT 1>
<cfset list = list & ", " />
</cfif>
<cfset list = list & qData[arguments.col]
/>
</cfloop>
<cfreturn list />
</cffunction>
Then I set Print When on the subreport band to
query.CurrentRow EQ 1 so that the list would only get output once.
Then in the field I put the following expression:
report.outputAsList(query, "MyColName")
Works fine. Yet another hack, of course, but that's the way I
managed to get what I needed, since ValueList just won't play
nice. -
First of all I have to use the BCC email field for
the quere result email address so all of my customers can't see the
other email address who are also receiving these emails. In the TO
email field I use an admin type of email address for my website.
When the program is executed it works great. The problem is that
for every email that is sent to a customer from the quere results,
around 200 per email, the person listed in the TO email field also
gets an email sent to them. So I wind up with 200 duplicate emails
every time the program is executed. I have tried leaving the TO
field blank but just as I would suspect the program errored out.
What I want, is to have the program send one email to the TO
recipient and one to every person in the quere results list.
I attached the pertenante code but deleted the rest.Don't use the query attribute in your cfmail tag. If you want
to send everyone a bcc, use the valuelist function. -
Create tab seperated list from CF Query
HI All,
i have a CF query that pulls all my products from my DB, what i'd like to do is create a tab seperated list from the results of the query, the list also requires column headers.
any pointers?
thanks
zacThe ValueList function creates a list from any column in your query. You can specify whatever delimiter you want.
I don't understand the concept of a list having a column header. -
I use the following code to display data in two columns :
<cfoutput
query="qryGet_Error">
<td valign="top"
align="left">
#qryGet_Error.error_description#,
</td>
<cfif CurrentRow MOD 2 EQ 0>
I put a comma at the end of the description so that each
output would have a comma separator. How do I do it so that the
last output value does not have a comma ?
Thanksquote:
Originally posted by:
trojnfn
I think I understand what you are doing here, but how do you
prevent the code from breaking ?
My list can contain a minimum of one value, or a maximum of
ten values. If I have three per line, for three lines, the last
line will only have one value. If I have four per line for two
lines, the last line will have two values. And if I have two per
line for five lines, the last line will also contain two values.
Changing the value for the step will determine the number of
columns (<td></td> sets) in your table row. Step="2"
will give 2, step="3" will give 3, etc...
Here is how my suggestion would work.
<table ...>
<CFLOOP from="1" to="#ListLen(myList)#" step="3"
index="x">
<tr>
<td>#ListGetAt(myList, x)#</td>
<td><CFIF x+1 LTE
ListLen(myList)>#ListGetAt(myList,
x+1)#<CFELSE> </CFIF></td>
<td><CFIF x+2 LTE
ListLen(myList)>#ListGetAt(myList,
x+2)#<CFELSE> </CFIF></td>
</tr>
</CFLOOP>
</table>
If you change the step value in order to add columns, just
copy/paste the last <td>...</td> line and change the
x+2 for the new line to x+3 and you will be fine. If you need to
set step="2", just remove the 3rd <td> line.
This will produce a table like this:
<table>
<tr>
<td>query data 1</td>
<td>query data 2</td>
<td>query data 3</td>
</tr>
<tr>
<td>query data 4</td>
<td>query data 5</td>
<td>query data 6</td>
</tr>
<tr>
<td>query data 7</td>
<td>query data 8</td>
<td>query data 9</td>
</tr>
<tr>
<td>query data 10</td>
<td> </td>
<td> </td>
</tr>
</table>
Since you created the list of values using the ValueList
function, you will not have the commas (list delimiter)displayed.
Just make sure the query data does not contain commas or it will
alter the list.
CR -
i have 2 simple tables
1 - cars
id make model
1 toyota corolla
2 - car_images
rel_car_id image
1 front.jpg
1 back.jpg
i need a 1 line query with the images all in 1 field (comma seperated)
eg
1 toyota corolla front,jpg,back.jpg
ive tried complex sql, valuelist function and everything has be beat!
im stuck and woudl love your help.
ps my final goal is to take this new query and dump it to a csv.Thanks guys and sorry for my delay in returning to you.
I had to push the data to a csv file so I had to do the code at the source (sql server).
So its actually not really a CF query at all.
However here is the sql 2005 code that worked a treat, seems OTT for my liking but it works..
SELECT VEHICLES.ID AS VEHICLEID, '' AS REGISTRATION, MAKES.MAKE, VEHICLES.MODEL, '"' + REPLACE(VEHICLES.SUMMARY, '''', '\"') + '"' AS TITLE,
'' AS TRANSMISSION, VEHICLES.FUEL, '' AS BODYSTYLE, VEHICLES.PRICE, VEHICLES.YEAR, VEHICLES.MILEAGE, 0 AS DOORS, '' AS COLOUR,
'' AS INSGRP, '' AS LOCATION, '"' + REPLACE(VEHICLES.DESCRIPTION, '''', '\"') + '"' AS DESCRIPTION, IMAGES = '"' + REPLACE
((SELECT DISTINCT 'http://www.clivehamiltonmotors.com/images/vehicles/' + IMAGE + ',' AS [data()]
FROM VEHICLE_IMAGES
WHERE REL_VEHICLE_ID = VEHICLES.ID FOR XML PATH('')), '', '-') + '"'
FROM VEHICLES INNER JOIN
MAKES ON VEHICLES.MAKE = MAKES.ID
thanks again. -
I have a database of 6 names. I need a form's action page to
email 1 name in the database in a row. For instance I have sales
lead 1,2,3,4,5,6. How could I set up a query to get the random
numbered person and select their email addresss. I know how to
write teh query to get the email but I need to have a counter that
doesn't reset everytime a person accesses the page so for something
like i from 1 - 6 but how do I keep i from resetting to 1 when
someone accesses the page?You could use array notiation on the query using the
RandRange Function and the query recordCount.
Another method would be to convert the email column of the
query into a list using the ValueList() function and then use the
same RandRange() function but use ListLen().
Using the list method would be easier to implement a shuffle
for a better distribution. Shuffle the list and then FIFO the
shuffle for each sales lead you request. When the list is
diminished, reshuffle again to start over -
Non-functionality in ValueList in CFReport
I've seen postings looking for a resolution, but never a
resolution. Is there a way to get ValueList to work within a
calculated field in a CFR? I constantly get an error stating that
the field does not exist, even though I clicked my way through the
expression builder using ValueList(query.column [, delimiter ])
Does anyone have a fix for this, or an alternate that works.
I need to output a number of records (string data) in a comma
delimited list.
Thanks to all in advance.I would also like an answer to this question. I haven't
gotten ValueList to work within a CFR at all. It always throws and
error saying that the query or variable doesn't exist. I'm using
the same query.foo that I've used elsewhere. Perhaps this is a bug?
Thanks! -
Which function does this?.
I have to do something like this......
How will i pass values to second query like this...
where empid in (1001,1002,1003,1005)
Which function does this....?. Please help me.
lost track of features of functions......done this 100 times
before....now not working.
Please help me ASAP. Thanks in advance.
<cfquery name="id_sel" datasource="#edsn#">
select empid
from employee
where age < 50
</cfquery>
<cfquery name="course_sel_q" datasource="#edsn#">
select benefit_desc
from benefits
where empid in (<cfloop query="id_sel" startrow="1"
endrow="#id_sel.recordcount#">
#valueList(id_sel.empid,",")#</cfloop>)
order by empid
</cfquery>quote:
Originally posted by:
jdeline
You're making it too complicated. See code below. It creates
a comma-delimited list for use in your WHERE clause.
Edit: fixed bad ValueList)( ).
Too complicated? It's a simple join for goodness sakes. It's
also more efficient because it only uses one trip to the database
to get the data.
Maybe you are looking for
-
Hi All, I've a requirement for XI: external system sends the sales order information, in SAP I can create sales order using BAPI_SALESDOCU_CREATEFROMDATA, I need to create Production order BAPI_PRODORD_CREATE based on the sales order creation. I need
-
Tools to manage and use oracle scripts
Easyscript for Oracle is a tool to help you manage scripts efficiently and use scripts easily. The goal of easyscript is providing you a uniform and easy envrionment to manage and use your scripts. With hundreds of ready-made scripts, easyscript is a
-
Which JDK to install weblogic 10.3.3 in Linux 64 bit machine.
I jave a Linux 64 bit box. I am trying to find out suitable java env for installing weblogic. JDK 64 bit, downloaded from Sun, is raising noClassDefFound for java/lang/object. Not sure if my platform is not correct or that .bin file is wrong. Can I u
-
Run User Query (OUQR Table)
Hello! I need to run User.. or System query by Mouse Click event.. I find solution of this problem: Tools->Queries->UserQueries... or SysteQueries (Menu UID..) Maybe there is other way, object for UserQueries... I find the table with all query (OUQR)
-
Hi Experts, I am trying to replicate the BOM adapter object in CRM 7.0. All the materials in the BOM belong to the same plant but when applying filter criteria on MAST I am only getting the field STLAN and now WERKS.WERKS field is not appearing in th