mariadb sec_to_time only displays up to 23:59:59 - time

I'm using:
$ mysql --version
mysql Ver 15.1 Distrib 10.2.14-MariaDB, for Linux (x86_64) using readline 5.1
and if I do queries like these:
select sec_to_time(timestampdiff(SECOND, '2018-05-31T00:00:00', '2018-06-01T00:00:01'))
union all
select sec_to_time(24*60*60+1)
The result always is '00:00:01' instead of '24:00:01'
Am I doing something wrong or is this a (known) bug?

Just found out, that this is a "display issue".
Running
select sec_to_time(timestampdiff(SECOND, '2018-05-31T00:00:00', '2018-06-01T00:00:01'))
in mysql/mariadb commandline tool gives '24:00:01'
When run on the same DB via DbVisualizer it gives '00:00:01'.
This is just a display issue as sorting works:
select sec_to_time(timestampdiff(SECOND, '2018-05-31T00:00:00', '2018-06-01T00:00:01'))
union all
select sec_to_time(timestampdiff(SECOND, '2018-05-31T00:00:01', '2018-06-01T00:00:01'))
union all
select sec_to_time(timestampdiff(SECOND, '2018-05-31T00:00:02', '2018-06-01T00:00:01'))
union all
select sec_to_time(timestampdiff(SECOND, '2018-06-01T00:00:00', '2018-06-01T00:00:01'))
order by 1
will happily display
00:00:01
23:59:59
00:00:00
00:00:01
Sorry…

Asking the DbVis experts I got the solution.
The JDBC Driver returns the result as a time object.
The commandline interface returns it as a CHAR object.
Casting to CHAR displays the same result as the commandline interface does.

Related

Why can't I find the dba datafile on the server where the database is?

This query give the list of the different datafile:
SELECT fil.FILE_NAME FROM dba_data_files fil
:D/Oracle.......
this query give me where the database is running
SELECT SYS_CONTEXT('USERENV','TERMINAL') FROM dual;
On the same serveur, I'm searching the datafiles. in :D/. But there is no subfolder Oracle.
I've searched with explorer and with powershell:
Get-ChildItem D:\ -Hidden
Why?
to get the server name. replace TERMINAL by SERVER_HOST
select sys_context('USERENV','SERVER_HOST') from dual

NIFI QueryDatabaes org.apache.avro.SchemaParseException: Illegal character in: COUNT(*);

I am trying to get the count from MySql Database using ExecuteSQL Processor. However everytime I do that I am getting following error.
Error:
org.apache.avro.SchemaParseException: Illegal character in: COUNT(*);
Following is the configuration
If I change the query to select everything it works fine, like below.
Select * from temp.test
Keep alias name for the count(*) as count or cnt ..etc,
then use the query with alias name for count(*) in you execute sql processor.
Example:-
Select count(*) count from temp.test
(or)
Select count(*) as count from temp.test

finding date before 30 days in hive-0.10.0

I have 2 hadoop clusters, One has hive-0.10.0 installed and another has hive-1.1.0 version installed.
I am able to run below query in hive-1.1.0 which gives date before 30 days from present date
select date_sub(from_unixtime(floor(unix_timestamp()/(60*24*24))*60*24*24), 30)
But, the Same query is giving syntax error in hive-0.10.0
ok failed: parseexception line 1:79 mismatched input '' expecting from near ')' in from clause
1.
Way too complected.
This will get you the same result:
select date_sub(from_unixtime(unix_timestamp()),30)
2.
Queries without FROM clause are only supported from hive 0.13
https://issues.apache.org/jira/browse/HIVE-178
Create s table with a single row (similar to Oracle dual) and use it as source

Oracle: ISO Week, wrong answer

In Oracle 11 and Oracle 12, issuing the following select:
SELECT TO_CHAR((TO_DATE('19720101','YYYYMMDD')), 'YYYYIW') || ' ' || TO_CHAR((TO_DATE('19721230','YYYYMMDD')), 'YYYYIW') AS ERRATO FROM DUAL;
I get:
197252 197252
I expected something like:
197152 197252 or 197153 197252
Why do I get the same result 197252 197252?
You're currently formatting with 'YYYYIW' which is the 4 digit year, followed by the ISO week-of-year. I suspect you want the ISO week-year, followed by the ISO week-of-year.
The Oracle documentation is very unclear on this, but you should try 'IYYYIW' as the format string instead. That uses the "4-digit year based on the ISO standard" (IYYY).
(I'm trying to run that on sqlfiddle to see if it works, but it's hung at the moment...)

Why isn't hextoraw() functioning, Am I misunderstanding it?

I'm running Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production, and I'm trying to convert a few hex characters to a string:
SQL> select hextoraw('414243') from dual;
HEXTOR
------
414243
But it seems nothing has been done here, am I miss understanding this macro?
Because the tools displays the result as string, so it seems nothing changed. Actually the datatypes are different, please use below SQL to check:
SQL> SELECT DUMP('414243'),DUMP(HEXTORAW('414243')) from dual
A B
-------------------------------- --------------------------------------
Typ=96 Len=6: 52,49,52,50,52,51 Typ=23 Len=3: 65,66,67
I believe SQL*Plus is just formatting the RAW to a format convenient for display.
HEXTORAW('414243') converts your string to the RAW(3) consisting of [0x41 0x42 0x43]. Then, when sqlplus tries to display that value back to the user, it converts it to something it can print to the terminal.
Here is a SQL Fiddle, but it looks like it displays the RAW value in base-10 format rather than hex. I'm not sure if there is a format command for sqlplus to change this behavior.
select hextoraw( '414243' ) as col1,
utl_raw.cast_to_varchar2( hextoraw( '414243' )) as col2
from dual;
| COL1 | COL2 |
|----------|------|
| 65,66,67 | ABC |

Resources