Friday, May 23, 2008

Creating - Oracle DB Links

1. Log into the db from which the query will be executed.
2.create public database link using
ex Create Database link db1_link using db1_machine1
3. Database link is created

Common Problems
===============
1. When global_names parameter set to TRUE then default domain name 'REGRESS.RDBMS.DEV.US.ORACLE.COM' is appended at the end of the dblink name and will cause ORA-02805 error.


Changing global names
================
Alter system set Global_names =false;

Thursday, March 27, 2008

Date Queries in MS Access

Writting query in MS Access for Date column differes from other SQL formats. For eg Writing the sql in ORACLE you will follow this patterrn

Select First_Name, DOB from emp where dob='01/jul/2008'

whereas in Access it has to be written like this
Select First_Name, DOB from emp where dob=#01/jul/2008#

Access understands the literals enclosed within # as date.

Sunday, February 24, 2008

Java - XPath for parsing XML

XPATH
(XML Path Language) is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values (strings, numbers, or boolean values) from the content of an XML document. The current version of the language is XPath 2.0, but because version 1.0 is still the more widely-used version, this article describes XPath 1.0.

The XPath language is based on a tree representation of the XML document, and provides the ability to navigate around the tree, selecting nodes by a variety of criteria. In popular use (though not in the official specification), an XPath expression is often referred to simply as an XPath.

Originally motivated by a desire to provide a common syntax and behavior model between XPointer and XSLT, XPath has rapidly been adopted by developers as a small query language, and subsets are used in other W3C specifications such as XML Schema and XForms.


Using XPath sample

1. Create the DOM XML document
String fileName = "D:/sample.xml"
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new File(fileName));

2. Create XPATH query string like "/parent/child/grandchild'[@attribute = value]'"
for eg
String XpathQueryContexts = "/root/module[@display='" + moduleKey +
"']/subjectArea[@name='" + subjAreaKey +
"']/tab[@targettable='" + tabKey + "']/" +
"filter-contexts";

root is the parent node
subjectArea is the child node for root
tab is the child node for subjectArea
targettable is a property defined in the tab node

3. Get the nodes as a ArrayList for the given query condition at step 2
List lstContexts = XPath.selectNodes(jDomDocument, XpathQueryContexts);


More information available in
http://en.wikipedia.org/wiki/XPath