Posts

Showing posts with the label oracle-sqldeveloper

compiler error while creating trigger in sql developer;

Image
Clash Royale CLAN TAG #URR8PPP compiler error while creating trigger in sql developer; I have two tables: create table superheroes('sh_name varchar2(30)); create table sh_audit(new_name varchar2(30), old_name varchar2(30), username varchar2(30), entry_date varchar2(30), operation); trigger: create or replace trigger SUPERHEROES_AUDIT before insert or update or delete on superheroes for each row enable declare v_user varchar2(30); v_date varchar2(30); begin select user, TO_CHAR(SYSDATE,' DD/MM/YYYY HH24:MI:SS') INTO v_user, v_date from dual; if inserting then insert into sh_audit(new_name, old_name, username, entry_date, operation) values(:NEW.sh_name, null, v_user, v_date,'insert'); elsif deleting then insert into sh_audit(new_name, old_name, username, entry_date, operation) values(null, :OLD.sh_name, v_user, v_date,'delete'); elsif updateing then insert into sh_audit(new_name, old_name, userna...

Find the length of the longest row in a column in oracle

Image
Clash Royale CLAN TAG #URR8PPP Find the length of the longest row in a column in oracle Does anybody know if there is a way to find what the length of the longest row in a column in Oracle? Basically I need to get the length of the longest row and then use that length plus 1 with SUBSTR to make the output of the column one character longer than the longest string. SUBSTR Thanks EDIT: Thanks for the advice. However, the MAX(LENGTH(column_name)) AS MAXLENGTH approach gives me the number I want but when I try to use it with SUBSTR(column_name,1, MAXLENGTH) I get an invalid identifier error. MAX(LENGTH(column_name)) AS MAXLENGTH SUBSTR(column_name,1, MAXLENGTH) SO I made a function to return the numberI wanted then used: SUBSTR(column_name,1,maxlengthfunc) This gave me the following output: SUBSTR(NAME,1,MAXLENGTHFUNC) Rather than: SUBSTR(NAME, 1, 19) And it didn't shrink the output column size like I needed. Also RTRIM(name)||' ' didn't do anything for me in SQL develop...

How to generate timeseries data into table in Oracle PL/SQL between two date using interval 1 minute?

How to generate timeseries data into table in Oracle PL/SQL between two date using interval 1 minute? I am new in this topic. In my setup Oracle 12c Standart Edition database and PL/SQL Developer. I have a table which has the following structure: int id; timestamp time_mon; double price; I need to insert data into a table which generate with some period such as 02.01.2018 00:00 - 02.01.2019 00:00 with an interval of 5 minutes. I cannot cope with this task. Please help me and show the SQL code example. 1 Answer 1 Assuming you mean 02.01.2018 = 2 January, this could be a way: select date '2018-01-02' + interval '5' minute * (level -1) from dual connect by date '2018-01-02' + interval '5' minute * (level -1) <= date '2019-01-02' By clicking "Post Your Answer", you acknowledge that you have read our updated ...