Running SQL from a Agile
PLM Groovy Event Handler
Introduction
 Will show how to execute SQL from a Groovy
handler using the SQL connection already
established by the cont...
Sample Script
import
import
import
import

com.agile.agileDSL.ScriptObj.*;
com.agile.api.*;
com.agile.util.sql.*;
java.sql...
Setting Up Agile for the Test
 Setting up the event for our demo
Setting Up Agile for the Test (cont)
 Defining the event handler
Setting Up Agile for the Test (cont)
 The event subscriber
The Results
I set up my script to execute on
the title block update event for
items, so simply modifying an
attribute on a...
About Us
 PLM Mechanic specializes in the technical
aspects of Oracle’s Agile PLM solution
 We offer the following servi...
Contact Us









Web: http://www.plmmechanic.com
Blog: http://www.plmmechanic.com/blog
Facebook: http://faceboo...
Upcoming SlideShare
Loading in...5
×

Running SQL from a Groovy Event Handler in Agile PLM

876

Published on

Have you ever run into a situation where you needed to run SQL from an event handler or PX but wasn't quite sure how to do it? This presentation will show you how to get a connection to the Agile PLM database and execute SQL without worrying about the connection details.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
876
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Running SQL from a Groovy Event Handler in Agile PLM

  1. 1. Running SQL from a Agile PLM Groovy Event Handler
  2. 2. Introduction  Will show how to execute SQL from a Groovy handler using the SQL connection already established by the container  Should work fine in a PX – add agileclasses.jar to the IDE classpath for the build but cannot run in the debugger since the PX is not in Agile’s class loader
  3. 3. Sample Script import import import import com.agile.agileDSL.ScriptObj.*; com.agile.api.*; com.agile.util.sql.*; java.sql.*; void invokeScript(IBaseObjectScriptObj object) { Connection connection = null; PreparedStatement statement = null; ResultSet rows = null; try { connection = ConnectionFactory.getFactory().getConnection(); statement = connection.prepareStatement("select ifs_url from vault"); rows = statement.executeQuery(); while(rows.next()) { // log the SQL response object.logMonitor( "SQL Response: " + rows.getString("ifs_url") ); } } catch (Exception e) { object.logMonitor( e.getMessage() ); } }
  4. 4. Setting Up Agile for the Test  Setting up the event for our demo
  5. 5. Setting Up Agile for the Test (cont)  Defining the event handler
  6. 6. Setting Up Agile for the Test (cont)  The event subscriber
  7. 7. The Results I set up my script to execute on the title block update event for items, so simply modifying an attribute on a part and saving the changes will trigger it. If we inspect the event monitor the following entry is found.
  8. 8. About Us  PLM Mechanic specializes in the technical aspects of Oracle’s Agile PLM solution  We offer the following service: – Agile PLM installations and upgrades – Agile PLM maintenance and help desk functions – Agile PLM hosting – Customization  PLM Mechanic also has several product offerings
  9. 9. Contact Us         Web: http://www.plmmechanic.com Blog: http://www.plmmechanic.com/blog Facebook: http://facebook.com/PLMMechanic LinkedIn: http://www.linkedin.com/company/plm-mechanic Twitter: @PLMMechanic Email: sales@plmmechanic.com Phone: 512-827-2262 Fax: 512-582-2932

×