Oracle Apex display image in classic report - sql

I want to display images which are stored under Shared Components -> Static Application Files. In my table I added a column images with this content:
image
______________________
#APP_FILES#image01.jpg
#APP_FILES#image02.jpg
...
I select the data in my SQL query for a classic report:
select ID,
'<img src="'||image||'"height="50" width="200">' as image
from TEST_TABLE
And set the column image with disabled "Escape special characters".
The image does not appear:
How an I display images in a classic report column which are stored under Shared Components?

Here is an example to show an image (same image) for every employee in the emp table. I used HTML Expressions.
The select:
select ename, '#APP_FILES#mickey550x560.jpg' as image_file from emp
set column "image_file" to "Plain Text" with column formatting > HTML Expression:
<img src="#IMAGE_FILE#" "height="55" width="56" alt="image">
Result:

Related

HTML in SQL queries

--select the data to highlight using html in sql queries
select
id_c,
salary_c,
case
when salary_c > 50000 then '<html><bgcolor=yellow><font color=red size=5><b>'||to_char(salary_c)||'<html>'
else to_char(salary_c)
END as conditionalsalary
from employees;
Please let me know where I did the mistake. am using oracle 11g and dbeaver client tool is.
I wanted result of conditionalsalary column high light in red color size 5 and background color yellow which are more than 50000 using html tags inside SQL query...
You’re using SQL Developer which is able to render HTML, see https://www.thatjeffsmith.com/archive/2012/07/using-html-to-mark-up-your-data-in-oracle-sql-developer/
Your HTML is not right, you are missing closing tags, quotes and bgcolor is not a valid tag as far as I can see. It probably should be:
select
id_c,
salary_c,
case
when salary_c > 50000 then '<html><font color="red" size=5 style=“background-color:yellow;"><b>'||to_char(salary_c)||'</font></html>'
else to_char(salary_c)
END as conditionalsalary
from employees;

Like Clause over an 'Element' - ORACLE APEX

I encounter some problems that i don't understand with APEX.... Well, let's be specific.
I ve got a select element retrieving a top 50 of most liked url (P11_URL). This is populate by a table view, TOp_Domains.
I create an element called "Context" that have to print all text containing the URL selected by the user from the element select. Those Texts come from another table, let's say "twitter_post".
I create a dynamic action (show only) with this sql/statement:
Select TXT, NB_RT, RANK
from myschema.twitter_post
where TXT like '%:P11_URL%'
group by TXT, NB_RT, RANK
.... and it doesn't work... I think APEX don't like like clause... But i don't know how to do. Let's keep in min an url could have been shared by multiple Tweets, that's why this element "context" is important for me.
I tried to bypass the problem by building a State (in french Statique) and a dynamic action that will refresh the state but it doesn't work neither... bouhououououou
TriX
Right click on the 'P11_URL' and create DA. Event :change, Item:P11_URL. As the true action of the DA, select 'Set Value'. Write your query in the sql stmt area. In the page items to submit, select 'P11_URL' . In the 'Affected Items': select 'Context'.
Query should be :
Select TXT, NB_RT, RANK
from myschema.twitter_post
where TXT like '%' || :P11_URL || '%'
group by TXT, NB_RT, RANK
So
Thanks to #Madona... Their example made me realised my mistake. I wrote the answer here for futher help if somebody encouter the same porblem.
A list select element get as arguments a display value (the one you want to be shown in your screen.... if you want so....^^ ) and a return value (in order, I think to linked dynamic actions). So to solved my problem i had to shape my sql statement as:
select hashtags d, hastags r
from my table
order by 1
[let s say that now in Apex it s an object called P1_HASHTAGS]
First step problem solving.
In fact, the ranking as second value, as i put into my sql statement was making some mitsakens into my 'Where like' clause search... well... Newbie am i!
Second step was to correctly formate the sql statement receiving the datas from my select lov (P1_HASHTAGS) into my interactive report. As shown here:
Select Id, hashtags
from my table
where txt like '%'||:P1_HASHTAGS||'%'
And it works!
Thank you Madona your example helped me figure my mistakes!

APEX 5: How can I store the results of a MultiSelection from a List in an APEX-Item?

My example list:
How can I store the results in the Input Field "Your Choose" as comma-separate values (in this example: ALABAMA, ARIZONA).
Would APEX_UTIL.TABLE_TO_STRING be suitable?
You need to be more specific while asking questions.
I assume that you have page with
item PX_MULTISELECT.
process Before Header that loads data from DB to the input PX_MULTISELECT
And basing on this I assume you are asking how to get data separated with : from DB.
In process that loads data you should fetch data from db using listagg function
begin
select
listagg(COLUMN, ':') within group (order by 1)
into
:PX_MULTISELECT
from
...
where
...
end;
LISTAGG documentation

Searching and returning all occurences of keyword in a Postgres text column

About database
Database table for content of an Confluence page is named bodycontent and the HTML content is stored in column named body, which is a text field. Im using Postgres database. Primary key is named bodycontentid
Result I need
For each row in the table I need to find all occurence of <image> tag where src attribute starts with "http://images.mydomain.com/allImages/%" in the body column
Example
Let say that body with bodycontentid = 12345 contains following text:
<h1>Chapter 1</h1>
<image src="http://www.google.com/image/111.jpg"/>
<h1>Chapter 2</h1>
<image src="http://images.mydomain.com/allImages/222.jpg"/>
<h1>Chapter 3</h1>
<image src="http://images.mydomain.com/allImages/333.jpg"/>
Result after running this query should return:
bodycontentid: 12345
body: http://images.mydomain.com/allImages/222.jpg
bodycontentid: 12345
body: http://images.mydomain.com/allImages/333.jpg
What I have tried
Im able to find all rows that has at least one occurence of the keyword Im searching for (see below), but what I need is to get list of all keywords per row that is matching my query.
SELECT *
FROM bodycontent
WHERE body LIKE '%http://images.mydomain.com/allImages/%'
One method is to use regexp_split_to_table() and then some string manipulation:
select bc.bodycontentid,
left(rst.s, position('"' in rst.s) - 1) as domain
from bodycontent bc, lateral
regexp_split_to_table(bc.body, E'srce="') rst(s)
where rst.s like 'http://images.mydomain.com/allImages/%';

Update colum with value from another column + text

I imported an e-store's database values into my own, and it mostly worked out fine. However, there were no image file names. So, I need to update the entire database- over 6,000 records, so that under 'image' we get a path + model name + jpg, so each product can be associated with an image. Im having trouble mixing the dynamic column value with the static path. Here is what I need to accomplish:
UPDATE `store`.`pr_product`
SET `image` = 'data/products/`**model_no**`.jpg'
WHERE `pr_product`.`product_id` = `pr_product`.`product_id` ;
But cannot get it to recognize the dynamic nature of 'model_no'
Thanks in advance
Max,
Please what you means about dynamic nature of 'model_no'?
Is this column's datatype int or long or varchar
Please need more explaination with example
you can test the following if e.g model_no is column in pr_product table
UPDATE store.pr_product
SET image = 'data/products/'+pr_product.model_no+'.jpg'
WHERE pr_product.product_id = pr_product.product_id ;
Best Regards,
Mohammed Thabet Zaky