Subversion Repositories DevTools

Rev

Rev 6177 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : jats_rm_play24.pl
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : Exeriment with invoking a store proceedure
10
#                       Convert Package Name into pkgid
11
#
12
#
13
#......................................................................#
14
 
15
require 5.006_001;
16
use strict;
17
use warnings;
18
use JatsError;
19
use JatsSystem;
20
use Getopt::Long;
21
use Pod::Usage;                             # required for help support
22
use JatsRmApi;
23
 
24
use DBI;
25
 
26
my $VERSION = "1.2.3";                      # Update this
27
my $opt_verbose = 1;
28
my $opt_help = 0;
29
my $opt_manual;
30
my $RM_DB;
31
 
32
#-------------------------------------------------------------------------------
33
# Function        : Main Entry
34
#
35
# Description     :
36
#
37
# Inputs          :
38
#
39
# Returns         :
40
#
41
my $result = GetOptions (
42
                "help+"         => \$opt_help,          # flag, multiple use allowed
43
                "manual"        => \$opt_manual,        # flag
44
                "verbose+"      => \$opt_verbose,       # flag
45
                );
46
 
47
#
48
#   Process help and manual options
49
#
50
pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
51
pod2usage(-verbose => 1)  if ($opt_help == 2 );
52
pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
53
 
6798 dpurdie 54
$ENV{GBE_RM_LOCATION} = 'jdbc:oracle:thin:@auawsards001.vix.local:1521:RELEASEM';
55
$ENV{GBE_RM_USERNAME} = 'RM_READONLY'; 
56
$ENV{GBE_RM_PASSWORD} =  'RM_READONLY';
392 dpurdie 57
 
58
ErrorConfig( 'name'    =>'PLAY24' );
59
getInvokeStoredProcedure('core_devl');
60
exit;
61
 
62
sub getInvokeStoredProcedure
63
{
64
    my $foundDetails = 0;
65
    my (@row);
66
 
67
    # if we are not or cannot connect then return 0 as we have not found anything
4552 dpurdie 68
    connectRM(\$RM_DB, 0);
392 dpurdie 69
 
70
    # First get all packages that are referenced in a Release
71
    # This will only get the top level packages
72
    # From non-archived releases
73
 
4538 dpurdie 74
    # This select currently works
4552 dpurdie 75
    #   Invoke a function and recover its return value
392 dpurdie 76
    my $pvid = 129265;
4552 dpurdie 77
    my $m_sqlstr0 = "SELECT release_manager.PK_RMAPI.return_vcs_tag($pvid) FROM DUAL";
392 dpurdie 78
 
4538 dpurdie 79
    # This begin does not yet work
80
    #   ORA-01008: not all variables bound
6798 dpurdie 81
    my $m_sqlstr2 =  "begin ? := release_manager.PK_RMAPI.return_vcs_tag($pvid); end;";
82
    my $m_sqlstr4 =  "begin aa := release_manager.PK_RMAPI.return_vcs_tag($pvid); end;";
4538 dpurdie 83
 
4552 dpurdie 84
    # This works
85
    #   Invoke a stored proceedure. A true proceedure with no return value
86
    #   Trick - you MUST have suffiecient privilege in order to execute
87
    #           May not work on the real database, unless you have the right 
88
    #           password.
89
    my $m_sqlstr3 =  "begin RELEASE_MANAGER.PK_BUILDAPI.set_resume(); end;";
392 dpurdie 90
 
4552 dpurdie 91
    #
6798 dpurdie 92
    #   So far, the limits appera to be
4552 dpurdie 93
    #       Can call a stored proceedure, but not one that returns stuff
94
    #       Can call a stored function
95
    #
96
 
4538 dpurdie 97
print("$m_sqlstr\n");
392 dpurdie 98
    my $sth = $RM_DB->prepare($m_sqlstr);
99
    if ( defined($sth) )
100
    {
101
        if ( $sth->execute( ) )
102
        {
103
            print "--- Execute\n";
104
            if ( $sth->rows )
105
            {
106
                print "--- Execute ROWS\n";
107
                while ( @row = $sth->fetchrow_array )
108
                {
109
                    print "Data: @row\n";
110
                }
111
            }
112
            print "--- Finish\n";
113
            $sth->finish();
114
        }
115
        else
116
        {
117
            Error("Execute failure: $m_sqlstr", $sth->errstr() );
118
        }
119
    }
120
    else
121
    {
122
        Error("Prepare failure" );
123
    }
124
}
125
 
126