Thursday, 23 April 2015

Getting view names and definition of view in Netezza

To get list of all the views in Netezza use the below statement:


SELECT viewname FROM _v_view WHERE viewname NOT LIKE '\_%' AND UPPER(objtype) = 'VIEW' ORDER BY viewname;


To get the definition of a view in Netezza  use the below statement. 


SELECT definition FROM _v_view WHERE viewname = <VIEWNAME> AND UPPER(objtype) = 'VIEW';

To get the unique object id associate with the view in Netezza use the below statement:


SELECT objid FROM _v_view WHERE viewname = <VIEWNAME> AND UPPER(objtype) = 'VIEW';


General syntax to create views in Netezza is :

create view vendor_view as select vendor_id, vendor_name from vendor order by vendor_id;

To read about mat views check:


http://dwbitechguru.blogspot.ca/2014/12/what-is-materialized-mat-view-in.html 


Wednesday, 1 April 2015

Simple data conversion , string handling, testing conditions in Informatica expression transformation

Simple data conversion , string handling, conditions in Informatica expression transformation

Testing conditions in Informatica expression transformation use:

1) If condition in Informatica:

IIF(condition, true, false)

2) To test for null

ISNULL(<portname>)

When used along with IIF statement, it would look like:

IIF(ISNULL(NAME), '', NAME)

NAME is the port that you are testing to check if it is null. If null you are passing '' blank character otherwise you are sending the NAME as it is .

3) To test if the incoming port is a decimal or integer you can use the below functions:

IS_DECIMAL() or IS_INTEGER() or IsNumber()

For example:

IIF( Not IS_INTEGER(i_PRICE) OR ISNULL(i_PRICE),'Invalid Price', '')

4) To check length of a port which is of string data type :

IIF(LENGTH(i_NAME) > 0, i_NAME, '')


String Handling in Informatica expression transformation use:

1) To search for a string in a port and get the position of the string you can use INSTR Function. SUBSTR function can be used to used to
extract part of string>

substr(NAME,1,INSTR(NAME,'-',1)-1)

In the above example, everything upto - is extracted from the incoming port NAME.

2) To concat strings from multiple ports use || funcation. For example:

i_port1 || i_port2

3) REPLACESTR function can be replace characters in a string; For example, char(10), chr(13) are replaced with '' blanks in the port NAME.

IIF(isnull(NAME),' ', REPLACESTR (1, NAME,CHR(10),CHR(13), ''))

In the below example, - are removed from date ID and then converted to integer:

TO_INTEGER(REPLACECHR(FALSE, v_DATE_ID, '-', ''))

4) To remove blanks from a port you can use LTRIM or RTRIM functions: In example below, blank spaces are removed before checking if the value  of port NAME is equal to '?'.

IIF(LTRIM(RTRIM(NAME)) = '?', 'N', 'Y')


Date manipulation in Informatica expression transformation:

In the below example, port TIMESTAMP is converted to dates in YYYY-MM-DD and YYYY-MM-DD HH24:MI:SS format respectively.

TO_CHAR(trunc(TIMESTAMP), 'YYYY-MM-DD')

TO_DATE(TIMESTAMP, 'YYYY-MM-DD HH24:MI:SS')

Netezza datatype conversion function

Netezza datatype conversion function


To convert decimal to integer use cast(value as int) in netezza:


select cast(12345.30 as int)

In the above example in place of 12345.30 you can use any decimal or numeric column.

Wednesday, 25 March 2015

Difference between Lookup and Joiner Transformation in Informatica

Difference between Lookup and joiner transformation in Informatica


Look up transformation :
a) Look up transformation can be used on a single table or a query to search for records that match incoming records. Matching condition can be specified in the lookup transformation. The result returned can be multiple columns or single column.
b) Lookup transformation can be unconnected or connected transformation. Unconnected transformation can return only single value.
c) Lookup transformation can be static or active. Dynamic lookups are active transformation.
d) Lookup transformation be used with more than one relational operator such as > , =, etc.

 

Joiner transformation :

a) Joiner transformation is used to usually to join data coming from two separate tables or source qualifiers.
b) The join can be left outer join, inner join, right outer join, etc.
c) The joiner returns all the results that match the join condition.
d) The master records in the joiner transformation is cached. The detail records are not cached. Hence, joiner transformation is active transformation.


When do you use joiner or lookup transformation?


