Sie sind auf Seite 1von 8

SQL Transformation

You can pass the database connection information to the SQL transformation as input data at run time. The transformation processes external SQL scripts or SQL queries that you create in an SQL editor. The SQL transformation processes the query and returns rows and database errors. When you create an SQL transformation, you configure the following options Mode:-The SQL transformation runs in one of the following modes Script mode. The SQL transformation runs !"S# SQL scripts that are externally located. You pass a script name to the transformation with each input row. The SQL transformation outputs one row for each input row. Query mode. The SQL transformation executes a query that you define in a query editor. You can pass strings or parameters to the query to define dynamic queries or change the selection parameters. You can output multiple rows when the query has a S$L$%T statement. Passive or active transformation. The SQL transformation is an acti&e transformation by default. You can configure it as a passi&e transformation when you create the transformation. Database type. The type of database the SQL transformation connects to. Connection type. 'ass database connection information to the SQL transformation or use a connection ob(ect. Script Mode !n SQL transformation running in script mode runs SQL scripts from text files. You pass each script file name from the source to the SQL transformation Script "ame port. The script file name contains the complete path to the script file. When you configure the transformation to run in script mode, you create a passi&e transformation. The transformation returns one row for each input row. The output row contains results of the query and any database error. Rules and Guidelines for Script Mode )se the following rules and guidelines for an SQL transformation that runs in script mode You can use a static or dynamic database connection with script mode. To include multiple query statements in a script, you can separate them with a semicolon. You can use mapping &ariables or parameters in the script file name. The script code page defaults to the locale of the operating system. You can change the locale of the script.

The script file must be accessible by the #ntegration Ser&ice. The #ntegration Ser&ice must ha&e read permissions on the directory that contains the script. The #ntegration Ser&ice ignores the output of any S$L$%T statement you include in the SQL script. The SQL transformation in script mode does not output more than one row of data for each input row. You cannot use scripting languages such as *racle 'L+SQL or ,icrosoft+Sybase T-SQL in the script. You cannot use nested scripts where the SQL script calls another SQL script. ! script cannot accept run-time arguments. Query Mode When you configure the SQL transformation to run in query mode, you create an acti&e transformation. When an SQL transformation runs in query mode, it executes an SQL query that you define in the transformation. You pass strings or parameters to the query from the transformation input ports to change the query statement or the query data. You can create the following types of SQL queries in the SQL transformation Static SQL uery. The query statement does not change, but you can use query parameters to change the data. The #ntegration Ser&ice prepares the query once and runs the query for all input rows. Dynamic SQL uery. You can change the query statements and the data. The #ntegration Ser&ice prepares a query for each input row. Rules and Guidelines for Query Mode )se the following rules and guidelines when you configure the SQL transformation to run in query mode The number and the order of the output ports must match the number and order of the fields in the query S$L$%T clause. The nati&e data type of an output port in the transformation must match the data type of the corresponding column in the database. The #ntegration Ser&ice generates a row error when the data types do not match. When the SQL query contains an #"S$.T, )'/!T$, or /$L$T$ clause, the transformation returns data to the SQL $rror port, the pass-through ports, and the "um .ows !ffected port when it is enabled. #f you add output ports the ports recei&e ")LL data &alues. When the SQL query contains a S$L$%T statement and the transformation has a pass-through port, the transformation returns data to the pass-through port whether or not the query returns database data. The SQL transformation returns a row with ")LL data in the output ports.

You cannot add the 01output0 suffix to output port names that you create. You cannot use the pass-through port to return data from a S$L$%T query. When the number of output ports is more than the number of columns in the S$L$%T clause, the extra ports recei&e a ")LL &alue. When the number of output ports is less than the number of columns in the S$L$%T clause, the #ntegration Ser&ice generates a row error. You can use string substitution instead of parameter binding in a query. 2owe&er, the input ports must be string data types. SQL !ransformation Properties !fter you create the SQL transformation, you can define ports and set attributes in the following transformation tabs Ports. /isplays the transformation ports and attributes that you create on the SQL 'orts tab. Properties. SQL transformation general properties. SQL Settin"s. !ttributes unique to the SQL transformation. SQL Ports. SQL transformation ports and attributes. #ote: You cannot update the columns on the 'orts tab. When you define ports on the SQL 'orts tab, they display on the 'orts tab. Properties !ab %onfigure the SQL transformation general properties on the 'roperties tab. Some transformation properties do not apply to the SQL transformation or are not configurable. The following table describes the SQL transformation properties

