NO SQL,ORIENTDB - orientdb

I have already inserted record in OrientDB using insert query. But I forgot to save it. Now I wanted that query in OrientDB.Is there any ways to get that query back?
I am using OrientDB. I wrote the insert statement to insert the data in the class(table). Now I want all the insert statement querys back in OrientDB itself.
I want to reinsert the data using same query.
The query will be in the following format.
Insert into TABLE name()values();
I wrote some 100 queries using insert statement. But I lost all. Is it possible take the back up of all the queries I wrote so far in OrientDB.

If you have logged yor queries in OrientDB log, you can try to get by there. When you run a query by studio, you have a history run queries. If you have deleted the history or clean the log, you can't retrieve them

Related

Why can't we view deleted table in SQL Server

What is meant by a "logical table?" i.e. Deleted and Inserted. That is, why can't we do something like:
Delete
From exampletable
Select *
From deleted
In the same session and see the results from the deleted table?
You probably search for OUPUT clause:
Delete From exampletable
OUTPUT deleted.*
The DELETED and INSERTED tables are created by the SQL engine to handle the data manipulation in your data manipulation statement. Think of them as being similar to a temp table that you would create in a stored procedure to hold interim results.
Once your DML statement has completed, SQL Server doesn't need them anymore, so it "drops" the "temp tables" and they aren't there to query any longer. You can, though, access them using the OUTPUT clause in your DML statement, as #LucaszSzozda explains, because at that point, the engine hasn't dropped them yet.

postgres db trigger to log query type into another table

This problem scenario may sounds strange but I am trying to write a trigger to log the query type into another table and so far i havent been able to find anything on google
the database i am using is postgres
i.e.
if i have two tables; table1 and querylog(has a string field called querytype)
and a select query is executed on table1, i want to insert a row into the query log table with the querytype field populated with "select"
anyone have any idea how to reference the query type in a function that will be called by a trigger?
Triggers do not get called for SELECT queries, so that won't work.
If you want to audit queries, you can use the PostgreSQL log file or tools like pgaudit that hook into PostgreSQL to retrieve and log the information.

PostgreSQL insert query succeeds but then row nowhere to be found

I am at a complete loss. I perform queries to my data table with an application very rapidly and they seem to be there. However, I have tried to perform a few inserts by hand and although I do not get any errors when I try to select my last insert I cannot find it.
postges 9.3. Any thoughts?

JPA - insert into select - copy large amount of records

I would like to copy records with diffrent key values. what is the best way to do so ?
In plain sql I would do:
insert into tableX values (x1,x2,x3,x4,x5) select 2,T1.x2,T1.x3,T1.x4,T1.x5 from tableX T1
(x1 is my primary key).
I tried writing this code inside the entity #NamedQuery, but i got org.eclipse.persistence.exceptions.JPQLException and after searching a way to write it i understand that this sql cannot be wriitten inside NamedQuery - is that correct?
I also tried looping through the object list representing tableX and for every object I did em.find() or created a new object and then inserted it with em.persist - but it seems to be an inefficient way. (when using find I do a select for each object , so if i have a list of 2000 records, it dosent make sense to create 2000 selectes and then insert with new key value).
So my question is what is the best way to implement copying all the records?
also if I got an exception, or something went wrong I would like to rollback so that I wont have only part of the records inside my database table.
Thanks In Advance.
You can use any SQL in JPA through a native query. SQL would be best for this type of insert.
If you need to do anything in Java on the data before inserting it, then you would query the objects, then insert them. Enable batch writing to improve efficiency.
http://java-persistence-performance.blogspot.com/2013/05/batch-writing-and-dynamic-vs.html

Insert data from staging table into multiple, related tables?

I'm working on an application that imports data from Access to SQL Server 2008. Currently, I'm using a stored procedure to import the data individually by record. I can't go with a bulk insert or anything like that because the data is inserted into two related tables...I have a bunch of fields that go into the Account table (first name, last name, etc.) and three fields that will each have a record in an Insurance table, linked back to the Account table by the auto-incrementing AccountID that's selected with SCOPE_IDENTITY in the stored procedure.
Performance isn't very good due to the number of round trips to the database from the application. For this and some other reasons I'm planning to instead use a staging table and import the data from there. Reading up on my options for approaching this, a cursor that executes the same insert stored procedure on the data in the staging table would make sense. However it appears that cursors are evil incarnate and should be avoided.
Is there any way to insert data into one table, retrieve the auto-generated IDs, then insert data for the same records into another table using the corresponding ID, in a set-based operation? Or is a cursor my only option here?
Look at the OUTPUT clause. You should be able to add it to your INSERT statement to do what you want.
BTW, if you need to output columns into the second table that weren't inserted into the first one, then use MERGE instead of INSERT (as suggested in the comment to the original question) as its OUTPUT clause supports referencing other columns from the source table(s). Otherwise, keeping it with an INSERT is more straightforward, and it does give you access to the inserted identity column.
I'm having experiment to worked out in inserting multiple record into related table using databinding. So, try this!
Hopefully this is very helpful. Follow this link How to insert record into related tables. for more information.