I think it is better like this than split into multiple migrations.  This is 
exactly that I meant.  It is one single change, so it should stay in one 
migration.

Chuck


On 2012-09-07, at 1:16 PM, Miguel Torres wrote:

> You are right.
> 
> This is the way I solved it.
> 
> 
> public class DInAdminEOModel17 implements IERXMigration { 
>          public NSArray<ERXModelVersion> modelDependencies() { 
>                    return null; 
>                  } 
> 
>          public void upgrade(EOEditingContext editingContext,
>                               EOAdaptorChannel channel, EOModel model) throws 
> Throwable {
>                       
> ERXJDBCUtilities.executeUpdateScriptFromResourceNamed(channel,
>                                       
> "Migrations/DInAdminEOModel17_Upgrade.sql", null);
>                       
>                       ERXJDBCUtilities.fetchRowSet(channel, "SELECT 
> inserta_empresa_pacs() ;");
>                       ERXJDBCUtilities.executeUpdate(channel, "DROP FUNCTION 
> inserta_empresa_pacs();");
>               }
> 
>               
> 
>               public void downgrade(EOEditingContext editingContext,
>                               EOAdaptorChannel channel, EOModel model) throws 
> Throwable {
>                       // whatever it takes to invert those
>               }
> }
> 
> 
> I guess it would be better to split it into several migrations but it is a 
> controlled change so it works for me.
> 
> Thanks.
> 
> Miguel Torres.
> 
> 
> 
> On 07/09/2012, at 12:50, Chuck Hill <[email protected]> wrote:
> 
>> 
>> On 2012-09-07, at 10:30 AM, Miguel Torres wrote:
>> 
>>> public class DInAdminEOModel17 implements IERXMigration { 
>>>        public NSArray<ERXModelVersion> modelDependencies() { 
>>>                  return null; 
>>>                } 
>>> 
>>>        public void upgrade(EOEditingContext editingContext,
>>>                             EOAdaptorChannel channel, EOModel model) throws 
>>> Throwable {
>>>                     
>>> ERXJDBCUtilities.executeUpdateScriptFromResourceNamed(channel,  
>>> "Migrations/DInAdminEOModel17_Upgrade.sql", null);
>> 
>> The update will not expect a result.  You probably need to split this into 
>> four steps and use executeSelect to run the procedure.
>> 
>> Chuck
>> 
>> 
>> 
>>>             }
>>> 
>>>             
>>> 
>>>             public void downgrade(EOEditingContext editingContext,
>>>                             EOAdaptorChannel channel, EOModel model) throws 
>>> Throwable {
>>>                     // whatever it takes to invert those
>>>             }
>>> }
>>> 
>>> 
>>> On 07/09/2012, at 12:20, Chuck Hill <[email protected]> wrote:
>>> 
>>>> How are you running this in Java?
>>>> 
>>>> 
>>>> On 2012-09-07, at 7:37 AM, Miguel Torres wrote:
>>>> 
>>>>> Hi List,
>>>>> 
>>>>> I am getting this error:
>>>>> 
>>>>> A result was returned when none was expected.
>>>>> 
>>>>> I am executing a migration that creates a new table and a new procedure 
>>>>> to insert some records to that table, because it has a reference to a 
>>>>> table that already exists and may have some records. At the end of the 
>>>>> migration, the procedure is dropped.
>>>>> 
>>>>> I am calling the procedure using a SELECT statement (Postgresql).
>>>>> 
>>>>> This is the content of my migration:
>>>>> 
>>>>> CREATE TABLE empresa_pacs (
>>>>> tf_habilitar character varying(5) NOT NULL,
>>>>> tf_modo character varying,
>>>>> tf_certificado character varying,
>>>>> tf_vencimiento_certificado date,
>>>>> tf_contrasena character varying,
>>>>> empresa_id integer PRIMARY KEY REFERENCES empresa ON DELETE CASCADE
>>>>> );
>>>>> 
>>>>> 
>>>>> CREATE FUNCTION inserta_empresa_pacs() RETURNS VOID
>>>>> AS 'DECLARE empresa_temp empresa%ROWTYPE;
>>>>>           BEGIN FOR empresa_temp IN SELECT * FROM empresa LOOP INSERT 
>>>>> INTO empresa_pacs(empresa_id, tf_habilitar) 
>>>>> VALUES(empresa_temp.empresa_id, ''false'');
>>>>>           END LOOP;
>>>>>           END;'
>>>>> LANGUAGE plpgsql;
>>>>> 
>>>>> SELECT inserta_empresa_pacs() ;
>>>>> 
>>>>> DROP FUNCTION inserta_empresa_pacs();
>>>>> 
>>>>> I understand the error's meaning, I am asking if there are any other way 
>>>>> to execute the migration to avoid the error.
>>>>> 
>>>>> Thanks in advance.
>>>>> 
>>>>> Miguel Torres.
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Webobjects-dev mailing list      ([email protected])
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>> https://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>>>>> 
>>>>> This email sent to [email protected]
>>>> 
>>>> -- 
>>>> Chuck Hill             Senior Consultant / VP Development
>>>> 
>>>> Practical WebObjects - for developers who want to increase their overall 
>>>> knowledge of WebObjects or who are trying to solve specific problems.    
>>>> http://www.global-village.net/gvc/practical_webobjects
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>> 
>> -- 
>> Chuck Hill             Senior Consultant / VP Development
>> 
>> Practical WebObjects - for developers who want to increase their overall 
>> knowledge of WebObjects or who are trying to solve specific problems.    
>> http://www.global-village.net/gvc/practical_webobjects
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 

-- 
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall 
knowledge of WebObjects or who are trying to solve specific problems.    
http://www.global-village.net/gvc/practical_webobjects









 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to