Help in executing select query from perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in executing select query from perl script
# 1  
Old 12-19-2012
Question Help in executing select query from perl script

Hi,
I have a perl snippet that call a select query with a bind variable,when i compile the script I'm unable to get the query output.
The same query when i fire in sqlplus fetches few rows.
The query takes bit time to fetch results in sqlplus.

Code:
my $getaccts = $lda->prepare("select distinct  usage_acct_seq_nbr 
  from svc_price sp,svc_agrmnt_line_item sali,sbscrp_Asgm sa 
 where sp.free_usage_across_acct_ind in ('Y','A') 
      and sp.svc_name=sali.svc_name 
     and sp.comm_svc_area_id=sali.comm_svc_area_id 
    and sp.charge_type_cd='F' 
    and sp.svc_price_expr_dt is null 
    and svc_agrmnt_trmntn_dt is null 
       and sali.sbscrp_id=sa.sbscrp_id 
    and sa.sbscrp_asgm_expr_dt is null and acct_nbr=?");
    
$getaccts->bind_param(1,$currAcct);
   	print (" getaccts is $getaccts \n ");

	my $sbscrp_id='0032581923';
	my @accts;
	my $returnCode = ERROR;
	if(defined($getaccts))
	{
		$getaccts->execute()|| logDBIError(" execute failed for coll_acct ");

		while ( @accts = replaceNils($getaccts->fetchrow_array() ) ) {

			         print ("Acct = $_ \n");


		}

}


Last edited by jim mcnamara; 12-19-2012 at 09:19 AM.. Reason: unreadable
# 2  
Old 12-19-2012
First question - this looks like DBI code, you get rows from your select statement in sqlplus.

How is DBI communicating: ODBC? In other words what platform is the perl on and what platform is the db server on?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Generating & executing the SELECT and UPDATE clause dynamically using shell script

Hi All, I need to write one shell script. The requirement is as follows. a) I am having list the employee names in a file stored in /tmp directory location as below /tmp/emp.txt b) and the contents are as below cat emp.txt ravi raj ram arun c) I need to connect to sybase... (1 Reply)
Discussion started by: Gowtham_giri
1 Replies

2. Shell Programming and Scripting

How to pass Variable from shell script to select query for SqlPlus?

echo "set echo off"; echo "set feedback off"; echo "set linesize 4000"; echo " set pagesize 0"; echo " set sqlprompt ''"; echo " set trimspool on"; Select statement is mentioned below echo "select res.ti_book_no from disney_ticket_history res where res.ti_status =${STATUS} and... (7 Replies)
Discussion started by: aroragaurav.84
7 Replies

3. Shell Programming and Scripting

How to print the output of a select query using shell script?

HI, I want to connect to database and fetch the count from a table. The sql query is as below : select count(*) from table_test where test_column='read'; How can I print the output of this statement using shell script. Thanks in advance. (4 Replies)
Discussion started by: confused_info
4 Replies

4. UNIX for Dummies Questions & Answers

Regarding executing sql query in shell script

Hi, I have one SQL file prepared in UNIX and one script that is executing that. In SQL i have Update and create queries. I want to introduce conditions in SQL file (in UNIX) that if either of the create or update query failes whole transaction should be rollback. I just have 1 create... (2 Replies)
Discussion started by: abhii
2 Replies

5. Shell Programming and Scripting

How to run a SQL select query in Oracle database through shell script?

I need to run a SQL select query in Oracle database and have to capture the list of retrieved records in shell script. Also i would like to modify the query for certain condition and need to fetch it again. How can i do this? Is there a way to have a persistent connection to oracle database... (9 Replies)
Discussion started by: vel4ever
9 Replies

6. Shell Programming and Scripting

In a csh script, can I set a variable to the result of an SQLPLUS select query?

Can someone tell me why I'm getting error when I try to run this? #!/bin/csh -f source ~/.cshrc # set SQLPLUS = ${ORACLE_HOME}/bin/sqlplus # set count=`$SQLPLUS -s ${DB_LOGIN} << END select count(1) from put_groups where group_name='PC' and description='EOD_EVENT' and serial_number=1;... (7 Replies)
Discussion started by: gregrobinsonhd
7 Replies

7. Shell Programming and Scripting

Script executing sql query

Hello, I have a sh script excuting a sql query through sqlplus. I am having trouble making my date equal to the date of the server time in the sql script. How can i call the server date from my query? Thanks (2 Replies)
Discussion started by: kingluke
2 Replies

8. Shell Programming and Scripting

executing a SQL query in shell script

Hi ALL, I need an help in connecting to oracle database, executing a select query and printing it on the screen. Can any one please write a simple code or psuedo code and let me know. select query returns multiple values( say select name from emp) Thanks in advance LM (1 Reply)
Discussion started by: lijju.mathew
1 Replies

9. Shell Programming and Scripting

Executing Sql Query Using Shell Script

HI ALL i have a requirement like this. i have to write a shell script to run a sql query. DB is oracle. once the query is run, the results of the query has to be published in a data file. can you please advice me how to go about it. i am absolutely new to shell scripts and this is a part of my job. (14 Replies)
Discussion started by: ragha81
14 Replies

10. UNIX for Dummies Questions & Answers

Executing a SQL query from a shell script

I cannot figure out how to run a SQL script, or just a sqlplus query, from a shell script (bash or ksh). Basically, I need to su - oracle from root and run a query, then test the exit status. (3 Replies)
Discussion started by: 98_1LE
3 Replies
Login or Register to Ask a Question