Pular para o conteúdo

SQL Developer Start Training for Developers – Part II

SQL Developer Start Training for Developers – Part II

Using SQL Developer with Subversion

Preparing the Subversion

SQL Developer is fully integrated with Subversion.

The first step is create a new subversion connection. Just find in the main menu the option Team >> Create Connection.

SQL Developer Start Training

Choose Manually Create a Subversion Connection:

Pt7aNwc70rEQxIRWWlkO629DN1C yGzxDnaLoNxtSiRqdA96E50W9XWCe1CI zuAVRt1eHXd6sNUSftPJfqNuLz AW5XDWHl71UFpGQmiuo5Tg72DfuBCXc82qrLrYmSnMM4vbE

Fullfill all the fields:

Z00SnLBMcFHDs2d8Hj87MpfZtU4faRvu9ZlhrswNZijVEdUx2oJhl5T3m2EKu2fJuqDSNx6 I 0cc5U ZB9A9k7AFE1Yv2NVzwP7Aa30Tl0B jvMlbh0sv PYic6XyzVlEZQaIg

Click oin Test Read Access Button to test your connection:

If you don’t have a repository created, it´ll be necessary create one. Just go to Team Menu and choose Create Local Repository:

pGbtfZU76Yy4xCeKXRRUYX8U

That´s it ! Now, it´ll be necessary to do a checkout to copy the files from the subversion to your local repository. Go to Team Menu and Choose Checkout:

ACJAXVuEtu8CskPMedT857WhuIiqwaER5LI922Dg19aFF2gfT B57E975YJG RjGzuS3t8dmEyBQjuwUgGJEj9aSdwA8ar8YUZy5RemWFUrmUzWZUv3ha ot0DNEt98dMbMZQpYj

It´s done ! Your repository is updated and ready to be used !

Using the Subversion Integration

Now, it´s time to use the Subversion Integration. The first action is to open the Files Window. Go to View Menu and choose Files. A new window will be opened:

YqgoAW0 kMkSwA RPgdLikovKXgKVfflAXtdkH4l1uxuELupMgiZWXa21uH3ECLuizGsr29qk 11y7 iYwh9WIwEprEwLBIxQqPjD9J1x6 whO2HmBOh33KSSzOArw6fIfdZkr0

Choose the object and right click to open the menu option:

Tr28nxQEV1NeXaGwNFZg70gBPlk1BIb5CVTAXtpGY4c9utTm7 GRFeayuiA uYMVvG8M5YCMlUZygBrJj3uilwPCMV40mHaGI8ZsSJDKlas HFBkYH8jTf1b0MOp0Jx rZfELLJZ

Click in Open and the database object will be available to change.

Now, go to the Team menu. The Subversion options are available !

That´s it ! I won´t talk about Subversion, because is not the focus. Let´s continue to learn about Subversion !! ☺

Working with database objects

SQL Developer give a fully support to work with database objects. Let´s create one and learn a little more about this tool.

Let´s use the code below to test:

--

-- valueType Package SPEC

--

CREATE OR REPLACE PACKAGE valueType AS

  PROCEDURE question

     (

      p_text IN VARCHAR2

     );

  PROCEDURE question

     (

      p_text IN NUMBER

     );

  PROCEDURE question

     (

      p_text IN DATE

     );

  FUNCTION  answer

     (

      p_type IN VARCHAR2

     ) 

     RETURN VARCHAR2;

  FUNCTION  answer

     (

      p_type IN NUMBER

     )

     RETURN VARCHAR2;

  FUNCTION  answer

     (

      p_type IN DATE

     )   

     RETURN VARCHAR2;

END valueType; 

/

--

-- valueType Package

--

