Oracle Apex SQL Workshop - New line(CHR10) not working in varchar DB column - oracle-apex

I need to display text with line breaks in email.
The source database column has datatype varchar2(1000).
However in sql workshop, when i update it using CHR(10), it does not introduce line breaks and the output comes in single line. Even in application/email body, its showing as single line.
update text set text_content='Life'
||CHR(10)
||CHR(10)
'The very essence';
The output is simply: Life The very essence.
Instead of:
Life
The very essence.
How can i introduce line breaks?
Apex version : 20.1

SQL Workshop is not a good way to determine the line break is there. It is an invisible character and in SQL Workshop you can't see it.
Run the following code
WITH mydata (c)
AS
(
SELECT 'Hello'||chr(10)||'world' FROM DUAL
)
SELECT
c,
REPLACE(c,chr(10),'X')
FROM mydata;
That shows that the line break is there.
To make it visible in email, the best way is to replace the chr(10) with a <br> tag since email is usually sent in html. You can also use css classes as explained in this question

Related

ampersand(&) and special characters are not working in ORDS print server

Recently Print server has been changed for APEX listener to ORDS Print server.
I am using “” for ampersand(&) and “§” from section sign(§) in xsl-fop.
It used to work fine in APEX Listener however PDF is not getting generated after changing the Print Server.
I am able to replicate same issue in apex.oracle.com.
Workspace: fop_issue
Username: test
Password: Test#123
Created 3 test report queries in Application 132098.
Report Query1: FOP_WITHOUT_ISSUES ( PDF is generated without issues)
Which contains simple select statement (select ‘test user’ a from dual) and Report layout is Generic Report Layout.
Report Query2: FOP_WITH_ISSUES_2 (PDF is generated with issues)
Which contains same select statement (select ‘test user’ a from dual) and Report layout(FOP_WITH_ISSUES_2) is defined with generic Report layout however added “test  user” statement in Report Column Heading.
If  is taken out and run the report then PDF is generated like below.
If just ampersand(&) is taken out then PDF is generated like below
Report Query3: FOP_WITH_ISSUES (PDF is generated with issues)
This Report also contains same select statement(select ‘test user’ a from dual) and Report laoout (FOP_WITH_ISSUES) is defined with Named Columns(XSL-FO) layout. Which is very simple FOP which contains section sign “§”
Removed ampersand (&) from fop then PDF is generated like below.
Please advice any solution for this issue.
Thanks in advance for help.
 is a decimal numeric character reference to U+001A, which is a non-printing control character. & is a hexadecimal numeric character reference to U+0026 AMPERSAND. However, & is the start of an entity reference or a numeric character reference. Any other use of & is a syntax error.
If you want to represent "&", use &. That's the predefined entity for the "&" character. If you really want to use numeric character references for "&", use &38;. See https://www.w3.org/TR/REC-xml/#sec-predefined-ent.
§ is a hexadecimal numeric character reference to U?00A7 SECTION SIGN. I don't know why it's not working for you. However, your last screenshot includes "U 0047"; i.e., the '+' from your screenshot of the XSLT is missing as well, so you might have something wrong with all of your fonts.

Ajax call returned server error ORA-01403: no data found for APEX Interactive Grid

I am trying to save data into my table using an interactive grid with the help of custom plsql. I am running into an "ORA-01403-no data found" error while inserting data and I can't figure out why.
This is my plsql custom process which I run. Appreciate your help.
DECLARE
em_id NUMBER;
BEGIN
CASE :apex$row_status
WHEN 'C'
THEN
SELECT NVL (MAX (emergency_id), 0) + 1
INTO em_id
FROM emp_emergency_contact;
INSERT INTO emp_emergency_contact
(emergency_id, emp_id, emergency_name, emergency_relation
)
VALUES (em_id, :emp_id, :emergency_name, :emergency_relation
);
WHEN 'U'
THEN
UPDATE emp_emergency_contact
SET emergency_name = :emergency_name,
emergency_relation = :emergency_relation
WHERE emergency_id = :emergency_id;
WHEN 'D'
THEN
DELETE emp_emergency_contact
WHERE emergency_id = :emergency_id;
END CASE;
END;
So far I have not come across any documented way on how to use custom PL/SQL logic for processing submitted rows of APEX 5.1 Interactive Grid via AJAX call.
You are getting no data found error because the return is expected to be in certain json format.
The example you have provided is not too complex and can be with done using standard "Interactive Grid - Automatic Row Processing (DML)" process, which is an AJAX approach. If AJAX call is not important then you can create your own PL/SQL process with custom logic. Example of which is demonstrated in "Sample Interactive Grids" package application, check out Advanced > Custom Server Processing page in this application for more information.
I agree with Scott, you should be using a sequence or identity column for ids.
Not entirely sure. A 'select into' can raise a no_data_found exception, but yours shouldn't.
That being said, you shouldn't have max(id)+1 anywhere in your code. This is a bug. Use a sequence or identity column instead.
I have gotten this many times so the first thing I do is go look at any columns in my grid sql that are not part of the "Save", they are from a join for data only.
I just got it again and it was a heading sort column that I had as a column type of "Number". I changed it to display only and the "Save" now works.
Although, I had already set the "Source" of the column to "Query Only" which is also needed.
It is a bummer the Ajax error message doesn't at least give the column name that caused the error.
Hope this helps someone..
BillC
Add a RETURNING INTO clause after the insert. IG expects a primary key to be returned to query the inserted row.

