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:Code snippets

Revision as of 16:17, 29 November 2011 by Unnamed Poltroon (Talk)

Code snippets for EDT

Real code for real people. Share your code snippets with others!

Rich UI

Services

Database access

Record definition

 record CUSTOMER type Entity{@table{name = "CUSTOMER"}}
     NAME string
     COUNTRY string{@id};
     STATE string?;
     CUSTID string;
 end

Get a record

 function getCust{id String in} returns (Customer)
     ds SQLDataSource?{@resource {}};
     aCust Customer;
     get aCust from ds using(id);
     return (aCust);
 end

Add a record

 function addCust{customer Customer in}
     ds SQLDataSource?{@resource {}};
     add customer to ds;
 end

Loop through a SQL result set

 function loopCust()
     ds SQLDataSource?{@resource{bindingkey = "MyDB"}};
     rs SQLResultSet?;
 
     open rs from ds with #sql{
	SELECT * FROM CUSTOMER
     };
 
     myCust Customer;
 
     //Loop through results and write out customer name
     while(rs.setNext())
        get myCust from rs;
        Syslib.writeStdOut (Customer name: " + myCust.name);
     end
 
 end


Share a code snippet

Login to eclipse.org and edit this page. Use the Wikitext to add a new snippet. Use the source lang="java" tag will provide a background for your snippet and provide some syntax highlighting.

Back to the top