CREATE OR REPLACE PACKAGE BODY valueType AS

  v_answer VARCHAR2(100) := NULL;

  PROCEDURE question

     (

      p_text VARCHAR2

     ) 

  IS  

  BEGIN  

     DBMS_OUTPUT.put_line('VALUE ' || p_text || ' is ' || answer(p_text));

  END question;    

  PROCEDURE question

     (

      p_text NUMBER

     ) 

  IS  

  BEGIN

     DBMS_OUTPUT.put_line('VALUE ' || p_text || ' is ' || answer(p_text));

  END question;    

  PROCEDURE question

     (

      p_text DATE

     ) 

  IS  

  BEGIN

     DBMS_OUTPUT.PUT_LINE('VALUE ' || p_text || ' is ' || answer(p_text));

  END question;    

  FUNCTION answer

     (

      p_type VARCHAR2

     ) 

  RETURN VARCHAR2 

  IS     

  BEGIN

     BEGIN

        v_answer := 'VARCHAR TYPE';

     EXCEPTION

        WHEN OTHERS THEN

           v_answer := 'ERR';

     END;

     RETURN(v_answer);     

  END answer;

  FUNCTION answer

     (

      p_type NUMBER

     ) 

  RETURN VARCHAR2 

  IS

     v_answer VARCHAR2(100);

  BEGIN

     BEGIN

        v_answer := 'NUMERIC TYPE';

     EXCEPTION

        WHEN OTHERS THEN

           v_answer := 'ERR';

     END;

     RETURN(v_answer);     

  END answer;

  FUNCTION answer

     (

      p_type DATE

     ) 

  RETURN VARCHAR2 

  IS

     v_answer VARCHAR2(100);

  BEGIN

     BEGIN

        v_answer := 'DATA TYPE';

     EXCEPTION

        WHEN OTHERS THEN

           v_answer := 'ERR';

     END;

     RETURN(v_answer);     

  END answer; 

BEGIN

   NULL;

END valueType;

/

Just copy the code and press F5 (Run Script).

q8qFen9Dg k3Ci0kX3b5YKgA3nOqoPONsx D1a7fyIww7QGFqjIVbws6ppG iO4St8qL8WLvGOqLgH7Rx58TCsRP

Now, we must create an anonymous block to call our test package. Open a new SQL Worksheet (ALT+F10).

BEGIN    
   DBMS_OUTPUT.PUT_LINE('Begin...');    
   valueType.question('TEST');    
   valueType.question(1);    
   valueType.question(TO_DATE('01/01/2017','DD/MM/YYYY'));
   DBMS_OUTPUT.PUT_LINE('End...');     
END;

Let´s run ! (F5)

fQAEU4BzJa5MUlSuWFEFe2qLasaRxRMG SXEU2sPZS Z5fnQQxrPmOQoScga9Y7z KSLcEZjDnksVL42gu1fWz ivkAJ5sFndj3Kh U 6ILXnItQ4KMnmLZRX21fzlYsHAiT 1S

Where´s the DBMS_OUTPUT ?

Remember, it´s necessary to open the DBMS_OUTPUT Panel (CTRL+N). Let´s run again !

grW Y4pOpL3hW65ZahsrkximlKh1YpBilbrCknDHwwXFTCFA0Ujgquvqv bJ2W7QCpEJtoQ 1dgevBRaZNQbCz0wlhik

It´s works !!!

Now, it´s time to learn how to debug.

Debugging a database object

First, open our object clicking ion the name of the package and pressing SHIFT+F4. The Package SPEC will be opened. To open the BODY, click oin LVnrNMhJJNz4EIQZGZryfr5weG6gCgRq49t6T4eD2vx6q8KMSZsi44ptak8GZLG15uGB8YBofbE kie5frbH58JftzJULcter q9Emyn2xeCzlNP8js5ulU82XX 6dL RKgJFy7U at the toolbar above. A new Worksheet will be opened with the Package BODY.

CUKpY7ph1pbkDjPdihn75hRFF3NeAytVUgcFybhip l3eztFon4I1V68mKJZ47KE4t9U1shpacrcoNQ7JMUuPMX2jZlLFu4llISN80TJmGrPA881mKYt3ou64zlSgXfkSYlD1s3y

