oracle-sqldeveloper

Oracle sql order by with case statement

早过忘川 提交于 2019-12-01 07:17:27
I am facing difficulty in understanding oracle(12c) sql order by clause with case statement. I have a table with the below data, SELECT DEPT_NO, DEPT_NAME FROM SORTNG_LOGIC; DEPT_NO DEPT_NAME ---------- -------------------- 1 FINANCE 2 ACCOUNT 3 HUMAN RESOURCE 4 AUDIT 5 TRAINING I am executing the below sql query for this table to add custom order, on oracle sql developer. SELECT DEPT_NO, DEPT_NAME FROM SORTNG_LOGIC ORDER BY ( CASE DEPT_NAME WHEN 'ACCOUNT' THEN '1' WHEN 'AUDIT' THEN '2' WHEN 'FINANCE' THEN '3' ELSE '4' END )DESC; This is giving the below result : DEPT_NO DEPT_NAME ---------- -

Oracle : Export select statement result set as INSERT SQL Statements similar to SQL developer export

对着背影说爱祢 提交于 2019-12-01 06:53:23
I am looking for a solution to create the SQL INSERT statements using PL/SQL script for the select statement result set. Looking for similar feature available in the SQL Developer tool (export --> format insert) but I want the solution as script rather than using any tool(s). I have referred the below solution. However, I would like to know whether any better way to do it as the solution is old and not very simple. EXPORT AS INSERT STATEMENTS: But in SQL Plus the line overrides 2500 characters! I just found a simple solution for my problem using oracle hint ("insert"). This automatically take

Solving the mutating table problem in Oracle SQL produces a deadlock

不羁岁月 提交于 2019-12-01 06:36:47
Hey, I'm trying to create a trigger in my Oracle database that changes all other records except the one that has just been changed and launched the trigger to 0. Because I am updating records in the same table as the one that launched the trigger I got the mutating table error. To solve this, I put the code as an anonymous transaction, however this causes a deadlock. Trigger code: CREATE OR REPLACE TRIGGER check_thumbnail AFTER INSERT OR UPDATE OF thumbnail ON photograph FOR EACH ROW BEGIN IF :new.thumbnail = 1 THEN check_thumbnail_set_others(:new.url); END IF; END; Procedure code: CREATE OR

Execute scripts by relative path in Oracle SQL Developer

混江龙づ霸主 提交于 2019-12-01 05:19:46
First, this question relates to Oracle SQL Developer 3.2 , not SQL*Plus or iSQL, etc. I've done a bunch of searching but haven't found a straight answer. I have several collections of scripts that I'm trying to automate (and btw, my SQL experience is pretty basic and mostly MS-based). The trouble I'm having is executing them by a relative path. for example, assume this setup: scripts/A/runAll.sql | /A1.sql | /A2.sql | /B/runAll.sql /B1.sql /B2.sql I would like to have a file scripts/runEverything.sql something like this: @@/A/runAll.sql @@/B/runAll.sql scripts/A/runAll.sql: @@/A1.sql @@/A2.sql

SQLDeveloper jump between Package body and Package spec

亡梦爱人 提交于 2019-12-01 04:21:16
I'm currently using Oracle SQLDeveloper a lot more that I have ever used and I'm starting to like the tool. I use Shift+F4 a lot to jump into a package/function/procedure. But one thing that I don't really get is how to jump directly to the package body or as an alternative some kind of shortcut that toggles between the spec and the body of a package. Toad has something like this and I'm unable to find this feature in SQLDeveloper. I'm also aware that you have the object tree on the left side of the screen but it's not really the best way to navigate to a package body when you are already

Solving the mutating table problem in Oracle SQL produces a deadlock

我的未来我决定 提交于 2019-12-01 04:17:54
问题 Hey, I'm trying to create a trigger in my Oracle database that changes all other records except the one that has just been changed and launched the trigger to 0. Because I am updating records in the same table as the one that launched the trigger I got the mutating table error. To solve this, I put the code as an anonymous transaction, however this causes a deadlock. Trigger code: CREATE OR REPLACE TRIGGER check_thumbnail AFTER INSERT OR UPDATE OF thumbnail ON photograph FOR EACH ROW BEGIN IF

What is the maximum statement length in Oracle

半腔热情 提交于 2019-12-01 03:32:28
I'm building a SQL statement that contains data and I'm wondering if I would break some maximum statement length in Oracle 10g. The statement would be about 3 200 000 bytes, cannot be split and has to be parsable in its entirety. Before I'm investing too much time this way, I was wondering if I would be limited by the size of this statement. I am using SQL developer but I think that if the server can do it, so can SQL developer. There is no fixed number. See "Logical Database Limits": http://docs.oracle.com/cd/B19306_01/server.102/b14237/limits003.htm "The limit on how long a SQL statement can

PL/SQL How to get X day ago from a Date as Date?

烂漫一生 提交于 2019-12-01 03:08:27
I want to get 100 days ago from 08-APR-13, as date. How to do it with pl/sql? Assumption was made that the 08-APR-13 is a string in your situation. So you need convert it to date using to_date function, and then simply subtract 100 literal. SQL SQL> select (to_date('08-APR-13', 'DD-MON-RR') - 100) res 2 from dual 3 / RES ----------- 29-12-2012 PL/SQL SQL> declare 2 l_res_date date; 3 l_in_date varchar2(11) := '08-APR-13'; 4 begin 5 select (to_date(l_in_date, 'DD-MON-RR') - 100) 6 into l_res_date 7 from dual; 8 9 dbms_output.put_line(to_char(l_res_date, 'dd-mon-yy')); 10 end; 11 / 29-dec-12 PL

SQL Developer “disconnected from the rest of the join graph”

徘徊边缘 提交于 2019-12-01 03:00:30
I have the following SQL: select <misc things> from pluspbillline left outer join workorder on workorder.siteid=pluspbillline.siteid and workorder.wonum = pluspbillline.refwo and workorder.orgid = pluspbillline.orgid left outer join ticket on ticket.ticketid = pluspbillline.ticketid and ticket.class=pluspbillline.ticketclass left outer join pluspsalesorder on pluspsalesorder.salesordernum=pluspbillline.salesordernum and pluspsalesorder.siteid=pluspbillline.siteid In Oracle SQL Developer 4.0.0.13 (connected to a DB2 database), I get a squiggly line underneath the following italics: "from

Execute Statement or Run Script?

℡╲_俬逩灬. 提交于 2019-12-01 02:42:41
While entering a SQL statement in Oracle SQL Developer, I noticed that I have two choices. I can either "Run Statement" or "Run Script". A similar choice seems to be available in SQL Maestro as well, although named "Execute query" and "Execute as script". What exactly is the difference between the two? Greg Reynolds Run Statement will give you a list of all the results in a sortable table. It will also only run the statement under the cursor (or highlighted). You will be prompted for bind variables when you run the statement (any place holder with : in front of it). E.g. select * from