Friday, September 10, 2010

Informatica: How to Break target in multiple files with different filenames

Requirement.

We need to provide information broken down on seperate files with diferent file names. e.g we must provide customer statistics, every customer must be in a different file. the filename must include the customer id.



Solution.
  • Open Informatica designer
  • Go to Target designer
  • Open the appropriate target (should be file)
  • Click on "F" icon in order to create the filename port. This way we can control the output filename from a mapping.

  • Next go to mapping designer.
  • we need a mapping with the following tasks: 
  • Source->Sorter -> Expression->Transaction Control->Target
  • The expression must check for any changes at the key. We achieve that by creating a variable that holds previus value for ID.
  • if the key is changed (e.g customer id) then it must pass a signal to transaction control for commit.
  • In order to create different file for every customer we must use a Transaction control prior target. Everytime a commit is issued from the TC expression a new file is being created.


  • The sorting on the key is mandatory because of the aforementioned technique.
  • Enjoy

Linux FTP using a script

I was using ftp -s:filename on windoze machines in order to FTP files. On the other hand the "s" switch is mising on a Linux based OS. You must use the "<"  symbol to redirect input from a file. Furthermore you can implement autologin using .netrc.

  • Create a file under home named .netrc
  • populate file with server entries of the following format:
               machine myownmachine
               login myusername
               password mypassword
    e.g
               machine testserver
               login poweruser
               password 123456

  • Execute command chmod 600 .netrc so the owner and only the owner can access the file's contents. If you skip this line the autologin feature is going to fail.
  • create a file with the ftp commands you want to execute
  • You can now execute ftp testserver < commandfile
  • Enjoy