What is the different when we change the "Execute in new LUW" property in a procedure from False to True - procedure

I want to ask about this new property in procedure, can anyone give me an example of this property. I've read the information on the GeneXus wiki but I don't understand.

When it is set to Execute in new LUW, another connection to the database is opened and a new DBMS transaction is started in the database. You can commit and rollback on that object (or the ones called by it) and it won't affect the rest of your process.
It is used to perform commits in other tables and without losing the transactional integrity in the main process.

Related

Stored Procedure Failing to Insert to a Table, No Errors Given

Im working on an azure database just adding a couple of Stored Procedures and just making sure the program I'm building with it in .NET is all aligned properly.
I'm not going to go into the Stored Procedure itself nor the Program I'm developing because I don't believe the problem is there, I have a Development program and database which is using the exact same code and they work fine, I'm using Microsoft's SQL Server Management Studio to handle everything on the servers side.
The only difference to the current setup is that I myself scripted a bunch of the Stored procedures and a single View of a table that I did not create....(I did not create the table, but I made a view for it which is a slightly different format)
The person creating most of these databases and table is one of the database administrators I guess (not Microsoft, but an employee of the company using their services), I on the other hand am a freelance programmer and I'm guessing I have somewhat limited access to the server (limited credentials).....although it's allowing me to do more or less anything I need to do like creating SP's etc.
My current (and only problem) is a single stored procedure that runs through without an error does not update the table (the table i did not create) the Stored Procedure just inserts a couple of records and then deletes a record from the same table.......
It deletes the record just fine but for some reason the INSERT doesn't insert anything.
Again, this works fine on another Development database and the programs are sending the exact same strings but this new database just doesn't want to play along.....
Could this be a permission problem I'm having between my stored procedure and the table I did not create?
I would love to dump this onto the admin guy (and already did but he dumped it back on me haha) so I just want to be sure I'm not wasting his time....... and give him something solid to go on.
Thanks for your help Paul S.

How to manually manage Neo4j locks in Spring managed transaction