Now, click oin line number to create a BREAK POINT. you can create so many breakpoints that you want !

When you run the debug mode, the execution will stop at any break points created.

A7vEex0k3xXtiZTqF3kw5JhEZ6OrptVTAYbrBhusAn09sCZu5N6D6TqR8YaUhiZ 4Hd6FvrsEghX4BcCfEs FPdof4J iopdW3sNOfQ XcbEe 2TH723MkTle FwsQ0V7 ORmekd

To execute the debug mode, just click on the red bug icon 4KVzYMeRVsWUEGBfi3hbujMQtDWOjtE8 ofdgez9B8Z2HI1vrI1geRJZ PsFrKPWut8bVruUhYIYq4qbx6tPZKDTccK0gtEOIooK9u e0PIZoMqegurc Wu014r33A5GF0a6c1DT (CTRL+SHIFT+F10). A new window will be opened, and it is divided in three parts:

Target

Show all public functions and procedures available in the Package. Choose one to execute;

Parameters

Show all parameters that belongs to the function/procedure highlighted;

PL/SQL Block

Show the code to execute the function/procedure highlighted;

Now, put a value in Input Value field located in Parameters. Click oin ok after that, and a new worksheet will be opened:

a76g526iZFaCcC2YgA388nA2kjzUWpZ5YpMNUiyFs4uoAzZOM1vJv2TEZfSa2o8cBRV1 LPbn9a22lRqqLhfAbclv3rPpFK9TWTWZCKGuLJpfCqGulnrlkQk7cr0IcdrYQaUjeFS

The debug mode ran, but didn´t stop at the break point. What happened ?!?

There´s a simple explanation…To run any database object in debug mode, it´s necessary compile for debug.

No5WiJtSFOhWWxIjM7E es SVeqAhxXbDt4eIGmycew QWnWIMzUTntIbE3bbEhyOS lZ95NP G76WUDiZ8qBwSNPOv5Mf3Q92zKbetde6goytDFNygTleXIFC4ztKGa7ombz1dv

Let´s try again ! 4KVzYMeRVsWUEGBfi3hbujMQtDWOjtE8 ofdgez9B8Z2HI1vrI1geRJZ PsFrKPWut8bVruUhYIYq4qbx6tPZKDTccK0gtEOIooK9u e0PIZoMqegurc Wu014r33A5GF0a6c1DT (CTRL+SHIFT+F10)

SNb fGveLSwJIYpa9KRA3i0sxBWFaIu35WaAvzu2aUk 0Q6IaamSdezN3 r8agsFxnctxdqiOMCqjGi2FE 0wW97zH0kP noBD4scWxP hDmN PFcG0fcBjXqmtROD8ls0y5I8uk

The execution stopped at the breakpoint !

Look ! Something changed in toolbar and a new Panel appears.

D60xtV2ZDhki4SbmEhamUWciS2yfMVIhTKdY2IixbbJA58mzIptgmaGIYJvWe9k1SDgtZ 7oL1iPPlirTIP5kRjcSzYmzM 0M8FPZRDIQogr5fSF X8l43gS2ZqfdczCYl2i478

Debug Toolbar

TdXsZst2kaxAYc4NU9 IPWmBfJEZTs2CVdVasoljraffBb7yMk5Xjsk3BLVTWmAx A1jmkvLr88KjjEjAEEOyq8 JrLY59tOuEZ4R57KHHaqVRJipk4LiV4HmUFpUKWWD7s jNZD Terminate Test;

Zx8T62 J6Xp0rCvNyDoMByNaga1KkUD efQoN1MCechNsDody77fd kFHWp n8 DjlBI017wnHMhTlKg6GmZVHJGCW Sbw89 GQ2YXNzuA IfmsZ3FXd 0clb1lPjz6jY5Baaj Find Execution Point in Test (ALT+F3);

R9MI P6u RNdgv Step Over in Test (F8);

G7ogArjUEooAxFqyPEFs3FUMVme13dMfnGx92WWX1zXldZqgIM5BeoBlH3eByyFdfwnlkgocZzgpyncXVlK971gNY6FtldtzY0M6JiYUjoQXSQDOEd7W39OptU b1qMZsZe7mQ3v Step Into in Test (F7);

XinSXtPfewySRg3x4rA1QL6yuWbwXKyvcmofArYTSJnCwQMlqraMVjjvMg8TLuglDiNuX7w47PDeY2IzDESn4h hBOIYwG AihIigQm tNKgD0M2Lcs0PazDIVw5IDGtrme5 KIf Step Out In Test (Shift+F7);

LYqdlQNuvzFmKXP6yuaifQqx4jUhufZ3DR5bYSx2bk3SnRoiVVZ3bzKAb4cqp mJYm6SPqiUhzC I Sq5eNoln0EKiuvIsKvFWyihyuq64AK3seQvB1FOngMS3BBuF9mJ1g1Rz8c Step to End of Method in Test;

aBRJdBEQJpkoWsge aK8xivKCkFs4TzEwaU9jVPmLyC 6h9P6feQ y21ZYiLQGaGFSeoO Zkrkdc 8RJwK3QKlggXAg5U4ezl47nwRIdvBw2E8u4eG 6zNiRR2XhLz1ocpm77DFt Resume in Test (F9);

Pause in Test;

Suspend All Breakpoints in TEST;

Any option in debug toolbar is self-explained  ! ☺

Debug Worksheet

Now, we´ll take a look in at all new panels opened in debug mode:

Breakpoints Panel

Show manual and exception breakpoints.

Smart Data Panel

Auto-inspects the last X accessed variables.

A DoVZSJcYTRYg0fC27OYLaiy3IDXsADgQoUYnTfTu5gCMOwHbtvRYi LM5Yfj2MN5TFXPTztO zHSY0wCHdEVkpXsKJuAcVemROGa AYOI8o7zBSQrruR Crh6ZYZyme RatqYh

Data Panel

All variables are displayed.

Jl6Qr0KWp3Hujc9hx o1wa8ZA0W VCERqPY31XQJVmA1sLevIBt9WrdbOlNjdPq4MhZu4QIiuzJD4Qc6lMIgPCR3l0kTrDy ee0LzDlc1jKEEUaRMfZqOiAOqMjy5SM UfrdH1Nl

Watches

Show all watched created to monitoring.

M8aRpx7Ec5HfSdXKm85c 6ViGq82j41EDwyqkD3shu4fxEqBNrYA0cRI ohLhGC7IEDaBPUQ2gnUUBj05u1JUYINDPLaamFO5YbMghbvSSS7J RYXuZWXOwcEshBebdZnVTinRY0

It´s very easy to create a watch and monitoring the variables. After you start the debug mode, right click over the variable name and choose “Watch”.

7ylR8Y45 ueJgnnUt3hiaEFudyV71QvFJDvWbTB51YrxauhEWhZ3DhoM EEbAD65D4laC77dBem5kGwFQRiDpEosepSv fVYfHAfJyzgCG1HfDFMz0VQ mTozkLeRFaHCawGhPE8

You can create any watches that are you want.

Debugging IDE Connection

Show debug executing information.

CVxIlM212HUtZ44b9L2et1Qi1zAIv1VMDz7ygOSSTehUIuDhjYsWhjZO TIiLYnS5drXIK9TlE2WrqVDGyL oDgHjeuFIO8pVtwnz83K

User Defined Reports

Do you have a library of SQL scripts that you run in a regular way ? Off course you do ! SQL Developer offers an interesting way to storage and run those.

Just click in on “View” option on in main menu and choose “Reports”.

A Reports Panel will be opened.

xX8PVLZIbCo 6hhr2tiSMJgAGe4KL215tnNRFL3c5PEkQFhTCv6IFIa G7IOjAd7C7ECjLaCtd3LBpfymhZbLk9ixkJSb h6ntGoQCiP57zB8poT vyAjG8hYm8VZae4HLhdugX3