Exporting from pgadmin reads line breaks in field cells and creates unreadable Excel

I'm new to this, so I am sure it is a silly question, but I have read through every question related on the site and can't find anything!
I am exporting from pgadmin. A few of the columns have line breaks within the cells, so the exported data is very choppy. Does anyone know how to fix this? Is there a way to make it so the line breaks within cells are not read?
I know I am doing the right settings for exporting, but basically what happens is that the header names are there, along with one row of content for each column and then Column A will have 20 more rows beneath it because of line breaks from the first cell in column E.
Any help would be much appreciated!
I assume that you're referring to the Query --> Execute to file command in the Query window. I don't think it's a bug that pgAdmin doesn't escape line breaks within strings in its csv output, but Excel can read it correctly anyway.
In the export options, please make sure that you use commas as column separators and double quotes as quote chars. Here are my settings:
Additionally, when you load your CSV into Excel, please don't use Data -> From Text. This one doesn't parse CSV with line breaks correctly. Just open the file directly in Excel (via Open within Excel, or by right clicking it in Windows Explorer and choosing Open With -> Microsoft Excel).

Using RegEx in SSIS

I currently have a package pulling data from an excel file, but when pulling the data out I get rows I do not want. So I need to extract everything from the 'ID' field that has any sort of letter in it.
I need to be able to run a RegEx command such as "%[a-zA-Z]%" to pull out that data. But with the current limitation of conditional split it's not letting me do that. Any ideas on how this can be done?
At the core of the logic, you would use a Script Transformation as that's the only place you can access the regex.
You could simply a second column to your data flow, IDCleaned and that column would only contain cleaned values or a NULL. You could then use the Conditional Split to filter good rows vs bad. System.Text.RegularExpressions.Regex.Replace error in C# for SSIS
If you don't want to add another column, you can set your current ID column to be ReadWrite for the Script and then update in place. Perhaps adding a boolean column might make the Conditional Split logic easier at this point.

Calculating total number of rows for an IR from Page 0

I have a number of different Interactive Reports within my application (using Oracle ApEx 4.1), on different pages.
On each of these reports, I have pagination but I have been asked to also provide on each of the reports, the overall total number of records, displayed somewhere on the page per report.
Is there a means of doing this functionality on Page 0 or do I need to calculate total records for each report separately?
Update for commenter
As mentioned in my previous comment, I added the new "p_use_filter" boolean parameter and set this to FALSE and all works fine.
I have another query. On one of the IR reports, within my where condition, I am using a bind variable but when I drill down on a report field that passes to the other report with the bind variable a STRING and then look at the backend SQL statement, I am getting an INVALID RELATIONAL OPERATOR error because the SQL has a WHERE condition like:
WHERE (CUSTOMER_NAME = ABC AIRLINES LTD )
i.e. it is trying to parse the SQL without single quotes around ABC AIRLINES LTD ?
I'd propose to retrieve the IR SQL and then execute that SQL wrapped in a SELECT COUNT(*) from (...).
Now, with Apex 4.2 you get the apex_ir package which can get the report SQL, but in pre 4.2 you do not have such a package. I have made one for myself, and I've used it for several things (I've blogged a bit about these for example).
The code needs some cleaning, but it is functional and has plenty of commentary in it. It'll parse all the filters and transform them into SQL again. It does not handle computations or GROUP BYs. It'll maybe have some kinks left in the cable somewhere, but it may depend on what you want to do with it. In this case it shouldn't be a problem.
Git link
Basically, install the package in your schema, and then use code like this to run it:
DECLARE
lNullTable DBMS_SQL.VARCHAR2_TABLE;
lDebug VARCHAR2(4000);
lSql VARCHAR2(4000);
lCount NUMBER;
BEGIN
lSql := apex_ir_pkg.get_ir_sql
(
p_app_id => :APP_ID,
p_session_id => :APP_SESSION,
p_page_id => :APP_PAGE_ID,
p_report_id => NULL,
p_app_user => :APP_USER,
p_use_session_state => TRUE,
p_binds => lNullTable,
p_binds_val => lNullTable,
p_incl_order_by => FALSE,
p_debug => lDebug,
);
lSql := 'SELECT count(*) FROM ('||lSql||')';
EXECUTE IMMEDIATE lSql INTO lCount;
END;
You can use #TOTAL_ROWS# in the header or footer of the region, but it will only show the initial value. i use it for classic reports. I don't think it plays well with the IR javascript. That's a partial page refresh.
See: https://forums.oracle.com/forums/thread.jspa?threadID=2239712 and http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/ui_region.htm#CHDBCGJH