28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4. Create the table file.<br />

Browse to the folder in your project workspace where you want to create the new table file and perform the<br />

following tasks:<br />

a) Right-click the folder where you want to save the table file and choose New in the context-sensitive popup<br />

menu.<br />

b) Enter the name of the table in the File Name box and add the file suffix .hdbtable, for example,<br />

MYTABLE.hdbtable.<br />

c) Choose Finish to save the new table in the repository.<br />

5. Define the table.<br />

To edit the table file, in the Project Explorer view double-click the table file you created in the previous step, for<br />

example, MYTABLE.hdbtable, and add the table-definition code to the file:<br />

Note: The following code example is provided for illustration purposes only.<br />

table.schemaName = "MYSCHEMA";<br />

table.tableType = COLUMNSTORE;<br />

table.columns = [<br />

{name = "Col1"; sqlType = VARCHAR; nullable = false; length = 20;<br />

comment = "dummy comment";},<br />

{name = "Col2"; sqlType = INTEGER; nullable = false;},<br />

{name = "Col3"; sqlType = NVARCHAR; nullable = true; length = 20;<br />

defaultValue = "Defaultvalue";},<br />

{name = "Col4"; sqlType = DECIMAL; nullable = false; precision = 2;<br />

scale = 3;}];<br />

table.indexes = [<br />

{name = "MYINDEX1"; unique = true; indexColumns = ["Col2"];},<br />

{name = "MYINDEX2"; unique = true; indexColumns = ["Col1",<br />

"Col4"];}];<br />

table.primaryKey.pkcolumns = ["Col1", "Col2"];<br />

6. Save the table file.<br />

7. Commit the changes to the repository.<br />

a) Locate and right-click the new table file in the Project Explorer view.<br />

b) In the context-sensitive pop-up menu, choose Team Commit .<br />

5.5 Sequences<br />

A sequence is a database object that generates a serial list of unique numbers. You can use sequence definitions<br />

in mappings to generate unique numbers while transforming and moving data to your target system.<br />

<strong>SAP</strong> <strong>HANA</strong> Extended Application Services (<strong>SAP</strong> <strong>HANA</strong> XS) enables you to create a database sequence as a<br />

transportable design-time file in the repository. Repository files can be read by applications that you develop.<br />

You can use database sequences to perform the following operations:<br />

● Generate unique, primary key values<br />

● Coordinate keys across multiple rows or tables<br />

78<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Setting Up the Persistence Model

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!