Вопрос

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.

Это было полезно?

Решение 3

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
}

Другие советы

A late followup to a good answer: if you have a unidata programmer on staff, it may be better to make a call to a subroutine where you just pass parameters to get what you need. Sort of like calling a stored procedure in other languages. It's not a requirement at all, but it can be a good approach of you have a java programmer and a unidata/pick programmer working together on a project...

If you are going to need to access the Unidata database from Java on a regular basis, there is a product from Rocket (the owners of Unidata) called "UniObjects for Java" which comprises a class library to access Unidata, including logging in, performing queries and calling BASIC subroutines. Most developers I have worked with who need to do this use this product.

https://docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/unidata/previous%20versions/v7.2/unidata_uniobjectsjavadevguide_v72.pdf

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top