Property Run !ime Location

Description $nter a path relati&e to the #ntegration Ser&ice node that runs the SQL transformation session. #f this property is blan3, the #ntegration Ser&ice uses the en&ironment &ariable defined on the #ntegration Ser&ice node to locate the /LL or shared library. You must copy all /LLs or shared libraries to the run-time location or to

the en&ironment &ariable defined on the #ntegration Ser&ice node. The #ntegration Ser&ice fails to load the procedure when it cannot locate the /LL, shared library, or a referenced file. !racin" Level Sets the amount of detail included in the session log when you run a session containing this transformation. When you configure the SQL transformation tracing le&el to 4erbose /ata, the #ntegration Ser&ice writes each SQL query it prepares to the session log.

$s Partition able ,ultiple partitions in a pipeline can use this transformation. )se the following options - #o. The transformation cannot be partitioned. The transformation and other transformations in the same pipeline are limited to one partition. You might choose "o if the transformation processes all the input data together, such as data cleansing. - Locally. The transformation can be partitioned, but the #ntegration Ser&ice must run all partitions in the pipeline on the same

node. %hoose Locally when different partitions of the transformation must share ob(ects in memory. - %cross Grid. The transformation can be partitioned, and the #ntegration Ser&ice can distribute each partition to different nodes. /efault is "o. &pdate Strate"y The transformation defines the update strategy for output rows. You can enable this property for query mode SQL transformations. /efault is disabled. !ransformation The method in which the Scope #ntegration Ser&ice applies the transformation logic to incoming data. )se the following options - .ow - Transaction - !ll #nput Set transaction scope to transaction when you use transaction control in static query mode. /efault is .ow for script mode transformations./efault is !ll #nput for query mode transformations. 'utput is Repeatable #ndicates if the order of the output data is consistent between session runs. - "e&er. The order of the

output data is inconsistent between session runs. - 5ased *n #nput *rder. The output order is consistent between session runs when the input data order is consistent between session runs. - !lways. The order of the output data is consistent between session runs e&en if the order of the input data is inconsistent between session runs. /efault is "e&er. Generate !ransaction The transformation generates transaction rows. $nable this property for query mode SQL transformations that commit data in an SQL query. /efault is disabled.

Re uires Sin"le #ndicates if the !(read Per #ntegration Ser&ice Partition processes each partition of a procedure with one thread. 'utput is Deterministic The transformation generate consistent output data between session runs. $nable this property to perform reco&ery on sessions that use this transformation. /efault is enabled.

Create Mappin" :

Step ): %reating a flat file and importing the source from the flat file. %reate a "otepad and in it create a table by name bi3es with three columns and three records in it. %reate one more notepad and name it as path for the bi3es. #nside the "otepad (ust type in 6% 7bi3es.txt8 and sa&e it. #mport the source 6second notepad8 using the source-9import from the file. !fter which we are goanna get a wi:ard with three subsequent windows and follow the on screen instructions to complete the process of importing the source.

Step *: #mporting the target and applying the transformation. #n the same way as specified abo&e go to the targets-9import from file and select an empty notepad under the name targetforbi3es 6this is one more blan3 notepad which we should create and sa&e under the abo&e specified name in the % 78. %reate two columns in the target table under the name report and error. We are all set here. "ow apply the SQL transformation. #n the first window when you apply the SQL transformation we should select the script mode. %onnect the SQ to the Script"ame under inputs and connect the other two fields to the output correspondingly. Snapshot for the abo&e discussed things is gi&en below.

Step +: /esign the wor3 flow and run it.

%reate the tas3 and the wor3 flow using the naming con&entions. ;o to the mappings tab and clic3 on the Source on the left hand pane to specify the path for the output file.

Step ,: 're&iew the output data on the target table.

Das könnte Ihnen auch gefallen