-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: sql formatter
PostPosted: Mon Dec 27, 2010 11:28 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
SchemaExport does not respect format from entered input.
Statements coming from <database-object><create> xml file are generated into database as a whole line. No way that they are perfectly formatted.

Statement entered:

Code:
<database-object>
    <create>   
<![CDATA[
create procedure
   GRP_CONSTRAINTS(inout p_es_administrador char(1),
                   inout p_version          bigint)
   comment 'Restricciones de Grupo'
   /**
   * Constraints DEFAULT y CHECK
   * Author: JMR
   **/
begin
   if(p_es_administrador is null) then
      set p_es_administrador = 'F';
   end if;
   if(p_VERSION is null) then
      set p_VERSION = 0;
   end if;
   if(p_ES_ADMINISTRADOR <> 'F'
      and p_ES_ADMINISTRADOR <> 'T') then
      signal sqlstate '45000'
      set message_text = 'ES_ADMINISTRADOR ha de ser "F" o "T"';
   end if;
   if(p_VERSION < 0) then
      signal sqlstate '45000'
      set message_text = 'La VERSION ha de ser mayor o igual a 0';
   end if;
end
]]>
    </create>
    <drop>
drop procedure if exists GRP_CONSTRAINTS
    </drop>
<dialect-scope name="org.hibernate.dialect.MySQL5InnoDBDialect" />
</database-object>


Exit from console looks like this:

Code:
create procedure GRP_CONSTRAINTS(inout p_es_administrador char(1), inout p_version bigint) comment 'Restricciones de Grupo' /** * Constraints DEFAULT y CHECK * Author: JMR **/ begin if(p_es_administrador is null) then set p_es_administrador = 'F'; end if; if(p_VERSION is null) then set p_VERSION = 0; end if; if(p_ES_ADMINISTRADOR <> 'F' and p_ES_ADMINISTRADOR <> 'T') then signal sqlstate '45000' set message_text = 'ES_ADMINISTRADOR ha de ser "F" o "T"'; end if; if(p_VERSION < 0) then signal sqlstate '45000' set message_text = 'La VERSION ha de ser mayor o igual a 0'; end if; end;


Any solution to this?

Best regards.


Top
 Profile  
 
 Post subject: Re: sql formatter
PostPosted: Wed Dec 29, 2010 8:30 am 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
I see that drop tag works as expected
This piece of code:

Code:
    <drop>
<![CDATA[
alter table USUARIO
   alter VERSION drop default
]]>
    </drop>


is generated as:

Code:
    alter table USUARIO alter VERSION
        drop default;


formatted as expected...

So, I see the problem is related to <create> method and works perfectly with <drop> treatment method...


Top
 Profile  
 
 Post subject: Re: sql formatter
PostPosted: Wed Dec 29, 2010 12:46 pm 
Beginner
Beginner

Joined: Sat Oct 09, 2004 2:35 pm
Posts: 43
Location: Tenerife
False alarm:

<drop> does not work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.