17
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle SQL Developer PL/SQL Debugging Jeff Smith [email protected] || @thatjeffsmith Senior Principal Product Manager Database Development Tools Group Oracle Confidential – Internal/Restricted/Highly Restricted

Debugging PL/SQL with Oracle SQL Developer

Embed Size (px)

Citation preview

Page 1: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Internal/Restricted/Highly Restricted

Oracle SQL DeveloperPL/SQL Debugging

Jeff [email protected] || @thatjeffsmithSenior Principal Product ManagerDatabase Development Tools Group

Page 2: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Gentle Introduction to Debugging

Worksheet vs Procedure Editor

Debug Demo

How it works – boring architectural stuff

Advanced Debugger ‘Tricks’

Today’s Mission: Debugging PL/SQL < 5 Minutes

Page 3: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

FREE Oracle Database IDE/GUI Windows, OS X, *NIX More than 4,000,000 users worldwide My Oracle Support available via your DB license

Page 4: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Project Raptor 2005 ~ Oracle SQL Developer v1.0 2006 1.5 2008 2.1 2009 3.0 2011 3.1, 3.2 2012 4.0 2013 4.0.3 2014

4.1 May 2015

Release History

Page 5: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Run program, see what happens Add a bunch of DBMS_OUTPUT code Use your IDE to ‘step’ interactively through the PL/SQL program(s)

What do we mean by ‘Debug?’

Page 6: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

After the fact Extra Coding Not interactive Don’t forget to remove before Production

DBMS_OUTPUT is Better than Nothing

Page 7: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Confirm required PRIVS (DEBUG CONNECT SESSION) If 12c, configure Access Control (Fine Grained Access) Open Code – in the Procedure Editor Compile for DEBUG

Click the big ‘Bug’ button

How to Launch a Debug Session

Page 8: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Set a Breakpoint! OR Configure Preferences

Start Debugging: Step Over

Some Tips

Page 9: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Breakpoints

‘Pauses’ execution on a specific line

OR

If a condition is met

Page 10: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Step Over vs Step Into

Step Over – Executes line 51, goes to line 54 Step Into – Opens program at line 51 for debugging

Page 11: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

See whereyou’ve beenand whereyou’re going

Mind the Call Stack

Page 12: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Remote/External Debugging

Page 13: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Listen for Debug Requests

Page 14: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

execute DBMS_DEBUG_JDWP.CONNECT_TCP('127.0.0.1',4000);

create or replaceFUNCTION GET_EMP_NAME( ID IN NUMBER ) RETURN VARCHAR2 ASname varchar2(100);BEGIN select first_name||' '||last_name into name from employees where employee_id = ID; RETURN name;END GET_EMP_NAME;

Setup Debugger in your Application (hard way)

Page 15: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Just set an ENV VARIABLE!

ORA_DEBUG_JDWP=host=mypc;port= 1234

Enable Application for debugging (the EASY way)

Page 16: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

Advantages overSQL Worksheet:

Package body, jumpto Spec and vice versa ‘Breadcrumbs’ Highlighted compilererrors and warnings bydefault

Procedure Editor – a PL/SQL aware IDE

Page 17: Debugging PL/SQL with Oracle SQL Developer

Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |

SQL Developer Resources

• SQL Developer on OTN– www.oracle.com/sqldeveloper

• Feature Exchange– sqldeveloper.oracle.com

• Forums– https://forums.oracle.com/forums/forum.jspa?forumID=260

• Oracle Learning Library– www.oracle.com/oll