Hi Kapil, try this function var g=orient.getGraph(); var b=g.command('sql','select from Nodex') for(i=0;i<b.length;i++){ var id=b[i].getProperty("id"); var rid=b[i].getId().toString() + ""; var sql2="create edge hasParent from " + rid + " to ( select from Nodex where parent_id = '" + id + "')"; g.command('sql',sql2); }
Bye, Alessandro Il giorno venerdì 29 maggio 2015 09:12:37 UTC+2, Kapil Ranade ha scritto: > > I have imported hierarchical data into OrientDB from RDMBS using OETL. > > In RDBMS we used to store parentId in the same row. e.g. the table > structure is something like this: > > ID - Name - Parent_ID > > Corp - Corporate Office - Corp > > D1 - District Office 1 - Corp > > D2 - District Office 2 - Corp > > SO1 - Small Office 1 - D1 > > SO2 - Small Office 2 - D2 > > SO3 - Small Office 3 - D1 > > Now each row is a node in orientdb. I want to create an edge (ParentOf) > from say Corp to D1 and D1 to SO1 and so on. > > How can I write a query to achieve this? Something along the line of > following? > > create edge parentOf from (select from node)a to (select from node where > a.id = parent_id) > > > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.