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
I am trying to refresh a report with dynamic action. And get the following errors:
{'dialogue': {'uv': true, 'line': [{'V': "failure of Widget}]}}
ORA-20876: stop the engine of the APEX.
classic_report"}]}}
I think its an issue with string which can't take and ST.ID IN (:P11_ROW_PK) in sql query.
Please suggest a workaround for the same.
This question requires the context you've provided in
https://stackoverflow.com/a/63627447/527513
If P11_ROW_PK is a delimited list of IDs, then you must structure your query accordingly, not expect the IN statement to deconstruct a bind variable containing a string.
Try this instead
select * from your_table
where st.id in (select column_value from apex_string.split(:P11_ROW_PK))
where REGEXP_LIKE(CUSTOMER_ID, '^('|| REPLACE(:P4_SEARCH,',','|') ||')$')
Above code will act same as APEX_STRING only if you are using lower version Apex
I've been trying to use REGEXP_MATCH to create a custom field in Google Data Studio but it's not working as expected.
Example of the data I'm using it on (this is how the data is formatted in the tags_name field:
{construction,po-johnson,po-james}
{construction,po-sandy,po-occonor}
The objective is to check if a certain name exists, then create a new label.
Here's the code I'm trying (tags_name is the field name where the original text string exists):
CASE
WHEN REGEXP_MATCH(tags_name, ".*(johnson?).*") THEN "Marc Johnson"
WHEN REGEXP_MATCH(tags_name, ".*(occonor?).*") THEN "Sam Occonor"
ELSE "undefined"
END
Is this happening due to the presence of the curly brackets/commas/hyphens?
I've tried to reproduce the error in Google Data Studio based on your problem statement. Everything worked exactly as expected though.
I've entered your input (and a few other expressions for confirmation) in the tags_name field and placed your REGEXP_MATCH function into another field:
Here is the result:
Is this the result you expected?
Is there still an issue? If so, you could edit your question and add corresponding screenshots.
There is a interactive report which I have created using ORACLE APEX. The source for that interactive report is the sql query output, given by me.
The generated SQL output have one column, which is having integer values. Now my requirement is to use this integer value(lets say "11111", these integer values are variable values) and a link ("www.xyz.com/", this is a fixed string) and generate a concat value of these two string, it will create a hyperlink ("www.xyz.com/11111"), so this link I want to use as hyperlink for the integer values in my report.
Define your column as a Link, then substitute the values you need within the declaration
The same #COLUMN_ALIAS# substitution syntax can be used fro your Link Text, or if you just want to dynamically generate the url from SQL using apex_page.get_url
Alternatively, you can formulate whatever you like in the HTML Expression attribute, using the same syntax
I found the answer myself:
Steps are as follows:
Change the type of your column to "Link" which you want to have as link.
Go to Link subsection for that column --> Choose type as "URL" --> In URL section give "www.xyz.com/##"
This will create that as hyperlink, for example "www.xyz.com/11111".
While creating a table in Athena; it gives me following exception:
no viable alternative at input
hyphens are not allowed in table name.. ( though wizard allows it ) .. Just remove hyphen and it works like a charm
Unfortunately, at the moment the syntax validation error messages are not very descriptive in Athena, this error may mean "almost" any possible syntax errors on the create table statement.
Although this is annoying at the moment you will need to check if the syntax follows the Create table documentation
Some examples are:
Backticks not in place (as already pointed out)
Missing/extra commas (remember that the last column doesn't need the comma after column definition
Missing spaces
More ..
This error generally occurs when the syntax of DDL has some silly errors.There are several answers that explain different errors based on there state.The simple solution to this problem is to patiently look into DDL and verify following points line by line:-
Check for missing commas
Unbalanced `(backtick operator)
Incompatible datatype not supported by HIVE(HIVE DATA TYPES REFERENCE)
Unbalanced comma
Hypen in table name
In my case, it was because of a trailing comma after the last column in the table. For example:
CREATE EXTERNAL TABLE IF NOT EXISTS my_table (
one STRING,
two STRING,
) LOCATION 's3://my-bucket/some/path';
After I removed the comma at the end of two STRING, it worked fine.
My case: it was an external table and the location had a typo (hence didn't exist)
Couple of tips:
Click the "Format query" button so you can spot errors easily
Use the example at the bottom of the documentation - it works - and modify it with your parameters: https://docs.aws.amazon.com/athena/latest/ug/create-table.html
Slashes. Mine was slashes. I had the DDL from Athena, saved as a python string.
WITH SERDEPROPERTIES (
'escapeChar'='\\',
'quoteChar'='\"',
'separatorChar'=',')
was changed to
WITH SERDEPROPERTIES (
'escapeChar'='\',
'quoteChar'='"',
'separatorChar'=',')
And everything fell apart.
Had to make it:
WITH SERDEPROPERTIES (
'escapeChar'='\\\\',
'quoteChar'='\\\"',
'separatorChar'=',')
In my case, it was an extra comma in PARTITIONED BY section,
In my case, I was missing the singlequotes for the S3 URL
In my case, it was that one of the table column names was enclosed in single quotes, as per the AWS documentation :( ('bucket')
As other users have noted, the standard syntax validation error message that Athena provides is not particularly helpful. Thoroughly checking the required DDL syntax (see HIVE data types reference) that other users have mentioned can be pretty tedious since it is fairly extensive.
So, an additional troubleshooting trick is to let AWS's own data parsing engine (AWS Glue) give you a hint about where your DDL may be off. The idea here is to let AWS Glue parse the data using its own internal rules and then show you where you may have made your mistake.
Specifically, here are the steps that worked for me to troubleshoot my DDL statement, which was giving me lots of trouble:
create a data crawler in AWS Glue; AWS and lots of other places go through the very detailed steps this requires so I won't repeat it here
point the crawler to the same data that you wanted (but failed) to upload into Athena
set the crawler output to a table (in an Athena database you've already created)
run the crawler and wait for the table with populated data to be created
find the newly-created table in the Athena Query Editor tab, click on the three vertical dots (...), and select "Generate Create Table DLL":
this will make Athena create the DLL for this table that is guaranteed to be valid (since the table was already created using that DLL)
take a look at this DLL and see if/where/how it differs from the DLL that you originally wrote. Naturally, this automatically-generated DLL will not have the exact choices for the data types that you may find useful, but at least you will know that it is 100% valid
finally, update your DLL based on this new Glue/Athena-generated-DLL, adjusting the column/field names and data types for your particular use case
After searching and following all the good answers here.
My issue was that working in Node.js i needed to remove the optional
ESCAPED BY '\' used in the Row settings to get my query to work. Hope this helps others.
Something that wasn't obvious for me the first time I used the UI is that if you get an error in the create table 'wizard', you can then cancel and there should be the query used that failed written in a new query window, for you to edit and fix.
My database had a hypen, so I added backticks in the query and rerun it.
This happened to me due to having comments in the query.
I realized this was a possibility when I tried the "Format Query" button and it turned the entire thing into almost 1 line, mostly commented out. My guess is that the query parser runs this formatter before sending the query to Athena.
Removed the comments, ran the query, and an angel got its wings!