You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by Apache Wiki <wi...@apache.org> on 2007/09/13 21:48:43 UTC
[Db-derby Wiki] Update of "DerbySQLroutines" by BryanPendleton
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Db-derby Wiki" for change notification.
The following page has been changed by BryanPendleton:
http://wiki.apache.org/db-derby/DerbySQLroutines
The comment on the change is:
Grab Knut's nice example
------------------------------------------------------------------------------
* [http://mail-archives.apache.org/mod_mbox/db-derby-user/200510.mbox/%3C43418926.6010407@sun.com%3E A function that given a Date, returns the day of week]
* [http://mail-archives.apache.org/mod_mbox/db-derby-user/200501.mbox/%3c41DAC70D.7000002@debrunners.com%3e A function that converts a Timestamp to its corresponding Long value using Java]
+ === System.getProperty as a function ===
+
+ Here's a very simple example of how to define and use the JDK's {{{System.getProperty()}}} method from a Derby SQL function:
+
+ {{{
+ ij> create function getSystemProperty(name varchar(128)) returns varchar(128) language java external name 'java.lang.System.getProperty' parameter style java no sql;
+ 0 rows inserted/updated/deleted
+ ij> values getSystemProperty('derby.system.home');
+ 1
+ ---------------------------------------------------------------------------------------------
+ NULL
+
+ 1 row selected
+ ij> values getSystemProperty('user.dir');
+ 1
+ ---------------------------------------------------------------------------------------------
+ /tmp
+
+ }}}
+
+ Note that for this to work, Derby's security policy must allow System.getProperty calls to be made to retrieve the properties in question.
+
== Creating Procedures ==
[[Anchor(CreatingProcedures)]]