OC: I don’t know how far you’ve dug - but just in case I’ll throw this out. One of the keys to how all this works is ERXSQLHelper sqlHelper = ERXSQLHelper.newSQLHelper. This returns the vendor specific ERXSQLHelper for your database (Frontbase). DB specific code is there.
You might want to check the inner class: public static class FrontBaseSQLHelper extends ERXSQLHelper Just my 2¢, but instead of that large block of code, why not just change some properties, run migrations at app startup, and declare your changes there? Migrations work and you don’t have to reinvent the wheel. Then, if your SQL continues to be incorrect, you know where to focus. Tim Worman UCLA GSE&IS > On Jan 12, 2015, at 2:18 PM, OC <o...@ocs.cz> wrote: > > P.S. my current environment is > > Groovy 2.3.8 / WebObjects 5.4.3 / ERExtensions 6.1.2-SNAPSHOT / Java 1.7.0_13 > / Mac OS X 10.8.5 / FrontBase 7.2 > > On 12. 1. 2015, at 22:56, OC <o...@ocs.cz> wrote: > >> Theodore, >> >> On 12. 1. 2015, at 19:00, Theodore Petrosky <tedp...@yahoo.com> wrote: >>> have you looked at the migrations? >>> ERXMigrationTable personTable = database.existingTableNamed("person"); >>> personTable.existingColumnNamed("Foo").renameTo("Bar”); >>> personTable.newStringColumn(name, width, allowsNull) >> >> well... the API looks OK, but in practice it does not seem quite work. Can >> you (or anybody knowledgeable) please point out what am I doing wrong? >> Here's my code (sans error checking etc. for better readability) >> >> === >> EOObjectStoreCoordinator >> osc=EOObjectStoreCoordinator.defaultCoordinator() >> EODatabaseContext >> ctxt=ERXEOAccessUtilities.databaseContextForEntityNamed(osc,'DBAuction') >> ctxt.lock(); >> try { >> EOAdaptorChannel ach = ctxt.availableChannel().adaptorChannel(); >> if (!ach.isOpen()) ach.openChannel(); >> def tables=ach.describeTableNames() // looks like Migration API >> does not read the current state reliably >> EOModel dbModel=ach.describeModelWithTableNames(tables) >> ERXMigrationDatabase mdb=nil // created on-demand >> mdg.models.each { EOModel localModel -> >> localModel.entities.each { EOEntity localEntity -> >> if (localEntity.isAbstractEntity()) return >> String tname=localEntity.externalName() >> EOEntity dbEntity=dbModel.entityNamed(tname) >> ERXMigrationTable mtable=nil // on-demand >> localEntity.attributes.each { EOAttribute localAttribute -> >> String cname=localAttribute.columnName() >> EOAttribute dbAttribute=dbEntity.attributeNamed(cname) >> if (!dbAttribute) { >> println " adding column $cname >> ($localAttribute.name): $localAttribute.externalType (VT: >> $localAttribute.valueType) ..." >> if (!mdb) mdb=ERXMigrationDatabase.database(ach) >> if (!mtable) mtable=mdb.existingTableNamed(tname) >> switch (localAttribute.externalType) { >> ... >> case 'TIMESTAMP': >> mtable.newTimestampColumn(cname,YES) >> break >> } >> println " - OK" >> } >> } >> } >> } >> } finally { >> ctxt.unlock() >> } >> === >> >> but it crashes, printing out >> >> === >> adding column DC_ID (ID): TIMESTAMP (VT: null) ... >> 22:42:09.409 INFO Executing alter table T_AUCTION null DC_ID TIMESTAMP >> //log:er.extensions.jdbc.ERXJDBCUtilities [main] >> ... >> Caused by: java.lang.RuntimeException: Failed to execute 'alter table >> T_AUCTION null DC_ID TIMESTAMP'. >> Caused by: java.sql.SQLException: Syntax error 179. Illegal ALTER TABLE >> statement. >> === >> >> Well self-evidently it _is_ an illegal statement, it lacks "add column" >> having "null" instead; but what's the culprit and how to fix the problem? >> >> (Note: I've tried to bump up log levels to >> log4j.logger.er.extensions.jdbc.ERXJDBCUtilities=TRACE >> log4j.logger.er.extensions.migration.ERXMigrationDatabase=TRACE >> log4j.logger.er.extensions.migration.ERXMigrationTable=TRACE >> log4j.logger.er.extensions.migration.ERXMigrationColumn=TRACE >> but no more logs occurred anyway.) >> >> Thanks, >> OC >> >> >> _______________________________________________ >> Do not post admin requests to the list. They will be ignored. >> Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) >> Help/Unsubscribe/Update your Subscription: >> https://lists.apple.com/mailman/options/webobjects-dev/ocs%40ocs.cz >> >> This email sent to o...@ocs.cz > > > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/webobjects-dev/lists%40thetimmy.com > > This email sent to li...@thetimmy.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (Webobjects-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com