Re: Migrations: A result was returned when none was expected.
Re: Migrations: A result was returned when none was expected.
- Subject: Re: Migrations: A result was returned when none was expected.
- From: Miguel Torres <email@hidden>
- Date: Fri, 07 Sep 2012 15:41:45 -0500
Yeah,
In fact, I wouldn't could run the migration with the SELECT statement, using the ERXJDBCUtilities.executeUpdateScriptFromResourceNamed function.
Because it doesn't expect a result
Saludos.
Miguel Torres.
On 07/09/2012, at 15:27, Chuck Hill <email@hidden> wrote:
> 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@hidden> 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@hidden> 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@hidden)
>>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>>
>>>>>> This email sent to email@hidden
>>>>>
>>>>> --
>>>>> 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@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden