How to add a custom title to oracle apex sql command query result - oracle-apex

I am trying to a add a custom title to my sql query result in APEX sql command, can't seem to find a solution how.
The title is something like this:
"My custom title on top of the columns"
Customer Name | Stock Number | Date Hired | Model Name

You mean something like this?
SELECT [table_column1] as "Customer Name",
[table_column2] as "Stock Number",
[table_column3] as "Date Hired",
[table_column4] as "Model Name"
FROM [table_name];

From what you clarified in the comments it appears you are looking to set the title for an area.
That depends what area it is, probably either an interactive report or interactive grid. The attributes of those have a setting to set the title.

You can use Oracle alias including column and table aliases to make the heading of the output more meaningful and to improve readability of a query.
To instruct Oracle to use a column alias, you simply list the column alias next to the column name in the SELECT clause as shown below:
SELECT
first_name AS forename,
last_name AS surname
FROM
employees;
The AS keyword is used to distinguish between the column name and the column alias. Because the AS keyword is optional, you can skip it as follows:
SELECT
first_name forename,
last_name surname
FROM
employees;
By default, Oracle capitalizes the column heading in the query result. If you want to change the letter case of the column heading, you need to enclose it in quotation marks (“”).
SELECT
first_name "Forename",
last_name "Surname"
FROM
employees;
As shown in the output, the forename and surname column headings retain their letter cases.
If the column alias consists of only one word without special symbols like space, you don’t need to enclose it in quotation marks. Otherwise, you must enclose the column heading in quotation marks or you will get an error.
See the following query:
SELECT
first_name "First Name",
last_name "Family Name"
FROM
employees;

Related

Dynamic column names in field parameter

I've the following pbix file https://1drv.ms/u/s!Amd7BXzYs7AVk3D5iDMIrhfnpQNW?e=lHWRuH
The data model is simple
one fact related to date table and field parameter table
I need to create a dynamic column names, concatenate the month periode selected by the field parameter
I do it manually, I duplicate the same script for months june and march and I should do the same for all months
Parameter = {
("Month Name June-2022", NAMEOF('DimDate'[Month Name]), 0,"June-2022","Month Name"),
("sales.Reason June-2022", NAMEOF('FactSales'[sales.Reason]), 1,"June-2022","sales.Reason"),
("Customer.Email March-2022", NAMEOF('FactSales'[Customer.Email]), 2,"June-2022","Customer.Email"), ("Month Name May-2022", NAMEOF('DimDate'[Month Name]), 0,"March-2022","Month Name"),
("sales.Reason March-2022", NAMEOF('FactSales'[sales.Reason]), 1,"March-2022","sales.Reason"),
("Customer.Email March-2022", NAMEOF('FactSales'[Customer.Email]), 2,"March-2022","Customer.Email")
}
Is there a way to do it dynamically please?

how to get an item "Database column" name

Oracle Apex 19.1.0.00.15.
how to get an item "Database column" name for IG or Form region like that exists in Oracle Forms
get_item_property('block.item',COLUMN_NAME);
I don't know of an existing function to do this, but you can obtain it like this for a form item:
select item_source
into v_column_name
from apex_application_page_items
where application_id = :APP_ID
and item_name = v_item_name;
You could wrap that in a function of your own.
There is another APEX view APEX_APPL_PAGE_IG_COLUMNS for IG columns, but I can't see how you would need that as to look up the column name you are going to need to know the column name, right?!

Kettle database lookup case insensitive

I've a table "City" with more than 100k records.
The field "name" contains strings like "Roma", "La Valletta".
I receive a file with the city name, all in upper case as in "ROMA".
I need to get the id of the record that contains "Roma" when I search for "ROMA".
In SQL, I must do something like:
select id from city where upper(name) = upper(%name%)
How can I do this in kettle?
Note: if the city is not found, I use an Insert/update field to create it, so I must avoid duplicates generated by case-sensitive names.
You can make use of the String Operations steps in Pentaho Kettle. Set the Lower/Upper option to Y
Pass the city (name) from the City table to the String operations steps which will do the Upper case of your data stream i.e. city name. Join/lookup with the received file and get the required id.
More on String Operations step in pentaho wiki.
You can use a 'Database join' step. Here you can write the sql:
select id from city where upper(name) = upper(?)
and specify the city field name from the text file as parameter. With 'Number of rows to return' and 'Outer join?' you can control the join behaviour.
This solution doesn't work well with a large number of rows, as it will execute one query per row. In those cases Rishu's solution is better.
This is how I did:
First "Modified JavaScript value" step for create a query:
var queryDest="select coalesce( (select id as idcity from city where upper(name) = upper('"+replace(mycity,"'","\'\'")+"') and upper(cap) = upper('"+mycap+"') ), 0) as idcitydest";
Then I use this string as a query in a Dynamic SQL row.
After that,
IF idcitydest == 0 then
insert new city;
else
use the found record
This system make a query for file's row but it use few memory cache

Apex5.0 choose layout and add date validation

I am building a student module application in Oracle Apex 5.0 and wanted to know how to display the details in oracle apex.
Something like this with two tabs on the 1 page:
on first tab, When input StudentID,
the first section will contain system_date and tutor name that has login
second section should contain student name and course desc & course year
third section is to display current semester module, if payment done or not (Y /N), markings %, date of payment.
2nd tab of the page to include all courses done for that student.
Which layout to choose (interactive grid/report) or any other.
How to add validation of date picker for the payment date so that upon input it insert directly in table in DD-MON-YY format and also that it takes system_date??
Note table:
student_details: the student name, address and personal details
course_detail table contains the courses for the semester
payment_detail table for the payment details
The sort of things you're going to want to look for are:
Region Display selector, for multiple tabs
Any type of report region to display data, and you can have multiple, and nest them as sub-regions.
You can define page items that are displayed as date pickers, and use default values to source today's date using the keyword SYSDATE.
You're going to need to understand SQL.

How to read columns with spaces from coldfusion queries?

I am reading data from a spreadsheet. One of the column in the spreadsheet contains spaces.
For Example, Columns names are [first name,last name,roll].
I am getting a qryObj after reading the spreadsheet.
Now when i am trying to read first name from the query
<cfquery dbtype="query" name="getName">
SELECT [first name]
FROM qryObj
</cfquery>
It is throwing db error. I have tried with ['first name'] also but still it is throwing error.
The error is:
Query Of Queries syntax error.
Encountered "[. Incorrect Select List, Incorrect select column
I did crazy stuff like googling to see what people had done in other situations, and tried various SQL approaches to escaping non-standard column names (back ticks, square barackets, double quotes, combos thereof) , and drew a blank. So I agree with #da_didi that QoQ/IMQ does not cater for this. You should raise a ticket in the Adobe bug tracker.
You could do SELECT *, which removes the need to reference the column name. Or you could serialize the query, use a string replace to rename the column, deserialise it again then QoQ on the revised name. I'd only do this with a small amount of data though.
Or you could push back on the owbner of the XLS file and say "no can do unless you revise your column names".
You could also perhaps suppress the column names as they stand from the XLS file using excludeHeaderRow,and then specify your own columns names. How did I find out one could do that? By RTFMing the <cfspreadsheet> docs.
Thats easy:
Query
Select [FIRST NAME]
in output loop of query
["FIRST NAME"]
Try this - set a variable works for me
<cfset first_name = #spreadsheetData['first name'][CurrentRow]#>
You cannot. Best practices: I always replace all spaces with an underline.
Simple. Just alias the select. Select [FIRST NAME] as FIRSTNAME from qryObj