Read-only objects

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Read-only objects

Post by samsuf2002 »

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.
Last edited by samsuf2002 on Fri Jun 05, 2009 7:52 am, edited 1 time in total.
hi sam here
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Set that option as a default in the GUI before you run it from the command line - that changes a registry value the command reads. If you're feeling adventurous you can set it dynamically in a script via regedit.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Thanks Craig for the response.

I can't find any option in GUI to include read-only object. When I open the export window from designer there is a check box which says exclude read only items, it looks like its already defaulted to include. May be I am looking at wrong place :?:
hi sam here
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Maybe it's changed for 8, in earlier versions when you go to the Manager and do Export / DataStage Components there's a Options tab you can switch to and 'Include in export':

Defaulted Properties
Read-only objects
Referenced Shared Containers

The second one is the one I was referring to that needs to be checked for this to work in the 7.x release.
-craig

"You can never have too many knives" -- Logan Nine Fingers
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Some one on the forum here suggested to update the ds objects to not read only by running

Code: Select all

UPDATE DS_JOBOBJECTS SET READONLY = 'NRO' WHERE READONLY = 'RO';
Can anyone advise me on it, quite afraid to try it from Administrator :?
hi sam here
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Again, that's 7.x advice, not to mention the fact that it would affect everything in the repository. So, what was the specific advice - run that, export and then set it all back? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

viewtopic.php?t=88342&highlight=UPDATE+ ... 7RO\%27%3B

It was for 6 version. Doesn't work for me I believe. :(
hi sam here
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I don't believe so, no. And when I said "7.x advice" I really meant "pre-8.x advice". :wink:

Do you have any kind of a playground/sandbox project you could run some trials in?
-craig

"You can never have too many knives" -- Logan Nine Fingers
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

Yes I do have..... I also found this dsx cutter perl script. Thinking of giving a shot on it.
hi sam here
samsuf2002
Premium Member
Premium Member
Posts: 397
Joined: Wed Apr 12, 2006 2:28 pm
Location: Tennesse

Post by samsuf2002 »

I used the below perl script found on dsxchange and testesd it.

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 = '';
      }
   }
} 
It is splitting the project dsx into individual job dsx files, but the name of the file is not coming as .dsx and in the permissions I am seeing the following.

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
Not sure where I am going wrong.

Can any one suggest me on this.... Thanks in advance.
hi sam here
Post Reply