I running a BI Publisher report through SOAP request. the BI Publisher data model contain the following condition :
WHERE PERIOD_NAME IN ( :P_PERIOD_NAME )
when i pass single period like "Jan-21" it works fine but then when i pass "Jan-21, Feb-21" it fails.
how to pass comma separated values ?
You are passing in a single string (that happens to contain commas) and not a comma-separated list of multiple values so your query is effectively:
WHERE period_name IN ( 'Jan-21, Feb-21' )
Instead, surround both the delimited list and the list item in delimiters (so that you do not get a partial match) and then match on the substring:
WHERE ', ' || :P_PERIOD_NAME || ', ' LIKE '%, ' || period_name || ', %'
db<>fiddle here
Let try this query
SELECT *
FROM TABLE1
WHERE 1=1
AND PERIOD_NAME IN (
select regexp_substr('Jan-21,Feb-21','[^,]+', 1, level) as period from dual
connect by regexp_substr('Jan-21,Feb-21', '[^,]+', 1, level) is not null
);
I trying to load the datas from data file to the database table load_sql using sql loader. I have data like below in the data file.
empid,ename
1,Raja,**Kanchi
2,Poo,**Kanchi
3,Bhasker,**Kanchi
4,Siva,**Kanchi
I have to load to load it in the load_sql table like below format:
1,Raja,Kanchi
2,Poo,Kanchi
3,Bhasker,Kanchi
4,Siva,Kanchi
I have written a control file with help of char manipulation function for inserting records in third column but im getting error:
options(skip = 1,Errors = 100, direct = True)
load data
infile 'D:\SQLLDR\control.ctl'
truncate into table load_sql
when city = 'Kanchi'
fields terminated by ','
optionally enclosed by '"'
(
empid,
ename,
X filler,
city "ltrim(:city,*)"
)
I'm getting the error like
'SQL*Loader-951: Error calling once/load initialization
ORA-02373: Error parsing insert statement for table ROOT.LOAD_SQL.
ORA-00936: missing expression'
You have some syntax errors in your control file. Try this:
options(skip = 1,Errors = 100, direct = True)
load data
infile 'D:\SQLLDR\control.ctl' <-- This doesn't look like a data file name?
truncate into table load_sql
when (city = '**Kanchi')
fields terminated by ','
optionally enclosed by '"'
(
empid,
ename,
city "ltrim(:city, '*')"
)
ltrim(:city,*)
^
|
this is invalid
Should have been
ltrim(:city, '*')
or, possibly,
replace(:city, '*', '')
I am currently attempting to aggregate a list of concatenated values. However, I was wondering if it was possible to use a carriage return function within the listagg so that each concatenated value would be returned onto a new line. Does anyone have any experience with this? Thank you!
Here is a portion of my code: (Please note that this is also taking place inside a view join)
(select (listagg ((z.event_name || ' - ' || z.event_date), '; ') within group
(order by z.event_name))
from
a_visit_event z
where
z.subject_no = av.subject_no
and
z.visit_date = av.visit_date) event_name,
Just add chr(13)
i.e.
listagg ((z.event_name || ' - ' || z.event_date), '; '||chr(13))
I'm working on displaying data from oracle.
is there a way to make the following data inside the table:
example :
'1.somedata, 2.somedata, 3.somedata, 4.somedata, 5.somedata'
to display like:
example:
'1. somedata
2. somedata
3. somedata
4. somedata
5. somedata'
on the interface?
do i add new line separator directly into the data?
or do i separator them into new line when i query it?
or is there any other simple way?
Thanks.
There are so many ways to do this, here is one if you are selecting from a column:
SELECT REPLACE ('1.somedata, 2.somedata, 3.somedata, 4.somedata, 5.somedata', ',', CHR (13) || CHR (10)) AS split
FROM DUAL;
1.somedata
2.somedata
3.somedata
4.somedata
5.somedata
I personally would use the listagg function and use '' as the delimiter.
SELECT LISTAGG(last_name, ' ')
WITHIN GROUP (ORDER BY hire_date, last_name) "Emp_list",
MIN(hire_date) "Earliest"
FROM employees
WHERE department_id = 30;
Remember that Apex is generating a web page, which means the end result is HTML. Apex, however, will also sometimes escape special HTML characters for you, like < and &. Since you're viewing a table, I assume the source of your data is a query and your "somedata" field is a single column. Try this:
SELECT REPLACE( somedata_column, ',', '<br />' )
FROM mytable
You don't say what version of Apex. In Apex 4.x, the column would need to be set to a Standard Report Column, which would stop Apex from the <br> elements. I forget what the column type is in Apex 5.x.
Check below sample query which converts coma separated list data into rows
SELECT substr( '1.AL,2.AL,3.AL,4.AL,5.AL,6.AL,',
( case when rownum = 1 then 1
else instr( '1.AL,2.AL,3.AL,4.AL,5.AL,6.AL,', ',', 1, rownum - 1 ) + 1
end ),
instr( substr( '1.AL,2.AL,3.AL,4.AL,5.AL,6.AL,',
( case when rownum = 1 then 1
else instr( '1.AL,2.AL,3.AL,4.AL,5.AL,6.AL,', ',', 1, rownum - 1 ) + 1
end )
), ',' ) - 1
) as data
FROM dual
CONNECT BY LEVEL <= length( '1.AL,2.AL,3.AL,4.AL,5.AL,6.AL,' ) - length ( replace('1.AL,2.AL,3.AL,4.AL,5.AL,6.AL,', ',') )
Hope this will help you!
IMAGE_PATH(its column name) Such type of value in column given below
sph/images///////30_Fairhall_Court.jpeg
sph/images///8_Furnival_Court.jpeg
sph//images/9_Pennethorne_House.jpeg
rbkc/images/TAVISTOCK_CRESCENT.jpeg
haringey///images///399932thumb.jpg
urbanchoice//images//18190862.jpg
westminster/images//7_Glarus_Court.jpeg
I want to update all row of column where have more then one '/' like as
sph/images/30_Fairhall_Court.jpeg
sph/images/8_Furnival_Court.jpeg
sph/images/9_Pennethorne_House.jpeg
rbkc/images/TAVISTOCK_CRESCENT.jpeg
haringey/images/399932thumb.jpg
urbanchoice/images/18190862.jpg
westminster/images/7_Glarus_Court.jpeg
please suggest how to update column by replacing multiple '/' in single '/'
You can use regexp_replace for this.
select regexp_replace( 'sph/images///////30_Fairhall_Court.jpeg', '(/){2,}','\1' )
from dual
sph/images/30_Fairhall_Court.jpeg
So your update statement would be something like the following:
update yourtable
set filename_column = regexp_replace( filename_column, '(/){2,}','\1' )
where instr(filename_column,'//')>0