I am totally new to Unidata. I am trying to write a Java application that can query records from Unidata. I downloaded U2 Clients package and installed UniDK. I followed this example. I was able to get a single record by key/ID from the file in Unidata using the libraries in asjava.zip.
I came across the U2 Clients documentation which suggests about using JPA. I am wondering if there is any other options that I can write database query to get list of records with WHERE condition without implementing JPA. I am looking for something similar with using Php to write MySQL query.
Thanks.
Yes you can. First you will want to learn a little bit about 'UniQuery', which is the UniData database's query langauge. You can find that in the manuals on the Rocket Software site.
As an example, let's say you have a file called customers
and fields called name
and `age1
SELECT customers WITH name LIKE "Dan..." AND age GT "20"
This select statement will generate a list of record IDs that have a name
starting with Dan and have an age
greater than 20.
In your code, you will need to execute the SELECT statement first. Assuming udSess
is the session you created:
UniCommand cmd = udSess.command(); // Create an object to run the command
cmd.setCommand("SELECT customers WITH name LIKE 'Dan...' AND age GT '20'")
cmd.exec()
UniSelectList sl = udSess.selectList(0);
while (!sl.isLastRecordRead())
{
UniString recordID = sl.next();
// Read your record here, using recordID
}