Lesson 1 - Generating a text file containing Table name and Primary key

<< >>

Navigation:  CodeStencil > Tutorials >

Lesson 1 - Generating a text file containing Table name and Primary key

 

The aim of this lesson is to show how you can use a Code Nanite to generate a series of text files named after the tables in your database schema.

 

1.Ensure you have some tables defined in your Database Schema. If you don't have any table you can use the Schema Importer to import an existing schema, or create some tables using the Schema Generator.

 

CS_clip0038

 

2.Add a new FOLDER node, and call it "temp". The files we want to generate are going to be created in this folder

3.Add a FILE node to this folder. See Adding Nodes.

 

4.Rename the label of the file node to "[%CS_TABLE%].txt".  

See [%CS_TABLE_LIST%] for more information on the features of this code nanite.

 

CS_clip0037

 

5.Add the following to the contents of the node using the Code Editor:

 

My Table Name is: [%CS_CURRENT_TABLE%]

My Primary Key is: [%CS_PRIMARY_KEY%]

 

CS_clip0036

 

6.Generate the code

 

You will see the files generated:

 

CS_clip0039

 

CS_clip0040

 

So what happened here?

 

My Table Name is: [%CS_CURRENT_TABLE%]

My Primary Key is: [%CS_PRIMARY_KEY%]