Is there a way to make a copy of an arbitrary OrientDB record without its edges? I modified an original command (from the docs) for copying records and added fetchplan to it, but it does not work (frankly speaking to me it looks like there's a problem parsing this particular command, but hopefully im wrong)
This one executes fine, but edges remain:
insert into Test from select from Test where #rid=#102:119 fetchplan in_*:-2 out_*:-2
This one gives an error:
insert into Test from (select from Test where #rid=#102:119 fetchplan in_*:-2 out_*:-2)
com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.(SELECT FROM Test WHERE #rid = #102:119 FETCHPLAN in_*:-2 out_*:-2)
also tried smth like
insert into Test content (select #this.toJSON('fetchPlan:in_*:-2 out_*:-2') from Test where #rid=#102:119)
but that doesn't work either. Any thoughts? I'm on Orient 2.1.x
As workaround you can use this javascript function with one parameter (id)
var g=orient.getGraph();
var b=g.command("sql","select #this.toJSON('fetchPlan:in_*:-2 out_*:-2') as json from "+ id);
if(b.length>0){
var query="insert into Test content " + b[0].getProperty("json") ;
var myVertex=g.command("sql",query);
g.commit();
return myVertex;
}
Using the following command
select expand(result) from (select yourFunction(#102:119) as result)
Here's how to select all vertices (V) that have no incoming or outgoing edges:
select from (select #this, bothE().size() as n from V) where n = 0
I tried your query and I have the same problem.
I solved it in this way:
insert into Test from select <property-name> from Test where #rid=#102:119
If you want use it with fatchplan try this:
insert into Test from select <property-name> from Test where #rid=#102:119 fetchplan in_*:-2 out_*:-2
Hope it helps.
Regards,
Michela
Related
I have this python3 code :
conn = psycopg2.connect( ... )
curr = conn.cursor()
curr.execute(code)
rows = curr.fetchall()
where 'code' has the select query statement
After executing this, 'rows' list will have lists of only the selected row values. How do I run 'curr.execute' in such a way that I also get the respective col headers too?
Meaning if I have say
Select col1, col2 from table Where some_condition;
I want my 'rows' list to have something like [['col1', 'col2'], [some_val_for_col1, some_val_for_col2] ....]. Any other ways of getting these col headers are also fine, but the select query in 'code' shouldn't change.
you have to execute 2 commands
curr.execute("Select * FROM people LIMIT 0")
colnames = [desc[0] for desc in curs.description]
curr.execute(code)
you can follow steps mentioned in https://kb.objectrocket.com/postgresql/get-the-column-names-from-a-postgresql-table-with-the-psycopg2-python-adapter-756
I would like to do a subselect in order to do the following postgresql query with the querybuilder:
SELECT i.* FROM internship i
WHERE EXISTS (SELECT iw.*
FROM internship_weeks iw
WHERE i.id = iw.internship)
Does anyone have an idea how to get the same result with queryBuilder? or maybe with DQL?
Thanks for the help !
As example, only for demonstrate HOW-TO use a subquery select statement inside a select statement, suppose we what to find all user that not yet have compile the address (no records exists in the address table):
// get an ExpressionBuilder instance, so that you
$expr = $this->_em->getExpressionBuilder();
// create a subquery
$sub = $this->_em->createQueryBuilder()
->select('iw')
->from(IntershipWeek::class, 'iw')
->where('i.id = iw.intership');
$qb = $this->_em->createQueryBuilder()
->select('i')
->from(Intership::class, 'u')
->where($expr->exists($sub->getDQL()));
return $qb->getQuery()->getResult();
Hope this help
I have a vertex as below.
And I also have an edge (it is an out edge of above vertex) as below.
I can query with following SQL statements.
select from #20:6 where outE().weight in 1
select from #28:12 where sessionStatus.keys() in "session1"
However when I combined the 2 filters above, there is no vertex out from the query.
select from #20:6 where outE().sessionStatus.keys() in "session1"
Is there anyone guide me the correct filter I can use?
you can use MATCH
select expand(vv) from (
MATCH
{
class: GW_Score,
as: vv,
where: (#rid=20:6)
}
.outE(){
as: ee,
where: (sessionStatus.keys() = "session1")
}
RETURN vv
)
Try with this query:
select from #20:6 where ["session1"] in outE()[0].sessionStatus.keys()
Hope it helps.
I've got a query:
SELECT < column names >
INTO <#temp_table>
FROM < table >
WHERE < stuff >
It runs fine in dbVisualizer. However, running it in Oracle SQL Developer gives me the error "The executeQuery method must return a result set."
What is happening here, and how can I fix it in SQL Developer?
EDIT: In response to Tanner, I get the errors when I try the following things (tell me if something I try is invalid. I'm new to SQL):
This:
select * into #temp_table from status
produces this:
The executeQuery method must return a result set.
This:
select * into #temp_table from status;
select * from #temp_table;
produces this:
Invalid object name '#temp_table'.
And this:
select *
from(
select * into #temp_table from status)
produces this:
Incorrect syntax near the keyword 'into'.
I'm lost, ladies and gentledudes.
If you have a query like:
SELECT *
INTO #TEMP
FROM TABLE_A
That is simply creating and inserting data into a temp table.
What you need to do is return that temp table, so after you have run that code you need to do this:
SELECT *
FROM #TEMP
I work with postgreSQL
I want to update email of all my users using sql
I have a table named user that contains 500 users,
so I think that I should use a loop in my sql syntax
For example when the table contains 4 users, I want the email for these users to become :
user1#hotmail.fr
user2#hotmail.fr
user3#hotmail.fr
user4#hotmail.fr
in java it should be like this
String newValue=null;
for(int i=0;i<list.size();i++)
{
newValue="user"+i+"#hotmail.fr";
// make update
}
I think that I should use plsql syntax
updated :
I try without success with this code :
BEGIN
FOR r IN SELECT * from user_
LOOP
NEXT r;
UPDATE user_ SET emailaddress = CONCAT('user',r,'#hotmail.fr')
END LOOP;
END
I solved the problem using this query :
UPDATE user_ SET emailaddress='user' || col_serial || '#hotmail.fr' FROM
(SELECT emailaddress, row_number() OVER ( ORDER BY createdate) AS col_serial FROM user_ ORDER BY createdate) AS t1
WHERE user_.emailaddress=t1.emailaddress