User:Shuijingzhilian/sandbox

use strict;
 * 1) !/usr/bin/perl -w

=head1 USAGE:

run in command line: perl script.pl schema >xxx.log 2>xxx.err &

=head1 EXAMPLE:

nohup perl sql.pl zx017217 >sql.log 2>sql.err &

=cut

my $schema = $ARGV[0] my %schema_pw = ('hm017218'=>ims@7218, 'zx017217'=>ims@7217, 'wc041517'=>bdr@1517, 'yg017216'=>ims@7216, 'mj041515'=>ims@0415);

if(not exists $schema_pw{$schema}) {	print "Please confirm schema name is correct!\n"; exit 1; }

my $sql = qq(" create table EI2014_NVN_980643_01pp_Vagifem_claims_v2 as select ROW_NUMBER over(order by a.pat_id, a.from_dt) as rownum, a.* from IMS201312.CLAIMS a, EI2014_NVN_980643_01pp_Vagifem_p b where a.pat_id=b.pat_id and a.from_dt >= '2009-07-08';
 * 1) -- sql script #

select count(1), count(distinct pat_id) from EI2014_NVN_980643_01pp_Vagifem_claims_v2;

");

system("vsql -h ngspdbaims01lp -U $schema -w '$schema_pw{$schema}' -A -t -c $sql");
 * 1) --- run the sql script