Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

dbase help

New Here ,
Apr 08, 2008 Apr 08, 2008
hi, im trying to distinguish in a page we have to show calendar_status events on a page, and its defined by 0=unfilled, 1=filled. when i show the results on the cfm page edited, it only shows a 0 or 1. i would like it to show either unfilled or filled based on the number corresponding with database rule (0 or 1). how can i resolve this? thanks.
408
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2008 Apr 08, 2008
if your db supports this type of syntax,

select case when yourfield = 1 then 'filled' else 'unfilled' end somealias
etc
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2008 Apr 08, 2008
thanks for the reply. i actually may not have explained it very well. the dbase shows an event (CALENDAR_STATUS) with 0 or 1. the 0 = unfilled event, 1 = filled. on my frm_event_details.cfm page, im trying to add a section there for this. i have #getevent.CALENDAR_STATUS# , however it is just showing a 1 or 0. id like it to show what the 1/0 means (filled, unfilled) on the screen. thanks!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 08, 2008 Apr 08, 2008
quote:

like it to show what the 1/0 means (filled, unfilled) on the screen. thanks!!
.... and that is what Dan suggested trying using CASE, assuming that dBase allows the use of CASE statements. Oracle has a function named decode() that allows you to "convert" one value to another so that if your database returns a 0 you can display 'unfilled', and if it returns a 1 you can display 'filled', etc.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2008 Apr 08, 2008
if your db has a table that stores the '1, filled' and '0, unfilled'
values, then select the corresponding column from that table in your
query that pulls calendar_status data, i.e. using a JOIN

if not, then a simple <cfif calendar_status eq
1>filled<cfelse>unfilled</cfif> in your cfoutput will do the trick

or use your db's CASE/WHEN/THEN/ELSE/END or IF/THEN or similar flow
control functionality to convert 0 and 1 to desired string values in
your query

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2008 Apr 08, 2008
Azadi thanks, the <cfif code works fine. thanks all for ur replies!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2008 Apr 08, 2008
you are welcome, but if your db does support control flow (CASE, IF,
etc) - you are better off using those, as Dan gave you an example for.

i'd rather have a query return the exact data i need, than return some
data which i then have to 'format' or 'decode' with cf code into what i
need it to be...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 08, 2008 Apr 08, 2008
LATEST
For Access, you could use IIF, as in the following:

SELECT IIf(calendar_status = 0, 'unfilled', 'filled') AS cal_stat
FROM your_table
WHERE whatever

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources