I have problem to display picture in PL/SQL Dynamic view Content (Apex Oracle).
Below is problematic row of code:
sys.htp.p( '<img src="'https://apex.oracle.com/pls/apex/cgdev/test/cool/'||'kk1.ID'||'.1.png'"/>');
where is kk1.ID is ID relevant to report.
I need to get result:
"https://apex.oracle.com/pls/apex/cgdev/test/cool/2.1.png"
How can I concatenate strings in the right way?
Regards,
Stefan
Line #5 shows how it should look like. Your problem was in wrong enclosing kk1.id into single quotes, I think. I left opening and closing IMG tags out. Add them, if necessary.
SQL> with kk1 (id) as
2 (select 2 from dual)
3 select
4 '"https://apex.oracle.com/pls/apex/cgdev/test/cool/' || kk1.ID ||'.1.png"' col
5 from kk1;
COL
----------------------------------------------------------
"https://apex.oracle.com/pls/apex/cgdev/test/cool/2.1.png"
SQL>
Related
Question: For every part description that begins with the letter βbβ, list the part description, and then pad each part description with a β+βon the left side so that all these part descriptions are 15 characters in length.
And I wrote like
SELECT
LENGTH(PART_PART_DESCRIPTION), LPAD(PART_PART_DESCRIPTION,15,'+'),
PART_PART_DESCRIPTION, CONCAT('+', PART_PART_DESCRIPTION) FROM PART
WHERE SUBSTR(PART_PART_DESCRIPTION,1,1)='B'
but the output doesn't show 15 of '+' on left side.
Here is the output table
Your column PART_PART_DESCRIPTION is of CHAR data type with 285 data length. so BLENDER in your column has a total 285 (7 + 278 trailing spaces) length. that is why you are facing the problem.
See this:
SQL> select LPAD(CAST('BLENDER' AS CHAR(285)),15,'+') FROM DUAL;
LPAD(CAST('BLENDER'ASCHAR(285)),15,'+')
------------------------------------------------------------
BLENDER
SQL> select LPAD('BLENDER',15,'+') FROM DUAL;
LPAD('BLENDER',
---------------
++++++++BLENDER
SQL>
You need to use TRIM to properly use the LPAD on CHAR datatype column Something like the following:
LPAD(trim(PART_PART_DESCRIPTION),15,'+')
Most probably your data is padded with spaces. Try this
SELECT
LENGTH(PART_PART_DESCRIPTION), LPAD(TRIM(PART_PART_DESCRIPTION),15,'+'),
PART_PART_DESCRIPTION, CONCAT('+', PART_PART_DESCRIPTION) FROM PART
WHERE SUBSTR(PART_PART_DESCRIPTION,1,1)='B'
I am currently using apex 19.1. I have this problem where I can't (or don't know how to) select certain columns from checkbox meaning I have this checkbox
which gives me the ability to check the columns names I want to use that output (:P3_COLUMN) from the check box to select a specific columns in a table. My solution was :
select :P3_COLUMN
from INPUT_TABLE$
I also tried :
select case :P3_COLUMN when 'currency' then currency when 'nationality' then nationality end as test from input_table
which gave me this output
and
DECLARE
str varchar2(100);
BEGIN
str := 'select ' || replace(:P3_COLUMN, ':', ',') || ' from input_table';
execute immediate str;
END;
which gave me this error
I don't know what to do, any help will be really appreciated.
Here's a walkthrough (my page is #51). Suppose that we want to display some column from Scott's DEPT table.
create a region whose type is classic report
create a page item (let's call it P51_COLS which is a select list item; its source is a query which looks like this:
select column_name d,
column_name r
from user_Tab_columns
where table_name = 'DEPT'
Page action on selection should be "Submit page"
region's source should be a PL/SQL function body that returns a SQL query and look like this:
return 'select case when :P51_COLS = ''DEPTNO'' then to_char(deptno )
when :P51_COLS = ''DNAME'' then dname
when :P51_COLS = ''LOC'' then loc
end as result
from dept';
Its "Page items to submit" should be set to P51_COLS
That's it ... run the page; select any column from the select list item and the result should be displayed.
Yes, I know - the query itself looks stupid as you have to name all cases. For some reason, Apex expects literally return 'select ...' statement. Concatenation, replace function, ... won't work. Perhaps someone knows why or - even better - can demonstrate how to workaround it. Meanwhile, try what's been written above.
first option use server side condition on the columns.
second option use dynamic sql> create function returns sql statement> call the function in your region source.
I have a problem in updating a column in oracle which has a single quote.
The following example will clear the problem.
Lets Client name is Lucy'Mark
Now, I want to replace the Single quote with space
After output, it will be Lucy Mark
Now when I tried the following query it is not working as the query will be
select replace (Lucy'Mark , '''', '') from gen_clientvendor_m;
Please let me know the query.
I am using SQL developer
Use the column with client name and add space to the replace statement:
select replace (client_name , '''', ' ') from gen_clientvendor_m;
Multiple single quotes cause headache :) so - have a look at this option:
SQL> with test (name) as
2 (select q'[Lucy'Mark]' from dual)
3 select name,
4 replace(name, chr(39), ' ') result
5 from test;
NAME RESULT
--------- ---------
Lucy'Mark Lucy Mark
SQL>
I've googled all I know how to Google. I need some new eyes to look at this.
I am trying to center the RESULTS of a query. Here is what I have so far ...
set lines 2000 pages 2000
COLUMN total HEADING "Total" FORMAT A20 JUSTIFY CENTER
COLUMN sending_fi HEADING "Sending M" FORMAT A20 JUSTIFY CENTER
COLUMN receiving_fi HEADING "Receiving M" FORMAT A20 JUSTIFY CENTER
COLUMN status HEADING "Payment Status" FORMAT A20 JUSTIFY CENTER
SET UNDERLINE =
select
count(*) as "Total",
p.sending_fi,
p.receiving_fi,
p.status
from
my_schema.my_table p
where
p.match_date
between
to_date
(
'2017/10/26:00:00:00',
'yyyy/mm/dd:hh24:mi:ss'
)
and
to_date
(
'2017/10/28:23:59:59',
'yyyy/mm/dd:hh24:mi:ss'
)
and
p.expedited='1'
and
p.status='DELIVERED'
group by
p.sending_fi,
p.receiving_fi,
p.status
order by
1
DESC
;
Which produces this output ...
Total Sending M Receiving M Payment Status
==================== ==================== ==================== =================
266759 BAC BAC DELIVERED
49954 JPM BAC DELIVERED
45194 BAC JPM DELIVERED
25990 WFC BAC DELIVERED
25676 JPM WFC DELIVERED
24120 WFC JPM DELIVERED
23565 BAC WFC DELIVERED
The COLUMN HEADERS (names) are centered, but for the life of me, I can't figure out how to center the results.
I'm a non-privileged user (all i ever really do are select update and insert), with very limited SQL skills. Please be gentle in your suggestions.
Originally I wrote this as a Comment. Then I thought of closing the question as a duplicate; but the only duplicate I found has no answers: just a Comment saying the same thing. (I should know, it was my Comment then, too!)
Column Formatting JUSTIFY not working
ANSWER:
It looks like you want an answer in SQL*Plus. There is no answer. Strings and dates are always aligned to the left side of the column, and numbers to the right. Period. You can't change that (other than by adding to the strings themselves, in the query - by padding with spaces; a complete waste of time!) If you need to generate "good looking" reports, and what is available in SQL*Plus is not good enough, you must use a reporting tool; can't be done in SQL*Plus.
There seems to be some confusion about the SQL command COLUMN ... FORMAT ... JUSTIFY. Here is what the manual says:
JUS[TIFY] {L[EFT] | C[ENTER] | R[IGHT]}
Aligns the heading. If you do not use a JUSTIFY clause, headings for NUMBER columns default to RIGHT and headings for other column types default to LEFT.
https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12013.htm#BACHCABF
You might be able to use LPAD.
Here is a quick example:
COLUMN blks HEADING "Num Blocks" FORMAT A10 JUSTIFY CENTER
select
lpad(to_char(blocks),(10-length(to_char(blocks)))/2+length(to_char(blocks)),' ') blks
from user_segments
where rownum < 11;
The idea is to pad the column on the left with half of the difference between the format size and the size of the column value in spaces.
Output:
Num Blocks
----------
16
16
16
16
16
16
16
16
16
16
10 rows selected.
Bobby
Bobby's answer will work for text output. You can also make use of the HTML markup feature of sqlplus and produce formatted html output. An example which extends https://docs.oracle.com/database/121/SQPUG/ch_seven.htm#SQPUG531 would be
create table t1 (
id number
, dt date
, vc varchar2(20)
, constraint pk_t1 primary key (id) );
begin
for i in 1..10 loop
insert into t1 values (i,sysdate + i , 'Row '||i);
end loop;
commit;
end;
/
SET MARKUP HTML ON PREFORMAT OFF ENTMAP ON -
HEAD "<TITLE>Department Report</TITLE> -
<STYLE type='text/css'> -
<!-- BODY {background: #FFFFC6} --> -
<!-- TD { text-align: center} --> -
</STYLE>" -
BODY "TEXT='#FF00Ff'" -
TABLE "WIDTH='90%' BORDER='5'"
Then run
spool t.html
followed by your query and then
host firefox t.html
This is a oracle output records with pipe delimiter
04/22/2015|695|1074795|CRUSE|AXDE|01/29/1963|88359|||||
I want to change like this
"04/22/2015"|"695"|"1074795"|"CRUSE"|"AXDE"|"01/29/1963"|"88359"|||||
What is the query in Perl?
I want to change like this
"04/22/2015"|"695"|"1074795"|"CRUSE"|"AXDE"|"01/29/1963"|"88359"|||||
I won't say this is an elegant way to do it, since it is always better to fix the source itself. In your case, whatever is generating the output, you could simply concatenate the double-quotation marks to the column names.
Anyway, you could do it in SQL using REPLACE and RTRIM:
SQL> WITH DATA AS(
2 SELECT '04/22/2015|695|1074795|CRUSE|AXDE|01/29/1963|88359|||||' str FROM dual
3 )
4 SELECT '"'||rtrim(REPLACE(REPLACE(str, '|', '"|"'), '""',''),'"') str FROM DATA;
STR
---------------------------------------------------------------------
"04/22/2015"|"695"|"1074795"|"CRUSE"|"AXDE"|"01/29/1963"|"88359"|||||
SQL>
check this
select '"04/22/2015"|"695"|"1074795"|"CRUSE"|"AXDE"|"01/29/1963"|"88359"|||||' as str from dual
STR
---------------------------------------------------------------------
"04/22/2015"|"695"|"1074795"|"CRUSE"|"AXDE"|"01/29/1963"|"88359"|||||