Walking Tree
What are the possible error one can assume with the statement
CONNECT BY prior loop error
for the code
SELECT manager_id, last_name, department_name
FROM EMPLOYEES
START WITH last_name='xyz'
CONNECT BY PRIOR EMPLOYEE_ID = MANAGER_ID;
Hi Neo
If you have an employee who is both someone's manager and is also managed by the same person, you will then have a "loop" in your data which can cause an ORA-01436 (ie. the person is both a child and a parent in the relationship). In which case, you need to specify the NOCYCLE option in your CONNECT BY clause ( CONNECT BY NOCYCLE PRIOR EMPLOYEE_ID - MANAGER_ID).
Cheers
Richard Foote
http://richardfoote.wordpress.com/
Similar Messages
-
N-ary Trees non-recursive traversal algorithms
Hi,
Non-recursive traversals are needed when you are unsure how big the tree's will be. So far all the algorithms I have seen either use their own internal stack
or threading to climb back up the tree.
Here's my attempt that seems to work but I would value so critical evaluation
* An extension of the CommonAST that records the line and column
* number. The idea was taken from <a target="_top"
* href="http://www.jguru.com/jguru/faq/view.jsp?EID=62654">Java Guru
* FAQ: How can I include line numbers in automatically generated
* ASTs?</a>.
* @author Oliver Burn
* @author lkuehne
* @version 1.0
* @see <a target="_top" href="http://www.antlr.org/">ANTLR Website</a>
public class DetailAST
public AST getFirstChild()
public AST getNextSibling()
public int getChildCount()
public DetailAST getParent()
public int getChildCount(int aType)
public String getText()
}This was cut back just to give you enough info
public static AST getLeftMostChild(DetailAST ast) {
DetailAST tempAst = ast.getFirstChild();
while (tempAst.getFirstChild() != null) {
tempAst = tempAst.getFirstChild();
return tempAst;
public static void traverseASTInOrder(DetailAST root) {
DetailAST current = getLeftMostChild(ast);
processNode(current);
while (current != root) {
if (current == current.getParent().getFirstChild()) {
processNode(current.getParent());
if (current.getNextSibling() != null) {
DetailAST sibling = current.getNextSibling();
if (sibling.getChildCount() != 0) {
current = (DetailAST) getLeftMostChild(sibling);
processNode(current);
} else {
current = sibling;
processNode(current);
} else {
current = current.getParent();
// do stuff at inorder traversal
public static void processNode(AST current) {
System.out.println(current.getText());
}for pre-order and post-order John Cowan put forward this algorithm
http://lists.xml.org/archives/xml-dev/199811/msg00050.html
traverse(Node node) {
Node currentNode = node;
while (currentNode != null) {
visit(currentNode); //pre order
// Move down to first child
Node nextNode = currentNode.getFirstChild();
if (nextNode != null) {
currentNode = nextNode;
continue;
// No child nodes, so walk tree
while (currentNode != null) {
revisit(currentNode) // post order
// Move to sibling if possible.
nextNode = currentNode.getNextSibling();
if (nextNode != null) {
currentNode = nextNode;
break;
// Move up
if (currentNode = node)
currentNode = null;
else
currentNode = currentNode.getParentNode();
}Any comments, criticisms or suggestions ?
regards
David ScurrahStack is recursion? As far as I know recursion is when
function (method) calls itself. Just using some
Collection, which java.util.Stack implements is not
recursion.
Regards
PawelStacks are used to implement recursive algorithms. What happens in most languages when you make a function call? Each function has an "activation record" where it stores its local variables and parameters. This activation record is usually allocated on a stack. Thus for any recursive algorithm, there is a non-recursive algorithm that uses a stack.
In the OP's case you don't need a stack because of the peculiarities of tree traversal when you have a pointer to the parent node. (Namely, no cycles and you can get back to where you've been) So the algorithms he gave should work fine.
My only "criticism" would be that it may be more useful to implement these algorithms with the iterator pattern. So you would have a tree with some functions like:
public class Tree{
public TreeIterator inOrderIteraror();
public TreeIterator preOrderIterator();
}Where the TreeIterator would look like a java.util.Iterator, except maybe you want some additional utility methods in there or something.
Other than that, non-recursive algorithms are defnitely the way to go. -
NIORBU.DLL won;t register under Windows 7 Ultimate
When I installed the base LabView 9 package, at the end I got an alert that windows\system32\niorbu.dll was not valid. Ran regsvr32 and stated that the dll was not supported by the O/S.
Any workarounds or hotfixes for this issue?Hi Mike and Ken,
Thanks, I see that you installed LabVIEW 2009 SP1, the Feb 2010 Device Drivers DVD, NI-DAQmx 9.0.2, and NI-DAQmx 9.1.1, then repaired the installation of NI-DAQmx 9.1.1. Does this PC have any National Instruments hardware devices installed? I didn't see any in the attached report file. If you have already installed the hardware device(s), what model is it? Does it show up in Windows Device Manager with an "X" or an exclamation point over its icon?
There are a couple of different conditions I know of that cause a "Bad Image" error. One is that NIORBU.dll is corrupted (i.e. it is not a valid DLL). Another is that a side-by-side assembly (a DLL installed into the WinSxS directory) is missing. I think the latter is unlikely because direct dependencies of the 32-bit version of NIORBU.dll are not side-by-side assemblies. You can check for both of these conditions by opening nidevmon.exe in a free utility called Dependency Walker. If a required DLL is corrupt, Dependency Walker will display it with an icon of a red circle + exclamation point and will display "No DOS or PE signature found." If a required DLL is missing, Dependency Walker will display it with an icon of a yellow circle + question mark. (Note: doing File >> Save As... to save the entire Dependency Walker tree is more helpful than taking a screenshot, because it includes information that you would have to scroll to get to.)
It may also be worthwhile to try disabling the virus scanner, just to rule it out. However, if the virus scanner was causing an installation problem, you would have to repair the installation (or even uninstall and reinstall) with the virus scanner disabled.
Brad
Brad Keryan
NI R&D -
in order to create parent-child relationships, we need to use two tables because some children can have two parents and all parents have more than one children.
this makes tree walking by using the "connect by prior" difficult. has anyone run into something similar and what is the solution?
tiaIf you try to run a hierarchical query, using START WITH,
CONNECTY BY, and PRIOR on a sub-query that contains a join
condition, or on a view that was created using a join condition,
you will get "ORA-01437: cannot have join with CONNECT BY". One
way to get around this problem is to create a new table from the
tables that need to be joined, then run the hierarchical query
on the new table.
For example, first create the new table:
CREATE TABLE new_table AS
SELECT old_table1.column_a, old_table2.column_b
FROM old_table1, old_table2
WHERE old_table1.column_c = old_table2.column_d;
or if you are doing a self-join:
CREATE TABLE new_table AS
SELECT x.column_a, y.column_b
FROM old_table1 x, old_table1 y
WHERE x.column_c = y.column_d;
Then, run the hierarchical query:
SELECT column_a, column_b
FROM new_table
START WITH column_a = 'whatever'
CONNECT BY PRIOR column_b = column_a;If you could post your table structure, some sample data, and a
sample of the desired result, some of us could probably provide
a more specific solution.
Having multiple parents should not create a problem unless the
relationship creates a loop, like if A is a parent of B and B is
a parent of C and C is a parent of A. -
"walking" through a tree in javascript. JDeveloper 11g tp3
Is there a way (or some sample code) for walking down a tree and seeing which rows are disclosed (or expanded); in general getting the TreeState() on the client side using javascript?
Thanks Larry
Message was edited by:
glmasonThanks Frank
Yes, I've read every bit of documentation that you have on the JavaScript API... there is a flaw with you short answer... The default selection mode is none and in our case the row selection is kept unenabled, we use a check box on the node instead for displaying choice, so where one could get a set of row keys from the selection listener... and the disclosure listener... there seems no way get a "complete" set of row keys from the tree. So if the program does not "know" the number of rows there is no way to check each row to see if it is an expanded path or not. And even if one could find the number of rows (which can be done in the RichTree java class), according to the documentation one can not just assume that RowKeys are going to be 0,1,etc... rather "explicit" row keys are needed because the system creates row keys by some magic.
Hence my question is there some way to get the tree state from the RichTree javascript object?
I would "love" it if you told me I was full of it and that if I wanted to know the state of a tree all I'd have to do is...
Larry -
Need to expand tree by passing treeId thr URL not by clicking manually.
Sub: Need to expand tree by passing Id thr URL.
Hi,
Here i have Library.java and ajaxTree.jsf files (collected from Jboss richfaces)
There is having a list of artist .
If u click on a particular artistname then the respective albums(with their checkboxes) will expand and show like a treenode.
just look at d url : "http://localhost:8080/richfaces-demo-3.2.1.GA/richfaces/tree.jsf?c=tree&albumIds=1001,1002,1005,1008,1009,1010&client=0"
I m passing album Ids and clientId in url browser and receiving in d Library.java.
I need to expand the required client tree to show albums without clicking on artistname rather by passing the clientId from Url.
I thnk one EventHandling class( PostbackPhaseListener.java ) is responsible for expanding but I m unable to understand.
How can I do it.
Plz help asap.
/###############ajaxTree.jsf##########Start##############/
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:c="http://java.sun.com/jstl/core">
<p>This tree uses "ajax" switch type, note that for collapse/expand operations it will be Ajax request to the server. You may see short delay in this case.</p>
<h:form>
<rich:tree style="width:300px" value="#{library.data}" var="item" nodeFace="#{item.type}">
<rich:treeNode type="artist" >
<h:outputText value="#{item.name}" />
</rich:treeNode>
<rich:treeNode type="album" >
<h:selectBooleanCheckbox value="#{item.selected}"/>
<h:outputText value="#{item.title}" />
</rich:treeNode>
</rich:tree>
<h:commandButton value="Update" />
</h:form>
</ui:composition>
/###############ajaxTree.jsf##########End##############/
/************************Library.java*********Start****************/
package org.richfaces.demo.tree;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import javax.servlet.http.HttpServletRequest;
import javax.faces.context.FacesContext;
import org.richfaces.model.TreeNode;
public class Library implements TreeNode {
private static final long serialVersionUID = -3530085227471752526L;
private Map artists = null;
private Object state1;
private Object state2;
private Map getArtists() {
if (this.artists==null) {
initData();
return this.artists;
public void addArtist(Artist artist) {
addChild(Long.toString(artist.getId()), artist);
public void addChild(Object identifier, TreeNode child) {
getArtists().put(identifier, child);
child.setParent(this);
public TreeNode getChild(Object id) {
return (TreeNode) getArtists().get(id);
public Iterator getChildren() {
return getArtists().entrySet().iterator();
public Object getData() {
return this;
public TreeNode getParent() {
return null;
public boolean isLeaf() {
return getArtists().isEmpty();
public void removeChild(Object id) {
getArtists().remove(id);
public void setData(Object data) {
public void setParent(TreeNode parent) {
public String getType() {
return "library";
private long nextId = 0;
private long getNextId() {
return nextId++;
private Map albumCache = new HashMap();
private Map artistCache = new HashMap();
private Artist getArtistByName(String name, Library library) {
Artist artist = (Artist)artistCache.get(name);
if (artist==null) {
artist = new Artist(getNextId());
artist.setName(name);
artistCache.put(name, artist);
library.addArtist(artist);
return artist;
private Album getAlbumByTitle(String title, Artist artist) {
Album album = (Album)albumCache.get(title);
if (album==null) {
album = new Album(getNextId());
album.setTitle(title);
albumCache.put(title, album);
artist.addAlbum(album);
return album;
private void initData() {
artists = new HashMap();
InputStream is = this.getClass().getClassLoader().getResourceAsStream("org/richfaces/demo/tree/data.txt");
ByteArrayOutputStream os = new ByteArrayOutputStream();
byte[] rb = new byte[1024];
int read;
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
// System.out.println("request.getParameter(param) "+request.getParameter("param"));
//System.out.println("request.getParameter(client) "+request.getParameter("client"));
//System.out.println("request.getParameter() "+request.getParameter("c"));
try {
do {
read = is.read(rb);
if (read>0) {
os.write(rb, 0, read);
} while (read>0);
String buf = os.toString();
StringTokenizer toc1 = new StringTokenizer(buf,"\n");
String str1 = request.getParameter("albumIds");
int clientId1 =Integer.parseInt( request.getParameter("client"));
while (toc1.hasMoreTokens()) {
String str = toc1.nextToken();
StringTokenizer toc2 = new StringTokenizer(str, "\t");
String artistName = toc2.nextToken();
String albumTitle = toc2.nextToken();
String songTitle = toc2.nextToken();
toc2.nextToken();
toc2.nextToken();
String albumYear = toc2.nextToken();
Artist artist = getArtistByName(artistName,this);
Album album = getAlbumByTitle(albumTitle, artist);
String portfolios[] = new String[100];
Integer portfoliosId[] = new Integer[100];
int i = 0;
StringTokenizer st = new StringTokenizer(str1, ",");
while (st.hasMoreTokens()) {
portfolios[i] = st.nextToken();
if((songTitle.equals(portfolios))&&(!(songTitle == ""))){
//System.out.println("ifff");
album.setSelected(true);
i++;
album.setYear(new Integer(albumYear));
} catch (IOException e) {
throw new RuntimeException(e);
public Object getState1() {
return state1;
public void setState1(Object state1) {
this.state1 = state1;
public Object getState2() {
return state2;
public void setState2(Object state2) {
this.state2 = state2;
public void walk(TreeNode node, List<TreeNode> appendTo, Class<? extends TreeNode> type) {
if (type.isInstance(node)){
appendTo.add(node);
Iterator<Map.Entry<Object, TreeNode>> iterator = node.getChildren();
System.out.println("walk node.getChildren() "+node.getChildren());
while(iterator.hasNext()) {
walk(iterator.next().getValue(), appendTo, type);
public ArrayList getLibraryAsList(){
ArrayList appendTo = new ArrayList();
System.out.println("getLibraryAsList appendTo "+appendTo);
walk(this, appendTo, Song.class);
return appendTo;
/************************Library.java*********End****************/
/************************PostbackPhaseListener.java*********Start****************/
package org.richfaces.treemodeladaptor;
import java.util.Map;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
public class PostbackPhaseListener implements PhaseListener {
public static final String POSTBACK_ATTRIBUTE_NAME = PostbackPhaseListener.class.getName();
public void afterPhase(PhaseEvent event) {
public void beforePhase(PhaseEvent event) {
FacesContext facesContext = event.getFacesContext();
Map requestMap = facesContext.getExternalContext().getRequestMap();
requestMap.put(POSTBACK_ATTRIBUTE_NAME, Boolean.TRUE);
public PhaseId getPhaseId() {
return PhaseId.APPLY_REQUEST_VALUES;
public static boolean isPostback() {
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null) {
ExternalContext externalContext = facesContext.getExternalContext();
if (externalContext != null) {
return Boolean.TRUE.equals(
externalContext.getRequestMap().get(POSTBACK_ATTRIBUTE_NAME));
return false;
/************************PostbackPhaseListener.java*********End****************/
Edited by: rajesh_forum on Sep 17, 2008 6:13 AM
Edited by: rajesh_forum on Sep 17, 2008 6:18 AMHi
Can somebody please look into this?
Thanks
Raj
Edited by: RajICWeb on Aug 9, 2009 4:38 AM -
How to get the tree index of a child node
Hi, I am loading a tree object from an XML source file (via
an XMLListCollection)
I can find the children on the currently selected node, like:
var children:XMLList =
XMLList(myTree.selectedItem).children();
for(var i:Number=0; i < children.length(); i++) {
trace("Child Found: " + children
.@caption);
But how can I determine the tree index for each of the
children? I would like to be able to grab and save the tree index
for each child, so that I can later just to do
"myTree.selectedIndex = (saved child index) (based on some form
action the user performs). I can't find any method of determining
what the tree index for a child is, other than walking down the
tree from the parent node and counting the number of nodes till I
hit each child. Is there a simple method?Tree is hierarchical, index is linear. I have never seen
anyone successfully use selectedIndex with Tree.
You best bet is to put an id on each node and use e4x
expression to find that node when you want.
Tracy -
Walk through all files in a folder and do this for all subfolders and...
... and their subfolders, etc. I mean I want to recursively walk through all subfolders of a folder and when I'm "in" in each folder I would like to walk through all files alphabetically of that folder.
While iterating through the files (of a certain type: .mp3, .mp4, .m4a) of that folder, I need to make a simple counter. e.g. when counter is 3 it means we are on the 3rd file alphabetically of the folder.
Then I simply want to set the track # mp3 tag of that file to this counter value (e.g. 3)
Anyone know how to do this? or at least to be able to show me the walking the folders and iterating the files bit? I'm brand new to applescript.
Why do I want to do this? Well I have a lot of live music shows, each in its own folder, but in my apple devices and itunes when I play a show it will not show the songs in the correct order. The file names are alphabetical in the correct order though and I suspect if I assign track #s then itunes, ipods and iphones will be able to play the "album" back in the order listed by track #??What are you using to play your items? iTunes can use various properties to sort a playlist, independent of what the file name is (Finder too, for that matter). If you are just wanting to add a prefix number to a file name, you would also probably need to use leading zeros to keep it in order when sorted by name.
The following is a general purpose handler to go through the items in a folder - I just put various text into the output list as an example.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run -- example
set TheFolders to (choose folder with multiple selections allowed)
choose from list (ProcessStuff from TheFolders)
end run
to ProcessStuff from SomeItems
process items contained in SomeItems, recursively descending the directory tree
parameters - SomeItems [list]: the items to process
returns [list]: a list of processed items
set FilesList to {} -- this will be a list of processed items
repeat with AnItem in SomeItems
set AnItem to AnItem as text -- get the contents
set FileInfo to (info for AnItem as alias) -- see Standard Additions
if (folder of FileInfo) and not (package folder of FileInfo) then -- a folder (not a package)
-- do something with the folder, if desired
set the end of FilesList to "folder " & AnItem
try -- sort and process contents, skipping any errors
tell application "Finder"
set SubItems to (get items of folder AnItem)
set SubItems to (sort SubItems by name) as alias list
end tell
set FilesList to FilesList & (ProcessStuff from SubItems)
end try
else -- a file
-- do something with the file, if desired
set the end of FilesList to tab & (name of FileInfo)
end if
end repeat
return FilesList
end ProcessStuff
</pre> -
I recently used the solution provided at https://support.mozilla.org/en-US/questions/927950?page=2#answer-364990 by KerriB. It worked. However, I still found traces of the bloatware in two other places. Not sure if I should remove them, or not. Suggestions? I've included images of the locations (slightly edited for security reasons).
One is in my startup programs. To access: Mouseover an open space on your desktop. Press the Windows key and the R key at the same time. A dialog box pops up. Type in msconfig. Choose the startup tab. This lists all the programs that are starting at startup. As you can see, VProtect Application and ROC_roc_ssl_v12 are listed as manufacturer unknown, but in the file tree, they are in C:\Program Files\AVG Secure Search.
The other location is accessed via Start, then choosing Computer, Local Disk (C:) (your local disk might be a different letter, obviously) , Program Files. As you can see, there exists an entire folder FILLED with AVG Secure Search items.
I do have an open support ticket with AVG on this matter, but it being the weekend, I may not hear back for a couple of days. I will let everyone know what they advise when I do hear back from them.
UPDATE:
I have complained to AVG, and they offered me a free license for their paid AVG Premium security 2012 edition ... o.O ... anyway, I wrote them back asking about the above left-overs and they responded by sending me a download for a special uninstaller (which you have to install - go irony!). I've included an image of that email (image3).
After running their uninstaller, I ran a system clean-up, and a deep cleaning run of Advanced Systemcare (my favorite cleanup utility), did a restart, then did a search for "AVG".
As you can see (image 4), I *STILL* had a folder full of AVG accessed by going to Start, Computer, C:\.
I did a secure shred delete (again, and Advanced Systemcare tool, but simply deleting probably would be fine) of this AVG folder. Again, I ran a system clean-up, and a deep cleaning run of Advanced Systemcare (my favorite cleanup utility), did a restart, then did a search for "AVG". This time, nothing came up. Great! right? NO. I wanted to be *SURE* it was ALL gone, so I opened Windows Defender (the included firewall that comes with Windows 7), expanded the menu on drives to scan, and low-and-behold, look, what do you know, a HIDDEN $AVG folder (image 5)!
Now I have to view all hidden folders to find it. That is done by going to Start, Control Panel, (change View By: to Small Icons), Folder Options, (popup window), View Tab, then check the selection dot beside "Show hidden files, folders, and drives", Apply, OK (see image 6 for the walk-through). Now go back to Start, Computer, C:\, and it should show the hidden $AVG folder. If that doesn't show it, you can also do a Search, and delete the folder from the Search results. AGAIN, I ran a system clean-up, and a deep cleaning run of Advanced Systemcare (my favorite cleanup utility), did a restart, then did a search for "AVG".
I now feel I am completely free of AVG. I hope this helps you get rid of it too!'''Attachments of images:'''
-
Hi, I would like to ask you how can I display my Tree? in JTree?
I create tree:
Folder fol = new Folder(folderName, numFiles);
DefaultMutableTreeNode treeNode = new DefaultMutableTreeNode(fol);
....But now I does not know how to display tree with folder names. When I use tree.setModel(...); it display object, but not folder names...
And how can I use red font color for folder names with 0 files(numFiles = 0)?Hi, I would like to ask you how can I display my
Tree? in JTree?
I create tree:
Folder fol = new Folder(folderName, numFiles);
DefaultMutableTreeNode treeNode = new
DefaultMutableTreeNode(fol);
....But now I does not know how to display tree with
folder names. When I use tree.setModel(...); it
display object, but not folder names...you need to walk through your tree and create a new DefaultMutableTreeNode for each of your nodes and add to its parent node of your JTree (remember there is a distinction between view and control). the user object of your DefaultMutable TreeNodes is the file/folder, which should be in its own class (see below) and overwrite toString() to return the name. then the JTree will show what you want.
>
And how can I use red font color for folder names
with 0 files(numFiles = 0)?you need a tree cell renderer. it gets your file/folder object (see above) as a parameter. you can query it about the number of files and set the foreground/background accordingly.
thomas -
Internal error in R-tree processing: [Recursive fetch error]
Hello,
I seem to be getting an error when using any type of SDO function (SDO_RELATE, SDO_FILTER, SDO_ NN, ... ) on my spatially indexed data. The error I'm getting is this:
ERROR at line 1:
ORA-29903: error in executing ODCIIndexFetch() routine
ORA-13236: internal error in R-tree processing: []
ORA-13236: internal error in R-tree processing: [Recursive fetch error]
The interesting part of this is that I only get this error if I insert more than 31 entries into the table. All the relevant code is posted below, what I do is create the table, then create the metadata from the sqlplus interface. After that I run a java program that does Clear() then Insert() then Create_Indices(). All these run just fine (at least run without telling me about any errors). But as soon as that is all done and I do an SDO query on the data, for example:
SELECT location stop_range_poly_area
FROM stops
WHERE SDO_FILTER
location,
SDO_GEOMETRY
2003, null, null,
SDO_ELEM_INFO_ARRAY(1,1003,1),
SDO_ORDINATE_ARRAY(300,300, 600,300, 600,600, 300,600, 300,300)
) = 'TRUE';
I get the above mentioned error. But if I change my data so that it doesn't have more than 31 entries (doesn't matter which 31 entries, just so long as it doesn't exceed that number) that query (and all of my other SDO test queries on the stops table) seems to work just fine.
Thanks for looking at this,
Brad
---- SQLPLUS Code -----------------------------------------------------------------------------------------------------------
CREATE TABLE stops
stop_id VARCHAR2(4) PRIMARY KEY,
address VARCHAR2(256),
location sdo_geometry
INSERT INTO user_sdo_geom_metadata VALUES
'stops',
'location',
MDSYS.SDO_DIM_ARRAY
MDSYS.SDO_DIM_ELEMENT('X', 0, 600, 0.005),
MDSYS.SDO_DIM_ELEMENT('Y', 0, 800, 0.005)
null
----- Java Code -----------------------------------------------------------------------------------------------------------------
// Clear
// Description:
// This function clears all the data in the stop tables in the database
// given in the connection.
public static void Clear (Connection connection)
Statement statement;
try
statement = connection.createStatement();
statement.executeUpdate("DROP INDEX stops_index");
statement.executeUpdate("DELETE stops");
statement.close();
catch (SQLException e)
System.err.println("SQLExcpetion (Stop.Clear()): " + e.getMessage());
// Create_Indices
// Description:
// Create indices for stops table
public static void Create_Indices (Connection connection)
Statement statement;
String sql_query;
sql_query = "CREATE INDEX stops_index ON stops(location) " +
"INDEXTYPE IS MDSYS.SPATIAL_INDEX";
try
statement = connection.createStatement();
statement.executeUpdate(sql_query);
statement.close();
catch (SQLException e)
System.err.println("SQLExcpetion (Stop.Create_Indices()): " + e.getMessage());
// Insert
// Description:
// This function inserts this object into the stops table in the database
// given in the connection.
public void Insert (Connection connection)
Statement statement;
String sql_query;
sql_query = "INSERT INTO stops VALUES ('" +
stop_id + "', '" +
address + "', " +
"sdo_geometry(2001, null, sdo_point_type(" +
location.x + "," +
location.y + ",null), null, null)" +
try
statement = connection.createStatement();
statement.executeUpdate(sql_query);
statement.close();
catch (SQLException e)
System.err.println("SQLException (Stop.Insert()):" + e.getMessage());
Message was edited by: loos to include the changes proposed by the second poster.Hi,
Thanks for trying but changing those items for the specific failing queries didn't seem to help. Though you do seem to be right about the internal/external polygon problem, so I changed it all my other queries to see if they would fail (that way things would at least be consistent), but it doesn't seem to make a difference. All my old failing quries still fail and my working ones still work. I also changed the co-ordinates as you specified and still have no changes (unless of course the results changed, but right now I'm just looking for queries that compile and run, the results don't matter yet).
Maybe this will help, I'll give you guys both sets of data, one that works and one that doesn't and maybe you can see a problem in the data that I'm just missing or too ignorant to see. The data is simply comma seperated values that I parse into the required fields in the order (id, description, x, y).
So far, the only reason I've been able to find that the non-working data doesn't work is because there are more than 31 rows. I started taking records out of the stops table in a binary search sort of pattern. If I take out stops 100-115 (resulting 29 records) all the queries work, if I take out stops 100-107 (resulting in 36 records) it doesn't work. If I take out 109-115 (resulting in 35 records) it doesn't work. If I take out 1-11 (resulting in 32 records) it doesn't work. If I take out 1-12 (resulting in 31 records) it does work. Here's a table
Take out Stops ---- records left -- Works?
s1-s11 ------------ 32 ------------ No
s1-s12 ------------ 31 ------------ Yes
s100-s115 --------- 29 ------------ Yes
s100-s107 --------- 36 ------------ No
s109-s115 --------- 35 ------------ No
Thanks again for checking this out,
Brad
------- Working Data ---------------------------------------------------------------------------------------
(Student_id, Department, x, y)
Student_1,Computer Science ,296,131
Student_2,Social Science,130 ,279
Student_3,Mechanical Engineering ,392,180
Student_4,Electrical Engineering ,342,322
Student_5,Computer Science ,165,490
Student_6,Scicology ,393,533
Student_7,Physical Therapy ,590,616
Student_8,Civil Engineering ,165,640
Student_9,English ,360,412
Student_10,Economy ,89,32
Student_11,Computer Science ,26,117
Student_12,Social Science,430 ,291
Student_13,Mechanical Engineering ,382,80
Student_14,Electrical Engineering ,542,222
Student_15,Computer Science ,154,290
Student_16,Scicology ,493,323
Student_17,Physical Therapy ,290,426
Student_18,Civil Engineering ,65,230
Student_19,English ,300,412
Student_20,Economy ,44,292
Student_21,Computer Science ,146,431
Student_22,Social Science,405 ,179
Student_23,Mechanical Engineering ,192,480
Student_24,Electrical Engineering ,412,202
Student_25,Computer Science ,265,49
Student_26,Scicology ,33,273
Student_27,Physical Therapy ,186,216
Student_28,Civil Engineering ,365,600
Student_29,English ,309,42
Student_30,Economy ,415,392
------- Non Working Data ---------------------------------------------------------------------------------
(Stop_id, Address, x, y)
s1, 2341 Portland,377,64
s2, 24th St. / Hoover St.,308,22
s3, 2620 Monmouth Ave.,272,138
s4, 2632 Ellendale Pl.,128,110
s5, 2726 Menlo Ave.,85,231
s6, 2758 Menlo Ave.,84,124
s7, 28th St. / Orchard Ave.,183,236
s8, 28th St. / University Ave.,414,308
s9, 30th St. / University Ave.,391,352
s11, 34th St. / McClintock St.,180,458
s12, 36th Pl. / Watt Way,176,622
s13, Adams Blvd. / Magnolia Ave.,218,87
s14, BG Mills Apts.,23,637
s15, Cardinal Gardens Apts.,156,389
s16, Centennial Apts.,373,126
s17, Chez Ronee Apts.,446,414
s18, City Park Apts.,70,323
s19, Dental School,219,478
s96, Founders Apts.,373,192
s97, Hillview Apts.,412,214
s98, House of Public Life,531,303
s99, JEP,304,523
s100, Kerchoff Apts.,473,272
s101, Leavey Library,370,559
s103, McClintock St. / Childs Way,129,553
s104, Mt. St. Marys College,565,127
s105, Pacific Apts.,398,240
s107, Parking Center,525,652
s109, Parkside,78,651
s110, Severance St. / Adams Blvd.,435,202
s111, Research Annex,492,776
s112, Sierra Apts.,352,230
s113, Sunset Apts.,267,278
s114, Terrace Apts.,156,280
s115, Troy East Apts.,402,397
s116, University Regents Apts.,182,181
s117, Watt Way / 36th Pl.,176,622
s119, Watt Way / Bloom Walk,158,653
s120, Windsor Apts.,257,236
s121, Zemeckis Center,476,474
s137, Gate #2,321,715
s138, 24th St. / Toberman St.,377,64 -
Building tree using view crateria in view objects
suppose that i have the following tables "class" ,"group" and "item".
items in table "item" belong to groups in table "group" and groups belong to classes in table "class" .
suppose there is another table called "selling_basket" that contains an id for the customer and also a foreign key for rows in item table for the items he sold and a "Customer" table that contains customers id and other informations.
suppose that i want to build an JSF page that contains a table from a view based on the "customer" table and a tree of herarichy - class
|_group1
|_item1
|_item2
-class2
|_group2
|_item3
|_group3
and when i click on a row on table customer the tree only display the herarichy for items that this customer sold just.i solve the probel the description as follow :
. the problem : the problem is that when we use the tree model component with the scenario of filtration on the child nodes, we do a normal transactions of steps on the knowledge that the tree will use the master detail behavior as in table component and other ADF Master-details behaviors, so we build two view criteria one on employee and the other on department with the scenario of displaying only the department who has employees with salary equal some certain value, and only shows the employees who has salary equal that value, and on our code we apply the two criteria on the two view objects with the same value we entered to search for , the scenario works well for the top level nodes, but for child nodes it seems it doesn’t work, the behavior make us walk around our selves for why this happened. By debugging options and Tracing what SQL statements that it executes we found that the system execute two statements on the employee view object one with the bind value with the same we inserted and the other with null value, and we notice that the name of the second view object executed is not what we apply the view criteria for(departmentEO_employeeEO_emo_dept_FK_employeeView).
.The solution: we notice that the tree component doesn’t use master detail behavior as in tables, and instead of that it uses the View link assessors (the run time generated view object departmentEO_employeeEO_emo_dept_FK_employeeView ), to get the detailed items, so we should override the action of the View link assessor.
To deal with that we generate the view object rowimpl and viewimpl java classes, in the rowimpl class there is a method to call the link assessors with the following code:
public RowIterator getEmployeesView()
this.getAttributeInternal(EMPLOYEESVIEW);
We write our code:
public RowIterator getEmployeesView()
System.out.println("Here");
ViewObject s=((DepartmentsViewImpl)this.getViewObject()).getViewLinks()[0].getDestination();//we get the employee object by using the view link
// between department and employee
// then we apply the view criteria to that view object and return it as view link
System.out.println("row number "+s.getEstimatedRowCount());
ViewCriteria evc=s.getViewCriteriaManager().getViewCriteria("EmployeesViewCriteria");
s.ensureVariableManager().setVariableValue("nSal",((DepartmentsViewImpl)this.getViewObject()).getnSal());
s.applyViewCriteria(evc);
s.executeQuery();
return s;
Notice that we use the employee view object getted by the view link instead of the master details.
Regards
Mohammad.b.yaseen
Sep 26 2011 @ 11:43
J2EE Team
RealSoft
for more info this the application url :
http://www.4shared.com/file/lgeaYWXa/TreeTestApplication1.html
notice that i diidn't attach the database with the project so you can connect to the local db
Edited by: mohammad.j.b.yaseen on Sep 26, 2011 12:13 PM -
Implementation of a parse tree in Java (Urgent)
How best can a parse tree be implemented in java, i have read some online information that suggest use of data structures, but i am still not clear on how to do it.
Well, you need a tree. A logical way to structure a tree is out of "node" objects. A node presumeably will hold some data, and may also have one or more subnodes.
So the root of your effort ought to go into designing the node - data it will hold, and getters and setters, and operations to walk the tree. -
Namespace, IXpathFunction "tree" return
I am trying to implement an IXpathFunction component. My Java runs fine but I am having trouble getting the data back into my BPEL process in a usable way.
So far I have 3 User Defined Functions. 2 of them I can read from just fine but one of them is giving me fits.
My returns for these are:
String (base64 encoded binary actually... but that's just a big string)
tree -- <caseNumber resultString=" " status=" " messageOut=" "/>
When I check the flow trace I see this in the update:
<caseNumberEdit xmlns="http://xmlns.oracle.com/f17userDefinedFunctions" resultString="011-4563457" status="0" messageOut="Success"/>
tree -- <sortList xmlns:f17="http://entp.hud.gov/f17UserDefinedFunctions"><f17:sortedCollection><f17:item></f17:item></f17:sortedCollection></sortList>
When I check the flow trace I see this i the update:
<sortedCollection xmlns="http://xmlns.oracle.com/f17userDefinedFunctions"><item xmlns="">134</item><item xmlns="">34555</item><item xmlns="">35345</item><item xmlns="">555134</item></sortedCollection>
So.... What's the deal? My Java program doesn't send that text: it sends:
<sortList xmlns:f17="http://xmlns.oracle.com/f17userDefinedFunctions">
<sortedCollection>
<f17:item>134<f17:item>
<f17:item>34555</f17:item>
<f17:item>35345</f17:item>
<f17:item>555134</f17:item>
</f17:sortedCollection>
</sortList>
I create a variable based on "sortedCollection" and use the following statement to run my function and move the data to that variable:
(I have already moved data to each element in "$sortBuffer" prior to this copy statement)
<copy ignoreMissingFromData="yes" bpelx:insertMissingToData="yes">
<from>oraext:parseEscapedXML(f17:sortList(ora:getContentAsString($sortBuffer)))</from>
<to>$sortBuffer</to>
</copy>
I can see that my Java class read the input and did its job (sorted the items numerically) and that the sorted data was returned but even though $sortBuffer
has been populated I can't read the data. Each of the nodes defined in the schema evaluate as empty.
Here is the schema for these objects:
<?xml version="1.0" encoding="windows-1252" ?>
<schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:f17="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xmlns.oracle.com/f17userDefinedFunctions"
elementFormDefault="qualified">
<f17:element name="caseNumberEdit" >
<f17:complexType>
<f17:attribute name="resultString" type="f17:string"/>
<f17:attribute name="status" type="f17:int"/>
<f17:attribute name="messageOut" type="f17:string"/>
</f17:complexType>
</f17:element>
<f17:element name="sortedCollection" >
<f17:complexType>
<f17:sequence>
<f17:element name="sortlist">
<f17:complexType>
<f17:sequence>
<f17:element name="item" type="string" minOccurs="0" maxOccurs="unbounded"/>
</f17:sequence>
</f17:complexType>
</f17:element>
</f17:sequence>
</f17:complexType>
</f17:element>
</schema>Yes sure.
I have a plsql region which calls a procedure and in that procedure I have a cursor which selects values from a table with a hierarchical structure (self referencing). At the moment I pass in a start value and generate the values in the cursor using a tree walk.
What I would like to do is present my hierarchical structure in tree report on screen and then somehow pass the values displayed on the screen into my procedure.
I could write my own tree report that is based on a collection and every time a node is opened I would update the collection with the child node values etc. I could then use the collection in my plsql procedure. However, producing a tree report by hand will be a bit of work, so I was wondering what was available out of the box, or if someone had already done it.
I hope this clear and please don’t ask me to reproduce it on apex.oracle.com :-)
Shunt -
Hi,
I want to create an xml code from a java tree. I'm reading the tree data from DB and have a class named Node. For each node, setting data of Node class object.Is there anyone knows how to handle this.
P.S: I just need a converter that converts the tree in the DB to XMLCreate a tree walker that generates SAX events appropriate to the data in the Node.
Pass those events to something else (an XMLWriter http://www.megginson.com/Software/ to generate text directly, or a SAXSource to transform it to DOM or text), to generate the XML.
Eg:import javax.xml.transform.*;
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamResult;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.XMLFilterImpl;
import java.util.*;
// dummy Node class
class Node {
final String name;
final List children = new ArrayList();
Node (String name) { this.name = name; }
Node append (Node child) { children.add(child); return this; }
class NodeWalker extends XMLFilterImpl {
// root of tree to walk
final Node root;
public NodeWalker (Node root) {
this.root = root;
public void parse (InputSource input) throws SAXException {
startDocument();
try {
visit(root);
} finally {
endDocument();
// recursively visit the node and its children
void visit (Node node) throws SAXException {
AttributesImpl attributes = new AttributesImpl();
attributes.addAttribute("", "name", "name", "CDATA", node.name);
startElement("", "node", "node", attributes);
for (Iterator childIt = node.children.iterator(); childIt.hasNext(); ) {
visit((Node)childIt.next());
endElement("", "node", "node");
public class NodeWalkerTest {
static Node node (String name) { return new Node(name); }
public static void main (String[] args) {
try {
// set up some nodes
final Node root = node("root").
append(node("one")).
append(node("two").
append(node("alpha")).append(node("beta")).
append(node("gamma")).append(node("delta"))).
append(node("three"));
// transform them to a stream result,
final TransformerFactory factory = TransformerFactory.newInstance();
final Transformer nullTransform = factory.newTransformer();
nullTransform.transform(new SAXSource(
// SAX source created using node walker and default input source
new NodeWalker(root), new InputSource()),
new StreamResult(System.out));
} catch (Exception ex) {
ex.printStackTrace(System.out);
}Pete
Maybe you are looking for
-
I meant my app store
-
ITunes 10.2.1 Update has created 2 iTunes libraries
Have just updated to 10.2.1 and on checking finder there is an iTunes folder with all the music etc and another folder (iTunes new) which also has all the music etc. The folders are not identical as they are of different sizes but their structures ar
-
Opinion on High Definition Camera?
I'm thinking about upgrading from Digital8 to HD. What should I be looking for when editing with Final Cut? Additionally, how much hard drive space does an hour of HD video take? Thanks for your advice
-
Hello, When I use Disk Utility to verify Disk Permissions on Macintosh HD, I get about 1,500 lines displayed like Permissions differ on "Applications/iTunes.app/Contents/Resources/Dutch.lproj/AACEncoderConfig.nib"; should be drwxr-xr-x ; they are -rw
-
Hi All, I'm using ADDRESS and ENDADDRESS command to display vendor address in my Sapscript. I would like to know how to add text (eg: To) before display the address out? Kindly see below format layout I would like to print out. To: <Address Line 1>