a) If  the table size is not too large then preferable to use lookup.
b) If result from a single matching records needs to be returned then use a lookup. If there is a query that needs to be used in a lookup to find the result for lookup then good to use a lookup.
c) If you are doing lookup on a table that is updated in the session then use a lookup. Joiners are active so not preferable.
d) If look up table data does not change then the table can be made persistent and used in the lookup which gives even better performance.
e) If data from two different source qualifiers need to be joined then use a joiner.
f) If data from two different databases are read and need to be joined with a outer or inner join then use joiner transformation.

Thursday, 19 March 2015

Creating DATABASE, GROUPS, USERS , GRANTING PERMISSIONS in Netezza

Creating DATABASE, GROUPS, USERS , GRANTING PERMISSIONS in Netezza

Some of the sample netezza commands to create database, user groups , users, add user to a group, grant permissions to netezza objects is below:


Creating a netezza database, group, and adding user group permissions to that database


\c SYSTEM
CREATE DATABASE <databasename>;

CREATE GROUP <groupname> WITH USER <username1>, <username2>;
GRANT LIST ON
<databasename> TO <groupname> WITH GRANT OPTION;GRANT  Create External Table, Create Sequence, Create Synonym, Create Table, Create Temp Table, Create View TO <groupname> ;

GRANT backup, create sequence, create synonym, create table, create external table, create temp table, create view, restore  TO <groupname> ;

To create a user group in netezza database:


Syntax: CREATE GROUP <groupname>

Example: CREATE GROUP  MYTESTGROUP1;

To alter the settings of the group:


ALTER GROUP "<groupname>" WITH ROWSETLIMIT 0 SESSIONTIMEOUT 0 QUERYTIMEOUT 50 DEFPRIORITY High MAXPRIORITY High;

To create a user and assign to a netezza database user group:


CREATE USER  <username>  WITH PASSWORD '??' IN GROUP "<groupname>";

If user already exists or after you have added a user then you can use the command below to add that user to a group:


ALTER GROUP "<groupname>" ADD USER "<username>";

To provide permission on netezza objects such as tables, views, database etc to a user group or a user use the syntax below:


GRANT List ON "<databasename>" TO "groupname";

GRANT List, Select, ON "<tablename>" TO "groupname";


GRANT delete,genstats,groom,insert,list,select,truncate,update ON <tablename> TO <groupname>;
 

To copy permissions from one table to the other in Netezza:


ALTER TABLE <target_table_name> set privileges to  <target table name>;

To change ownership of a netezza table:

alter table <tablename> owner to <newownername>

The above command change the schema name associated with the table

Monday, 16 March 2015

Ways to Sort and aggregate data in Informatica

Sorting  and aggregating data in  Informatica

Sorting In Informatica:

In the Source qualifier of Informatica mapping you can sort the data by manually overiding the SQL and adding order by clause to the SQL. Also, group by clause can be added to the source qualifier.

Select col1, col2, col3 from table1 order by col1, col2



The other way to sort data in the source qualifier of Informatica mapping is to use the Number of sorted ports field in the properties tab of the source qualifier (as shown in screenshot). You can set it to any number of ports you want to sort it on and it will sort the data based on the order the ports are in the source qualifier. If you set the number of sorted ports to 2, then it going to sort in ascending order of port1 and port2 which is eqvilent to using order 1,2 clause in the sql.


Tuesday, 24 February 2015

Advantage of using deployment groups in Informatica

Advantage of using deployment groups in Informatica

Deployment groups- contains all the informatica objects that need to be migrated to the destination machine. It is one of the easiest method to migrate code from one repository to another if it involves few objects. 

To use deployment groups: 

Go to Repository Manager.
Under Tools>Deployment Groups > Create
Provide a name for the deployment group and add the desired permissions.
Select the informatica objects that you want to migrate , right click and select add to deployment group or you can also copy the objects and paste it to the deployment group
Now copy this deployment group from source repository to the destination repository using normal copy and paste.
The deployment wizard will start and you have to follow the on screen steps.


Advantage of using deployment groups:

1) It is easy to deploy since you can migrate all the objects in one shot just like doing a folder copy.
2) You do not have to create shortcuts manually in the destination folder since deployment group will automatically copy all the shortcuts.
3) You can migrate the changes without having to copy the dependencies such as source or target definition.
4) You can migrate only the portions of the workflow that have changed by adding only those objects from the workflow to the deployment group and remigrating the workflow. For example, if you have add 3 sessions to the workflow, then add the 3 sessions to the deployment group and also the workflow ( no dependencies) to the deployment group. This will migrate the workflow with those 3 sessions only to the target and add those 3 sessions to the workflow in the  target repository.
5) You can automatically set to validate all the objects in the target repository though I have found that this is time consuming.