Read-only objects
Posted: Thu Jun 04, 2009 3:24 pm
How to include the read-only objects while exporting a job through command line ? It's giving a message that it omitted read-only objects.
Thanks in Advance.
Thanks in Advance.
Code: Select all
UPDATE DS_JOBOBJECTS SET READONLY = 'NRO' WHERE READONLY = 'RO';
Code: Select all
#!/usr/local/bin/perl -w
###################################################################################################################
#
# Documentation Header
#
###################################################################################################################
# Script Name: DSX_Cutter.pl
# Author :
# Create Date:
#
# Purpose: This script is meant to easily take a single .dsx file as it was exported from DataStage and split it
# into it's component parts. There will be one job and exec per file. The file
# will be named after the Identifier for each DSRECORD within a section or each DSJOB with all
# appropriate subrecords attached to it.
#
# Test results:
#
# Operating command: perl DSX_Cutter.pl filename.dsx
#
# Output : Individual files with the appropriate header for importing into DataStage for job & execjob component.
#
#
#
#
#
#
###################################################################################################################
#
# Code Block
#
###################################################################################################################
use strict;
use warnings;
# define scalars
my $dsx; # name of the file to be processed
my $value; # holds name of parameters file
my $line; # value for line for comparison
my @work; # array to hold working rows
my @header; # array to hold the header rows
my @jobs; # array to hold the job rows
my @exec_job; # array to hold the exec_job rows
#my $jobs_flag # flag for jobs
my @transforms; # array to hold the routines rows
my @routines; # array to hold the routines rows
my @tabledefs; # array to hold the tabledefs rows
my @stagetypes; # array to hold the stagetypes rows
my @datatypes; # array to hold the datatypes rows
my @containers; # array to hold the shared container rows
my @section; # array to hold information for sectional parts of the dsx (transforms, routines, etc.)
my $element; # element of the array being processed
my $tag; # tag holder
my $on; # off/on flag
my $dsname; # name to be assigned to the new file
my $cnt; # generic count for checking things
my $rowchk; # counter for catching begin and end tags right next to each other
my $in_section; # flag showing a routine file is being worked on
#
# initialize some things if needed
#
$on = 0;
$in_section = 0;
#
# collect the filename from the input argument and create the working filename
#
$dsx = "$ARGV[0]";
open (OLD, "< $dsx")||die "Unable to open $dsx for reading!\n";
while ($line = <OLD>)
{
chomp $line;
push(@work, "$line\n");
}
close OLD;
# now that it is all in memory, parse out the sections into their own arrays
# for processing
foreach $element (@work)
{
chomp $element;
# determine which section we are in and flag it accordingly
if ($element =~ /BEGIN HEADER/)
{
$on = 1; ## flag for HEADER records
}
elsif ($element =~ /BEGIN DSJOB/)
{
$on = 2; ## flag for DSJOB records
}
elsif ($element =~ /BEGIN DSEXECJOB/)
{
$on = 3; ## flag for DSEXECJOB records
}
# separate out each section to a name array for it
if ($on == 1)
{
push(@header, "$element\n");
if ($element =~ /END HEADER/)
{
$on = 0;
}
}
if ($on == 2)
{
push(@jobs, "$element\n");
if ($element =~ /END DSJOB/)
{
$on = 0;
}
}
if ($on == 3)
{
push(@exec_job, "$element\n");
if ($element =~ /END DSEXECJOB/)
{
$on = 0;
}
}
}
##############################################################################################################
# process the jobs into their own individual files
##############################################################################################################
### DSJOB section
foreach $element(@jobs)
{
chomp $element;
push(@section,"$element\n");
#print "...-in-1".$element."---".$in_section;
#exit;
if (($element =~ /BEGIN DSJOB/) and ($in_section == 0))
{
# flag the jobs section as being active
$in_section = 1;
}
elsif ($in_section == 1)
{
# check to see if we are at the end of the job
if ($element =~ /END DSJOB/)
{
$cnt = scalar(@section);
if ($cnt > 2)
{
# reset the in_section counter
$in_section = 0;
# extract the name of the file using the Identifier
$value = $section[1];
chomp $value; # remove the end of line stuff
$value =~ s/Identifier//g;
$value =~ s/"//g; # handle quotes
$value =~ s/ //g; # handle spaces
$value =~ s/([\.])/_/g; # handle periods if they exist
$value =~ s/([\\\\])/_/g; # handle double back slashes if they exist
$value =~ s/([\/\/])/_/g; # handle double forward slashes if they exist
$value =~ s/([\\])/_/g; # handle back slashes if they exist
$value =~ s/([\/])/_/g; # handle forward slashes if they exist
$value =~ s/([:])/_/g; # handle colons if they exist
# name the file
$dsname = "$value".".dsx";
print "Creating job file for $dsname\n";
#exit;
open (NEW, "> $dsname")|| die "Unable to create $dsname file!";
# output the header to the file
foreach $line(@header)
{
chomp $line;
print NEW "$line\n";
}
# output the lines of this particular job
print NEW "BEGIN DSJOB\n";
foreach $line(@section)
{
next if (($line =~ /BEGIN DSJOB/) or ($line =~ /END DSJOB/));
chomp $line;
print NEW "$line\n";
}
print NEW "END DSJOB\n";
# when done pushing the lines out, close the file
close NEW;
}
# if the count was 2 or less or has been processed, then ditch what is in the array
@section = ();
$value = '';
}
}
}
################################
### DSEXECJOB section
#print "...-in-2\n";
#$in_section = 0;
$cnt = 0;
#
# get rid of dupes and empty pairs
@work= ();
foreach $element(@exec_job)
{
chomp $element;
#print "...-in-2-1\n".$element."\n";
#exit;
#next if (($element =~/BEGIN DSEXECJOB/) or ($element =~/END DSEXECJOB/));
#if (($element =~ /BEGIN DSEXECJOB/) or ($element =~ /END DSEXECJOB/)) { push(@work, "$element\n"); }
push(@work, "$element\n");
next;
#print "...-in-2-1\n".$element."\n";
#exit;
}
@exec_job = ();
@exec_job = @work;
@work = ();
#print "...-in-3";
foreach $element(@exec_job)
{
#print "...-in-4";
chomp $element;
push(@section,"$element\n");
#print "...-in-4-1".$element."---".$in_section;
#exit;
if (($element =~ /BEGIN DSEXECJOB/) and ($in_section == 0))
{
#print "\n...-in-5";
#exit;
# flag the exec_job section as being active
$in_section = 1;
}
elsif ($in_section == 1)
{
#print "...-in-6";
#exit;
# check to see if we are at the end of the job
if ($element =~ /END DSEXECJOB/)
{
$cnt = scalar(@section);
#print "\n...-in-7".$cnt;
#exit;
if ($cnt > 2)
{
# reset the in_section counter
$in_section = 0;
# extract the name of the file using the Identifier
$value = $section[1];
#print "\n...-in-8".$value;
#exit;
chomp $value; # remove the end of line stuff
$value =~ s/Identifier//g;
$value =~ s/"//g; # handle quotes
$value =~ s/ //g; # handle spaces
$value =~ s/([\.])/_/g; # handle periods if they exist
$value =~ s/([\\\\])/_/g; # handle double back slashes if they exist
$value =~ s/([\/\/])/_/g; # handle double forward slashes if they exist
$value =~ s/([\\])/_/g; # handle back slashes if they exist
$value =~ s/([\/])/_/g; # handle forward slashes if they exist
$value =~ s/([:])/_/g; # handle colons if they exist
# name the file
#print $dsname;
#print "\n\n";
$dsname = "$value"."_exec.dsx";
$dsname = "$value".".dsx";
print "Appending DSEXECJOB to file for $dsname\n";
open (NEW, ">> $dsname")|| die "Unable to create $dsname file!";
# output the header to the file
#foreach $line(@header)
#{
# chomp $line;
# print NEW "$line\n";
#}
# output the lines of this particular job
print NEW "BEGIN DSEXECJOB\n";
foreach $line(@section)
{
next if (($line =~ /BEGIN DSEXECJOB/) or ($line =~ /END DSEXECJOB/));
chomp $line;
print NEW "$line\n";
}
print NEW "END DSEXECJOB\n";
# when done pushing the lines out, close the file
close NEW;
}
# if the count was 2 or less or has been processed, then ditch what is in the array
@section = ();
$value = '';
}
}
}
Code: Select all
.dsxr--r-- 1 dsadm dsadm 13302 Jun 08 09:26 JOB1
.dsxr--r-- 1 dsadm dsadm 44493 Jun 08 09:26 JOB2
.dsxr--r-- 1 dsadm dsadm 699260 Jun 08 09:26 JOB3