how acess the report column value in oracle-apex? - oracle

I need the "elabora prenotazione" button to be shown only when the column "stato prenotazione" is "IN SOSPESO"
I tried to set a condition but I don't know how to pick the column value

If I understand your question, this could help:
For the source of your report:
SELECT
CASE
WHEN stato_prenotazione = 'in sospeso' THEN 'elabora prenotazione'
ELSE ''
END name_of_column,
prenotazione,
username,
nome,
cognome,
viaggio,
stato_viaggio,
data_prenota,
stato_prenotazione,
numero_ospiti
FROM your_table
Then set the column "name_of_column" to type: link, and fill the target.

Wrap a condition around a call to apex_page.get_url within your SQL, so it will only produce a link when relevant
Example of function in use, sans condition:
https://azureoutput.wordpress.com/2017/10/18/custom-hyperlink-in-interactive-report/
Use this to make the button look prettier, and maybe get some other ideas
https://www.grassroots-oracle.com/2015/12/tutorial-include-action-button-in-report.html
See this in regard to escaping special characters, otherwise you'll just see HTML in your report
https://www.grassroots-oracle.com/2017/01/escape-special-characters-apex-demo.html

This could be resolved by a simple case statement as #sara mentioned.
something like:
select (case stato_prenotazione when 'in sospeso' then 'elabora prenotazione' end) as your_column
I would not keep else condition so that the column will simply contain null value if the condition is not met.

Related

How to put 0 instead of blank in rtf template

see sample report output with blank fields
I tried this code see imagethis is the code I used
But the 0 was added to the end of each values. See the image below it's looks like this
Try one of these:
<?xdofx:if your_element!='' then your_element else 0 end if?>
<?xdoxslt:ifelse(your_element!='', your_element, 0)?>
To me, the simplest way to do that is to use NVL function in query that populates the report, e.g.
select nvl(that_value, 0) as value
from ...
which means that it'll return value (if it exists) or 0 (if value doesn't exist).

XPath: need a condition based on the value of attribute

For the below path in XPath, I need to have a condition for parser, where the value of the attribute is '1'
./*[local-name()='AccountNumber']/#UndocumentedAccount
I've tried a few things so far, but none seem to work
./*[local-name()='AccountNumber']/#UndocumentedAccount='1'
./*[local-name()='AccountNumber'][#UndocumentedAccount='1']
./*[local-name()='AccountNumber']/#*[UndocumentedAccount and text()='1']
I know how to build such conditions for the value of the element itself, but haven't figured out yet how to do the same for the attribute values
If you are trying to select the UndocumentedAccount attribute only if its value is 1, then the syntax you are probably looking for is:
./*[local-name()='AccountNumber']/#UndocumentedAccount[.='1']
The dot is shorthand for the self axis which is the context item (the item immediately to the left of the [ bracket). You can also try the following to only select AccountNumber nodes having an UndocumentedAccount attribute = 1:
./*[local-name()='AccountNumber' and #UndocumentedAccount ='1']/#UndocumentedAccount

How to get record data from locate?

In VFP 6 I have a table called "cars" and inside a button I want to find an ID based on the name. What did I do wrong?
... code
SELECT cars
LOCATE FOR ALLTRIM(UPPER(name)) = variable_read_from_textbox
IF NOT FOUND()
messagebox("not found")
ELSE
messagebox(cars.id_car)
ENDIF
Running the code works ok when the name is not found but when it is found it errors out.
Thanks!
Your code is right in general. Slight modification for safety and fix for error:
SELECT cars
* this implies an exact match, regardless of set exact, and makes casing same
* remember this wouldn't use an index unless there is an index with the same signature
LOCATE FOR ALLTRIM(UPPER(name)) == ALLTRIM(UPPER(m.variable_read_from_textbox))
IF NOT FOUND()
messagebox("not found")
ELSE
messagebox(transform(cars.id_car))
ENDIF
As far as I remember, in VFP6, messagebox() was not yet capable transforming the value to string for you and expects a string (you didn't tell what the error is but that should be it).
A little caution about your search.
ALLTRIM(UPPER(name))
will NOT use an index, unless there is an index with key "ALLTRIM(UPPER(name))". If there is, it would be used, but such an index is actually useless because of the alltrim(). A better index would simply be:
Upper(name)
and then your search would look like:
variable_read_from_textbox = ALLTRIM(UPPER(m.variable_read_from_textbox))
SET EXACT ON
SELECT cars
LOCATE FOR UPPER(name) = m.variable_read_from_textbox
IF NOT FOUND()
...

Express JS Jade Engine If statement nested in For loop

I can't seem to find a solution to this.
I'm trying to nest a if statement inside a for loop in Jade engine (using express js).
The base code is shown below:
form
select
for obj, i in phoneModel
option(value='#{i}') #{obj.phone_model}
What I would like to do is to have a IF statement inside the for loop to check to see if a varaible "deviceIndex" is a certain value. Eg. If deviceIndex == i, then do something, else do some other thing.
I have tried the code below:
form
select
for obj, i in phoneModel
- if(phoneIndex == #{i})
option(value='#{i}') #{obj.phone_model}
- else
option(value='#{i}' selected='selected') #{obj.phone_model}
It gives the "expect indent, but got newline" error. I expect it is my placement of the if statement inside the for loop; however, I have tried just about every combination of tabs and spaces as well as putting the "option(val..." line inside a bracket on the same line as the if statement.
What's with the typeof around a boolean? And shouldn't the phone with phoneIndex == i be the one selected? Also, the point of Jade is to have much cleaner code. Tell me if this works:
form
select
for obj, i in phoneModel
option(value=i, selected=phoneIndex==i)= obj.phone_model

need to get out of the select case

We are using a code where we need to select an item in combobox, we do this by a select case statement like Case "SelectItem"
However if there are no items in the combobox the code should exit from the case."End Select" was not working..
How can we resolve the same? is there a different logic?
you could try using Case Else to handle any unexpected values.
Select Case SelectItem
Case 1
'There is one item in the combobox
Case 2
'There are two items in the combobox
Case Else
'There are a different number of items
End Select
Not sure what exactly you are doing. You could also wrap your Select in an If statement.
If Combobox.Listcount > 0 Then
Select Case SelectItem
Case <Item>
'Do something here
End Select
End If
Unfortunately I don't think there is that functionality. One way to get around it would be to put your Select inside it's own sub and then you can exit it with Exit Sub/Exit Function.
I'm not sure I entirely understand what you are asking, but I think you may be able to achieve what you want just by putting your select block inside of an if-then.
i.e.
If Combobox.Listcount > 0 Then
Select Case ...
Case ...
...
End Select
End If

Resources