Mapping Database Tables
Some database functions are deprecated since version 6.4, including:
- DatabaseSelect
- DatabaseJoin
- DatabaseInsert
- DatabaseUpdate
There will be no further developments concerning these functions, and you are encouraged to use other functions.
The database support allows you to read and write from databases using a map. To use the database support, you must first import the database using the Import mechanism Talend Studio. This reads all of the tables of the database into a set of structures, one for each table. Each database structure has a loop (with an element called Row) that corresponds to each selected or written row.
inTo read from the database, use the structure corresponding to the table as the input structure of a map. If you are reading from multiple tables using a JoinHandling, you can create a new structure representing the joined tables using the New Structure wizard (select the create a database join table option). When creating the map you can specify a SQL select statement using a DatabaseSelect function. You can also useDatabaseJoin functions to specify conditions on joins as required. All database functions are placed in the IO/Database expression tab.
To write to a database, use a structure corresponding to the table as the output structure of a map. Use a DatabaseInsert or DatabseUpdate function as required.
You can import or read any number of database tables in a single map by creating an enclosing structure that inherits from the desired database table structures.
Database Lookup Functions are also provided to find and update values from database tables. To use these, import the database as described below, and then use the functions in your mapping expressions, specifying the required database and tables.