Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EDT:Default SQL Generation

Revision as of 03:36, 22 December 2011 by Zhuzhi.cn.ibm.com (Talk | contribs)

         Quick Assist Support for Default SQL Generation

  EDT 0.7.0 release provides quick assist support for the following EGL action statements to 
generate default SQL statements:
 1 ADD Statement
 2 DELETE Statement
 3 GET Statement
 4 OPEN Statement
 5 REPLACE Statement

Use examples to show how to use the feature in EDT plugin.

EGL Record Definition:
    record Product{@Table {name="Product"}}
       id bigint{@Id};
     name string;
     price float;
  end


The above is a basic record definition, one must use annotation @Id to specific which record 
field is used as primary key, also can use annotation @Table to specify to which table the record 
is mapped, just as 'Product' definition shows, but this is optional.

record OrderItem type Entity{@table{name = "OrderItem"}}
   ITEM_ID int{@Id};
   NAME string{ @Column { insertable=true } };
   IMAGE string?{ @Column { updateable=true } };
   PRICE decimal(7, 2)?;
   DESCRIPTION string?;
end

The above is an entity record definition that is generated from a table schema.



EGL Variable Definition
   basicRec Product;    
   itemEntity OrderItem;
   rs SQLResultSet?;
   ds SQLDataSource? = new SQLDataSource("jdbc:derby:C:/databases/EGLDerbyR7;create=true");    


ADD Statement

   Click anywhere in the EGL statement and press CTRL+1, and press “Add SQL Statement” proposal, 
default SQL statement will be added to the above statement: 
       (1) add basicRec to ds; //for basic record 

Change To: 
       add basicRec to ds with 
           #sql{ insert into Product (id, name, price) values (?, ?, ?)}; 
    • GET Statement
  • OPEN Statement
  • REPLACE Statement



Back to the top