Output file name uses Data Parameter
I am creating an output file, and I want to use the date parameter passed in as part of the output file name. This is how I name my output file: 1. Assign the date param to ARGV -> $active_date = $ARGV[0]; 2. $outputfile = "NEW_CUSTOMERS_after_$active_date"; When I run the task I get the following error: Can't write to file: No such file or directory at /xps_uat1/express/atai/loc/server/bin/new_customers_since.pl line 71. Below is the section that is referenced: if ($ARGV[0] ne '') { $fetch_New_customers->execute($active_date) || die "Can't execute file handle: $DBI::errstr\n"; while (@raw = $fetch_New_customers->fetchrow) { $node_name = $raw[0]; $created_date = $raw[1]; $active_date= $raw[2]; open (FILE,">>$outputfile$active_date") || die "Can't write to file: $! "; <---LINE 71 write (FILE); } Is there a better way to incorporate a date parameter in the output file name. Thanks, Kim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Variable interpolation in a format - Disregard
never mind. > -Original Message- > From: Kim Green > Sent: Thursday, September 13, 2001 9:11 AM > To: '[EMAIL PROTECTED]' > Subject: Variable interpolation in a format > > Below is my format: > > format FILE_TOP = > New Customers Since > -- > -- > > Customer Name Creation DateActivation Date > . > format FILE = > @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< > @<<<<<<<<<<<<<<<<<<< > $node_name,$created_date, $active_date > > . > > > My script is accepting a date parameter, and I want to print that date in > the title. I tried that by adding $active_date to the New Customers Since > title, and the variable was not interpolated. > What's the best way to print my parameter inside of the output file? > > > > > Kim Green > Billing Systems Developer > Madison River Communications > 919.563.8385 > [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Variable interpolation in a format
Below is my format: format FILE_TOP = New Customers Since Customer Name Creation DateActivation Date . format FILE = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<< $node_name,$created_date,$active_date . My script is accepting a date parameter, and I want to print that date in the title. I tried that by adding $active_date to the New Customers Since title, and the variable was not interpolated. What's the best way to print my parameter inside of the output file? Kim Green Billing Systems Developer Madison River Communications 919.563.8385 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Passing Date from an Application
I am using a billing application called Saville Express to call a perl script and pass in a date. This is my prepare: $fetch_New_customers= $dbh->prepare(<<") || die "Can't prepare: $DBI::errstr\n ";#ataerr::dbprepare($dbh); select node_name, to_char(created_date,'MM-DD-'), to_char(active_date,'MM-DD-') from customer_node_history ch, (select customer_node_id, count(*) as cnt from customer_node_history group by customer_node_id) c where customer_node_status_code = 3 and c.customer_node_id = ch.customer_node_id and c.cnt = 1 and TO_CHAR(active_date,'MM-DD') > ? order by 1 If I pass in 08/20/2001, a record with an active_date of 12/31/2000 is returned. It's as if the month and day are compared , not the entire year. Has anyone experienced this? Kim Green Billing Systems Developer Madison River Communications 919.563.8385 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Command line vs. Application
I have a script that creates outputfile based on the rows returned from a select statement. I run the script from the command line, and the outputfile gets created. But, no file is created when I run the script from an application. Generally speaking, what kinds of things would cause this? Kim Kim Green Billing Systems Developer Madison River Communications 919.563.8385 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Bind variables
> My script has a statement handle that accepts only one parameter. I am > assigning the parameter given to the $ARGV[0]. I run the script from the > command line, also sending the parameter. I am also assigning all selected > values to an array for output. > I continue to get this message: > Can't execute file handle: ORA-01008: not all variables bound (DBD: > oexfet error) > > Here is most of the statement: > $fetch_GLD_BILL_details= $dbh->prepare("select distinct > substr(ne.general_18,82,1) CLASS, > substr(ne.general_18,83,1) MSG_TYPE, > c.charge AMOUNT, > ne.c_party_id MAIN_BILL_NUM, > SUBSTR(ne.a_party_id,1,3) CALLING_NPA, > SUBSTR(ne.a_party_id, 4,3) CALLING_NXX, > SUBSTR(ne.a_party_id,7,10) CALLING_LINE, > rc2.abbreviation FROM_CITY_STATE, > DECODE(SUBSTR(ne.a_party_id,1,3),SUBSTR(ne.b_party_id, 1,3), 'A', 'R') > Inter_Intra, > DECODE(NE.EVENT_SUB_TYPE_CODE,110, NE.C_PARTY_ID,'00') AUTH_CODE, > > DECODE(ne.event_sub_type_code,110, ne.general_14, '') PIN, > NVL(cnda.index1_value, '') PAC_Code, > substr(ne.general_18,4,2) category, > SUBSTR(TO_CHAR(I.ISSUE_DATE,'DD-MON-'),8,11) Stmt_YEAR, > TO_CHAR(I.ISSUE_DATE,'MM'), > SUBSTR(TO_CHAR(I.ISSUE_DATE,'DD-MON-RR'),1,2) Stmt_DAY > FROM customer_node_history cnh, > customer_node_da_array cnda, > product_instance_history pih, > product_history ph, > service_history sh, > service_type st, > charge c, > invoice i, > and SYSDATE between cnh.effective_start_date and cnh.effective_end_date > and SYSDATE BETWEEN pih.effective_start_Date and pih.effective_end_Date > and SYSDATE BETWEEN ph.effective_start_Date and ph.effective_end_Date > and SYSDATE BETWEEN sh.effective_start_Date and sh.effective_end_Date > and cnh.node_name_uppercase = ?"); > > $customer_name = $ARGV[0]; > > Please advise, > > Kim Green > Billing Systems Developer > Madison River Communications > 919.563.8385 > [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Optional Variables
I don't know how or where to put & how to use this $option. What if my Default value is a sql statement? Can I just include the name of the file handle between the brackets? -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Friday, June 29, 2001 6:40 PM To: M.W. Koskamp Cc: Evgeny Goldin (aka Genie); [EMAIL PROTECTED] Subject: Re: Optional Variables On Fri, 29 Jun 2001, M.W. Koskamp wrote: > > my $option = @ARGV ? shift : ; > > Above option only works for 1 parameter tho (and commandline arguments). > For function calls i like to use 'named parameters' by accepting a hash of > options. Well, yeah, but the topic *was* command-line arguments, not function arguments. You can easily loop through @ARGV, unshifting as you go, until @ARGV is depleted and default values assigned. -- Brett http://www.chapelperilous.net/btfwk/ A free society is one where it is safe to be unpopular. -- Adlai Stevenson
Formatting
What would cause this format for the output file to result in the error message "Format not terminated at end of line" : format OUTPUTFORMAT = @<<<,@< ,@<<< ,@< $servicename,$filename ,$service_type_name ,$node_name . These values are assigned by an array that gets populated based on a select statement. I call it in the body of my code like this: write (OUTPUTFORMAT); Thanks, Kim
FW: Optional Variables
file = "$L_DIRECTORY$outputfile"; $header = "Serv. Name FilenameService TypeCustomer Name\n"; # Put this file into File array push @file_array,$outputfile; open (FILE,">>$outputfile") || die "can't open file: $!\n"; print FILE "$header\n"; while (@data = $sth->fetchrow_array()) { my $servicename = $data[0]; my $filename = $data[1]; my $service_type_name = $data[2]; my $node_name = $data[3]; #print " $servicename $filename $service_type_name $node_name\n"; $each_file = "$servicename $filename $service_type_name $space $node_name"; open (FILE,">>$outputfile"); print FILE "$each_file\n"; #write; # invoke format STDOUT to STDOUT } close FILE; } else { if ($filename = 1) { $sthb->execute() || die "Couldn't execute statement."; # Read the matching records and print them out $outputfile = "No_LD_$date"; $outputfile = "$L_DIRECTORY$outputfile"; $header = "Serv. Name FilenameService Type Customer Name\n"; # Put this file into File array push @file_array,$outputfile; open (FILE,">>$outputfile") || die "can't open file: $!\n"; #print FILE "$header\n"; while (@data = $sthb->fetchrow_array()) { my $servicename = $data[0]; my $filename = $data[1]; my $service_type_name = $data[2]; my $node_name = $data[3]; #print " $servicename $filename $service_type_name $node_name\n"; $each_file = "$servicename $filename $service_type_name $node_name"; open (FILE,">>$outputfile"); print FILE "$each_file\n"; } } } close FILE; print "Filename = $filename\n"; Thanks, Kim -Original Message- From: Brett W. McCoy [mailto:[EMAIL PROTECTED]] Sent: Friday, June 29, 2001 9:39 AM To: Kim Green Cc: '[EMAIL PROTECTED]' Subject: Re: Optional Variables On Fri, 29 Jun 2001, Kim Green wrote: > What's the proper syntax to indicate that a variable is optional? The script > that I have created works great when I pass in a variable, but the script > need to execute the SQL even if I don't pass in a variable. You can set a sane default for the variable: my $option = $ARGV[0] || 1; If $ARGV[0] is not defined, then $option will be 1. Or you create your program logic accordingly to do one thing if the option is defined and another thing is if isn't defined. -- Brett http://www.chapelperilous.net/btfwk/ I B M U B M We all B M For I B M -- H.A.R.L.I.E.
Optional Variables
What's the proper syntax to indicate that a variable is optional? The script that I have created works great when I pass in a variable, but the script need to execute the SQL even if I don't pass in a variable. Thanks, Kim
Optional Variables
My question pertains to using command line variables in Perl. I created a script that uses SQL and runs from an application, and the only parameter is optional. This script works well when the parameter is required or not used at all. I have altered the SQL script so that it can accept a variable or execute the query without it, but I need to do the same in Perl. I am using @ARGV and explicitly assigning it to a variable. Below is an excerpt: if (defined(@ARGV[1])) { $filename = @ARGV[1]; $sth->execute($filename) || die "Couldn't execute statement " . $sth->errstr; This is my first script, so I have been reading, researching and testing what I find. However, I found nothing about this anywhere. Please help! Thanks, Kim