Creating tables/Fields in DB programatically from ABL

Posted by Akioma on 16-May-2013 13:48

Hi,

what is the best way to create tables/fields from the ABL?

I assume one could use the dictionary programs, but that code looks terrible and cumbersome to implement.

is there some kind of OO API available for this tasks in 11.2, similar to the one for maintaining tenant stuff?

regards,

Mike

All Replies

Posted by Stefan Drissen on 16-May-2013 14:20

Not that I am aware of.

Easiest path is probably to create an incremental df file and then:

RUN prodict/load_df.p ( cdfdir + cdf_name ).

Depending on your configuration (AppServers, WebSpeed agents, others) you may have a hard time getting a schema lock.

To be able to execute the above your 'client' needs to be able to compile code or be started with the -rx option. If not we disconnect the connected databases and spawn a copy of the current session with -rx added to the command line.

battling with the editor to get code marked as code

Posted by Thomas Mercer-Hursh on 16-May-2013 14:21

I suspect the easiest is to programmatically create the .df file and then run the dictionary programs to load it.

Posted by Håvard Danielsen on 16-May-2013 14:31

The DataAdmin API is currently targeted at multi-tenant related operations and does not support direct creation of tables, fields or indexes.The API does support load of .df files.

Posted by Admin on 16-May-2013 14:36

The API does support load of .df files.

The API is available from OE11 on - right? Is there documentation available? I mean outside the code, which accidentally has one or two comments but not much more.

Posted by Admin on 16-May-2013 14:40

And speaking of the data admin API's.

I recently logged Bug OE00236179 which relates to the DataAdmin tool, but is actually reproducible when using the Data Admin API. When setting a list of security administrators for one DB, then selecting a different working DB (DICT-DB) and then trying to change the security administrators for the second DB you end up setting them for the first one. That seems to be a bug in the data admin API.

Is it tested, that the load DF functionality in the data admin API's work when swtiching the working DB, aka DICT-DB?


Posted by Håvard Danielsen on 16-May-2013 15:14

The API was introduced in version 11 and is documented in the Programming Interfaces document. http://documentation.progress.com/output/OpenEdge112/pdfs/dvpin/dvpin.pdf

The interfaces are mostly well documented.

Posted by Admin on 16-May-2013 15:21

The API was introduced in version 11 and is ducumented in the Programming Interfaces document.

That's good to know!

 

The interfaces are mostly well documented.

Must have looked at the wrong source then.

Posted by gus on 16-May-2013 15:30

Yes. For now, this is the best way to create table definitions from 4GL code. Use of this (long-standing) API is supported.

The new API that was introduced with v11 is used by the database administration console (aka DBAC) part of OpenEdge Explorer and OpenEdge Management under the covers.

It doesn't do everything. But it is documented and supported. More functionality will be added to it in future releases.

Posted by Håvard Danielsen on 16-May-2013 16:55

mikefe wrote:

And speaking of the data admin API's.

I recently logged Bug OE00236179 which relates to the DataAdmin tool, but is actually reproducible when using the Data Admin API. When setting a list of security administrators for one DB, then selecting a different working DB (DICT-DB) and then trying to change the security administrators for the second DB you end up setting them for the first one. That seems to be a bug in the data admin API

The utility and the API is using the same code, so they may very well expose the same bug, but the DataAdminService is supposed to work against the database provided through the constructor, so you should use a new service for a different database. If you actually used two services against different databases, and they both updated the same database then this would be a bug in the API.

Posted by Admin on 16-May-2013 17:26

The latter is the case and the fix is scheduled for 11.3

Posted by Akioma on 18-May-2013 03:06

I did some tests creating  a .df file and then using the DataAdmin API to apply it to the DB. That worked fine, so we will go that way.

Is there any documentation available on the .df format? Especially the meaning of the "position" and "order" options are somewhat unlear to me.

Thanks to everybody for all the useful tips!

Mike

Posted by Admin on 18-May-2013 03:21

Another option:

https://code.google.com/p/pct/wiki/PCTLoadSchema

Posted by Håvard Danielsen on 20-May-2013 10:25

Is it tested, that the load DF functionality in the data admin API's work when swtiching the working DB, aka DICT-DB? 

The load df is not affected by the OE002369179 issue and works as expected with multiple services.

Posted by asthomas on 20-May-2013 10:26

I am out of the office until May 21st 2013. I will not be checking my mail and phone on a regular basis, but will reply to your mail as soon as I can.

If you need support from appSolutions, please send your mails to support@app-solutions.com.

If you need Roundtable support, please send mails to :

support-europe@roundtable-tsms.com.

Jeg er væk fra kontoret indtil den 21. maj 2013, og checker ikke mail og telefon regelmæssigt. Jeg vil dog svare på din mail så snart som muligt.

Hvis du har behov for support, kontakt venligst support@app-solutions.com, så vender vi tilbage så snart det er muligt.

Administrative henvendelser kan ske til : admin@app-solutions.com.

Med venlig hilsen / Regards

Thomas Hansen

appSolutions a/s

Posted by Håvard Danielsen on 20-May-2013 12:08

I wrote

The API does support load of .df files.

The main purpose of adding this to the API is to give access to new partitions created as part of the load (see documentation). The API version of Load .df is using the same internal code as the old prodict/load_df.p and provides a few improvements also for non-multi-tenant cases.

1. Uses current ABL error handling mechanism instead of inline message boxes wherever an error is encountered.

routine-level on error undo, throw.

service = new DataAdminService("mydb").
service:LoadSchemaChanges("mychanges.df").

catch e as Error:
    
end catch.

2.  The DataAdminService:GetSchemaChanges can be used to check the .df without applying.  

Posted by Admin on 20-May-2013 13:26

The load df is not affected by the OE002369179 issue and works as expected with multiple services.

Thanks for testing that!

This thread is closed