Creating an user defined Reports

To create a new report, just right click on User Defined Report paste and choose New Report…

2P61VNXpcnpwsqreEFg9P69ELdRo S9nFfnJ tQuym 5Ka3ckHW51W0yi07nXDBOZX4Ci 3U kyb

A Create Report Window will be opened. Fill the following fields in Master Report option:

xoVm4nOAwwvWZNUCSbqGtlVJ6a9EdkPsq79O0qAbvLufLMnYM3QeQ N opsth76Wm b0hRNzUbwPXNSNmGd6Hbtyf2YoNFzYQX9TkbK0W92N95nr1kzDjQUX4Rw3IT9d6HBvLZr

Name

Report Name;

Style

Report Style (Table, Chart, Gauge, Code, Script, PL/SQL DBMS_OUTPUT) ;

Description

Report Description ;

Tool Tip

Some tip to run the Report ;

SQL

Your SQL code.

Just click on Properties to change the Report Table Type

cXjT4hipuRmHd6aSuTyFEGm G5pbHT3yACgetNeCqQeKj7hRpT1tlhFBWongOVB3yzN

Table Type

Horizontal or Vertical.

After that, click oin Apply button and your Report will be ready to run !

RDaR14ksUy6h8VRwl28c6FnnWeijYlrltg91Y w7mkPf7qY31gC7260G 7o yzfhJXcSR8l9HwAMx9UxezF0pEdWX3mJHf38aybRO bTnSnSPvVHqXlVLH1RB730V vr8G5dSdEk

Running a Report

Just double click oin your Report Name. A new panel will be opened:

Yg2Q577RusyyufKytOoK8e7g2666rin7KuAKQfeR5VNopLhWSRXx77miTasOl5b1SUjYJqw1x4APTXImuMta eRWBZ6k2vFEAGpYDH5XBPR4d7HCXqmtclqNwW 8IDwJLV uEnM4

Click oin the green arrow to execute. A window with the parameters will be opened:

1Il7FQgHrBbU16hhoVjO9GRIEdejVl13Ss6ZUqiaIlvswHT nX0ttvRpicrTqrqBottDwF5mCTbhOQ CEKYa90ORL8zZOt tl NdYaAw45k1d2rMYBMV1hkl280jltEWDVAnWnLl

You made it ! Congratulations ! ☺

DG0B8viLwE2wqvpKhsFSx3 skdz3yzTKubjNTRwjMnrOKExy2VtxsPgyIGj 4kZPiKQvWZBaHngsUin4LGmEq165

Let´s talk about some tools offered by SQL Developer !

When I was talking about the option Save the Grid, I said that I would´ll speak about it later. Ok, now it´s time now  !

db u3FUbMR27wmVsB5KxUzJBIPop29mKXlXWE80GBdqU53S3SE0k9FXRcAiGpPMxF6TPSzl6VYdXPfXhR0IloTB10DfbVJHZSqme86Ctc05yXj44PA gw3jk GTWbQq2gP Li62K

SQL Developer allows to transform your SQL code in a Report. Just click oin Save Grid as Report and follow all the steps described in this topic.

SQL Developer Tools

SQL Developer 4.2 brings an interesting pool of tools to support developer work. Let´s talk about some of them. Go to the Tools option in main menu:

Database Copy

It´s highly probably that you don´t have access or permission to do something with that, but, the database copy tool is available !

eGljkdULp68b79r10SuVqpKLqIpMRUKga3oBXgTd4T57HW urqA6EGI9Pu2ZKm2lQGhKOWz1zLzz5T37EiMN0h8kHXK7bxPOck8pEsGXl8LcxAsg jt3j0wCK0tpBci39BHT RDa

Database Diff

Database difference is available in SQL Developer, but it´s not a good idea run this tool in PRODUCTION environment.

