Forum OpenACS Q&A: .xql file

Collapse
Posted by Luis Garcia on
Hi,
I would like to know why every time we create a query in a TCL file we have to create an .xql file with that same query...I know...I know I have to finish reading the documentation :)
Thanks!
Luis
Collapse
2: Re: .xql file (response to 1)
Posted by Robert Locke on
You don't *have* to create .xql files.  Being the lazy bastard that I am, I often don't create *.xql files at all and place my SQL queries directly in the db_* calls.

However, if you wish to release your package for public consumption or if you want it to be part of the official OACS distribution, then you should probably remove them from the *.tcl files and move all your queries to the appropriate *.xql files.  This makes it easier and cleaner to support multiple databases.

And if you have a bunch of queries embedded in *.tcl files, you can use the Query Extractor to help you with the tedious process of, well, extracting the queries.

Collapse
3: Re: .xql file (response to 1)
Posted by Don Baccus on
I'll make the statement more strongly - packages we release will have the queries separated out in query files because we're interested in supporting both Oracle and PG as "equal citizens."

And this requires customizing a considerable number of queries, though the number will shrink as future versions of Oracle and PostgreSQL gravitate towards supporting the SQL 99 standard.

We decided early on we'd rather put all queries in query files rather than attempt to pick-and-chose those that need customization.  One reason for that decision was to make it easier to port to a third database.  At the time there was a lot of interest in InterBase as an alternative to PostgreSQL, though InterBase now appears to be going no where fast (or slow, for that matter.)

But as Robert says - if you're writing a custom package for your own use that doesn't need to support both Oracle and PostgreSQL, isn't generalized and won't be part of a standard suite or packages or part of our contrib suite of code, then there's absolutely nothing wrong with writing your queries inline.  It's easier and more convenient to do so, the value of extracting them to query files lies only in simplifying the porting process to various RDBMS back ends.

Collapse
4: Re: .xql file (response to 1)
Posted by Gabriel Ricard on
In calling queries from .xql files in the Tcl code, what is the proper way to call that query?