First of all I will explain why I would like to manually set write locks. I use Neo4j database in my web service application based on Spring Data Neo4j. Transactions are managed by Spring, I just use #Transactional annotation. However, I have problem with specific use case which leads to database inconsistency. I have a method that is transactional and its aim is to make such nodes/relation in database:
(p:Person)-[:USES]->(s:SIM_Card{phoneNumber:"xxx"})
Its algorithm is as follows:
-check if there is a SIM_Card with specific phone number (unique) already in the database (cypher query through #Query),
-if yes get this node and if no create it,
-check if there is any Person attached to this SIM_Card with USES relation (cypher query),
-if there is no such Person create it and attach to SIM_Card.
Unfortunately when there are many requests it happens that I have in database SIM_Cards that are attached to more than one Person. I assume that method is executed by two concurrent threads. Both read database and search for SIM_Card with the same phone number, and both get the information that there is no such SIM_Card in database yet, so they create them, and then they attach two separate Person to them. PhoneNuber is unique for SIM_Card, so eventually there is only one SIM_Card, but two Person remains and it is not expected situation.
To fix this I would like to create SIM_Card in separate Transaction and then create Person and attach to this SIM_Card in another transaction. Before the Person is created I will check if there is no Person already attached. However, just before that check I would like to set a write lock manually on SIM_Card and I assume that then other Transaction would not be able to check in meantime if there is/or not any Person connected to this SIM_Card. It would have to wait for the lock to be released and then it will see that this SIM_Card has Person attached and would not create another one.
To achieve that I have to get somehow ability to set Neo4j locks inside #Transactional annotated method and I do not know how to do that. I would really appreciate your help.
I think you have to give up #Transactional in this case, wire GraphDatabaseService instance into your repository (or service), and start the transaction and acquire the write lock manually (http://neo4j.com/docs/stable/javadocs/org/neo4j/graphdb/Transaction.html#acquireWriteLock(org.neo4j.graphdb.PropertyContainer)

Using an existing neo4j graph database for quering instead of creating a new database (same) everytime

I have created a graph database from a pile of 30k xml files. I want to reuse this graph database for querying it. Currently, I create the graph database every time I have to query something from it. Since the data set is huge, the database creation takes approx. 40 min. I am not aware of the way of reusing the existing database instead of creating it every time. I would appreciate your help if you could tell me how to do this.
(Java language, IDE-> IntelliJ, Redhat Linux).
I am new in this, but I saw there is a Delete database method in several code. Perhaps this is your case. Try commenting out the delete database method o delete ir, and only use start and shutdown.
I am trying to know how use a database without start and shutdown each time Java code run, perhaps with api REST. I have no answer yet, but I am still searching.
First you should make sure your import logic and your query logic are not on the same code, and you can call on without the other.
The database you create is stored in a directory.
If you're on server mode, it is specified on the config file : neo4j-server.properties (look for org.neo4j.server.database.location).
If you're on embedded mode, you declare the path of the database to the graph factory:
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( PATH/TO/NEO.DB );
What do you mean by reusing? If you want to use the database from more than one client at the same time, use Neo4j Server and REST, see http://docs.neo4j.org/chunked/snapshot/rest-api.html and point the server to your database directory in conf/neo4j-server.properties.
Also, you can point a new instance of Neo4j to the same database directory and that way open the database you created (exclusively), see https://github.com/neo4j/neo4j/blob/master/community/embedded-examples/src/main/java/org/neo4j/examples/EmbeddedNeo4j.java#L35
Is that covering your usecase?
/peter
I just had the same problem, which resulted from sloppy copy pasting of the code snippets from the Neo4j documentation. Each time I ran the code, all previously created nodes were deleted.
Apart from deleting the removeData-method (as mentioned by Jose) you should also remove the following line in the createDb()-method to prevent this:
FileUtils.deleteRecursively( new File( DB_PATH ) );
Maybe this still helps anyone, even though the topic is old.

Component published property as array of TQuery

i'm developing a custom component, and i'd like to add a published property that would be an array of TQuery (it should be visible in the object inspector). the main feature would be to drop the component on a form and then visually select the queries that are present on the same form, or on any other project form.
is that doable? from what i've seen till now, you can only programatically use such an array property...
UPDATE
first, thanks for your answer Alex!
second, the chatch is that i have to modify an old app someone else created, so i want to tangle with it as little as possible (actually there's a second app i need to "fix" which i was told is twice as big). now for the details: the app has abou 15 forms for various db operations. as you can imagine each form has 2-3 TQuery objects. the problem is that the user must authenticate with the db in order to execute the queries, thus he knows the db user & pwd which is a security flow.
in order to avoid this, an intermediate system has been introduced. one connects & authenticates with it and requests the necessary db data: user, pwd, and database name. my job is to use this system and autologin to the db. the necessary credentials to access this intermediate system are not considered a security flow so i'll read them from an inifile that depends on the environment where it's deployed: test, pre-production, production.
so i placed a TDatabase component on my form, setting its LoginPrompt property to FALSE. the tricky part however is adjusting each TQuery to the diferent database name for each environment before execution..
dunno if i made myself clear but it's the simplest explaination i managed to come up with
thanks,
G
To make life as simple as possible, you may have to grin and bear it once:
Create a datamodule and make sure it gets instantiated before the main form.
Put your TDatabase component on that data module.
Go through all your forms once and
add the database's data module to its uses clause (can be in implementation section).
Change all your TQuery and other database related components once to use the database component from the data module instead of having their own connection strings.
At run time, login as you described via your TDatabase component et voila, all your components will now use these settings automagically (as they are all connected to your TDatabase instance).
Okay, you've added a TDatabase to your project. Now, fill the "DatabaseName" property of TDatabase with some random name. Every TQuery component in your project also has a "DatabaseName" property and fill in the same name in those properties! Now your database and all it's queries will be connected and you could use the TDatabase object to access them all.
Yes, it can be done but you will have to write your own Property editor with it's own input form to manage the data inside the array. There's plenty of information to be found online. And yes, you could create a component that checks for controls on it's parent, allowing you to access those.
But is it practical? Why do you need an array of TQuery components in design time? Maybe you need to rethink your design first, so you're absolutely sure that you need this functionality. (Besides, what's wrong with using a Data Module to contain your queries?)

Tracking or Notifying DB Changes - Inserts and Updates mostly

How do I track or get notified whenever a record is inserted or updated in a DB? I would like to notify an external application of the changes in near real time whenever such changes in DB occur. Are there DBMS independent and application programming language independent ways of doing this? If not, then is it possible with MS Access and MS SQL Server in particular? I'm looking to avoid continuous polling of DB of course.
With SQL Server it is possible to load a DLL within SQL Server itself and call methods from this with extended stored procedures. The DLL could then notify other applications - usually via a TCP socket.
I think the latest version of Microsoft SQL Server allows you to raise events in your .NET code based on server conditions and events. I haven't tried it, and I haven't heard of any 'DBMS independent' way of doing this (without polling DB every X milliseconds).
With MS-Access, I keep track of record changes or record additions with fields in the main table that store the user name and date when the record is created or updated.
You need to use a windows API to record the user name, usually run when switchboard form is opened.
I am digging to find a away to track specific changes. My data base is used for project management. I would like to keep track of what specifically was changed, not just who and when that I have now.
I think this meets the requirements of the original question. I can later add the windows API that reads the name of the user.
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!UserCreated = UCase(CurrentUser())
Me!DateCreated = Now()
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!DateModified = Now()
Me!UserModified = UCase(CurrentUser())
End Sub
-- Mike
To do this with SQL Server, you use the Notification Service - write a dll that subscribes to notifications from the DB for data updates which you can process in some way.
However, MS has said that they are removing this from SQL Server 2008.
Oracle has something similar (though they tend to leave their technology in place), but I've not seen anything that is database-neutral.

Resources