These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

What is Best Practice for Database Queries

tgoodman
Registered: Aug 18 2008
Posts: 72

Hi,

I've been looking at the Adobe examples for Database SQL queries that are called within scripts.

The Adobe examples (e.g. http://www.adobe.com/devnet/livecycle/designer_scripting_samples.php or http://www.adobe.com/devnet/livecycle/articles/lc_designer_db_lookup_tip.pdf)

Seem to use the following methods:

- Javascript to populate a multi-item values such as a dropdrown or Combobox
- FormCalc to execute a specific query with parameters.

My question is regarding the specific query ...

Is it best practice to use FormCalc, or is there a similarly usable method with Javascript ... Are there common examples of javascript?

My preference would be to use javascript always (not to mix and match with FormCalc), and to build a SQL query with input variables (e.g. "Select X from Table where TableID = " + inputVal + ";" )

If This is also possible with Javascript, then are there some good examples?

Thanks

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The whole JavaSript/FormCalc thing is a bit confusing. Both languages operate on the LiveCycle structure. Each using it's own syntax. The scripting structure of a LiveCycle document is a tree. At the top level there are several paths into different aspects of the XFA scripting model. These are called DOMs (Document Object Model). One of these (the xfa.sourceSet DOM) is for handling database connectivity. The path to a particular part of the DOM is call a SOM (Scripting Object Model). The SOM is the basic, or root, concept of LiveCycle programming. Every node along the path is a different kind of form element with it's own individual characteristics. Both FormCalc and JavaScript operate on these SOM path elements, but each does it using it's own syntax and structures.

So in a way it doesn't matter what language you use. They both have exactly the same capabilities when it comes to accessing the properties and functions of a particular node on a SOM path. However, each has it's own strenghts and weaknesses. Actually, FormCalc is pretty weak all around as a programming language. If you have anything the least bit complex to do program, use JavaScript. It's a much better programming language.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

tgoodman
Registered: Aug 18 2008
Posts: 72
Thanks Thom.

So Javascript is the best way - the examples are a bit misleading

I think it's making sense now - it looks like (using the Javascript API) the call is via the Statement.execute method, with statement being created from a Connection object...

Thanks,
Tim
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ahh, My previous discussion was about using "xfa.sourceSet" in a LiveCycle form. The ADBC object in Acrobat JavaScript is a different animal altogether. This object is an interface to an ODBC registered DB. I don't see any reason why you couldn't use it from a script in a LiveCycle document.

Whether you use the LiveCycle DB mechanisim or the ADBC object is largely a matter of what you are comfortable with and how you are using the data.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script