Database Export

A tool to export database objects ? Off course it has ! Just use the common sense !

75Z3Y4xmXqC90oWye1BPpEXoSnP2Y56MkrAq5QKR9T03OMbSeAbiq 7CL2wgo9MAkWUcjcj4JIrOWnnrT DYS0AIqKK9Q BUI6vzzH2VUTgtADBiGDZ3WVrsLQHOZY jc4r tjoN

Import Data

I almost forgot to talk about Data Import. This functionality is not described in Tools Menu, but exists !

Go to the Connections Panel, find your connection and double click it.

CqyEnQxPYNUqm2n38ZafWq0O7T1nj5nnx 9Zr7mv OSKqNSJPzJTH9l21mN8HuYQ5 qp5kPB6HZAsjGFvnwwBRKZXHGy HqM9t GlpPYCfMh DmkGLBePRm0fQCpEZrHy71k6lH

Open the Tables Paste and find the table that you want to import data and right click. Choose Import Data in Menu.

MEnvHTRrNjbxgmIW 08mEKtq8jOsrRJPxRoFXzh573E0J85N1FOIbX3jRBVTJvo8yj0pmzLn8R

Choose the file to Import and follow the steps:

bnX9noViwZSMmHyO Zpdc8SK8ZAeW9NQwXpRfv5yqVjfY1pefdWJztMRmPrQFTWJ9hPnvylNRcMuYE46qbP1ZI mNFFBKmbO78COL 4GOPKRuvXMvZLmXyoHchqFM3mD CH2PmTg

Easy Peasy !

Monitor Sessions

Do you need to take a look in your sessions running ? Monitor Sessions will help you with that !

0 SrCoa7TfS3RZcn1M

Active SQL, Explain Plan, Waits, Server, Client, Application, Contention, Long Opsq…everything available !

Real Time SQL Monitor

That´s my favourite Tool in SQL Developer. The Real Time SQL Monitor tab displays details and performance metrics for all the SQL queries that are running in real time. You can browse through the pages, if there are multiple queries in the Real Time SQL Monitor.

ki8P9DzqF71hFhKim9LYR8VzruqUIU5kDXpCMyldtSw18 neUBUWbQW9yNCXuRwsuGcVKE8T57aoS LzASHjdr9qQpiGL5n1IRP1RnMPdwpGXPLzlpew6u0dvzeQ6nfU PGtA28

You can see additional details for the selected entry underneath the list. It displays additional performance monitoring information for the selected entry under two tabs namely, Plan Statistics and Metrics. Plan Statistics provides you clear information like drilled down operation by line id, estimated rows, cost, executions, timeline, memory consumption, temporary memory consumption , I/O requests etc.

n1FI3xKvQLZ42eJPl5Gs5ctJKD4X6CgwZlW hhioyfPrIz3QocTMYRQitdppFetjeDBdem8M7Tb9 OVcpr1u8F vgq09Ye DvBM6fjYqeFoeptJH5OmsAtQTZ2 TFDVza9PUsmNL

SQL Developer have bunch of DBA Tools and integration with REST, Hadoop and other technologies. But, it´s a subject to another training ! ☺

I hope you enjoyed and learned a little about SQL Developer and its features !

See you in next doc/article/training !

https://www.profissionaloracle.com.br/2017/04/02/sql-developer-start-training-for-developers-part-i/
Sergio Willians

Sergio Willians

Sergio Willians é o fundador do GPO (Grupo de Profissionais Oracle) e possui quase 30 anos de experiência em tecnologias Oracle, sendo especialista em desenvolvimento Forms/Reports, PL/SQL e EBS (E-Business Suite) nos módulos Receivables, Payables e General Ledger. Atualmente trabalha na Scania Latin America, onde se dedica à área de integração de dados com Confluent Kafka. Sua paixão é compartilhar conhecimento com a comunidade Oracle, contribuindo para o crescimento e a excelência da plataforma.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

plugins premium WordPress