Access database dynamically, when db was not connected at compile-time

D.Cook

Member
Is it possible to compile a procedure without any reference to a database, then at run-time dynamically access a database?
I thought about creating a dynamic query, but even that needs a buffer set before I can run the query. As far as I can tell, I can't define a buffer without referring to a table name in the code..
 

RealHeavyDude

Well-Known Member
There is a big difference between dynamic and static queries and objects related to it:

  • Static objects get resolved at compile time - therefore there will be database references compiled into the .r file.
  • Dynamic objects get resolved at run time - therefore there won't be any database references compiled into the .r file. You can check this yourself in evaluating the DB-REFERENCES attribute on the RCODE-INFO system handle.
You should not confuse static object for which you grab the handle with dynamic objects. Although, the funny thing is, in memory they are the same.


Heavy Regards, RealHeavyDude.
 

D.Cook

Member
Thanks guys, seems I didn't read the doc properly and didn't realise table-name can be a character expression.
Now I'm past that hurdle I can compile my procedure independent of being connected to any database!
 

tamhas

ProgressTalk.com Sponsor
See the adjacent thread about connecting to a database. Dynamic queries will only help with a DB that is already connected.
 
Top