At last i think i found out a way out :-). Since my statements are prepared i can use the Statement handle attribute 'NUM_OF_PARAMS' to check whether the bind variables count is matching with the bind variables count in the array passed.
Any feedback or suggestion on this. Thanks, Ramesh ramesh thangamani <[EMAIL PROTECTED]> wrote: What I am expecting is getting error message saying enough bind variables are not passed. Is there a way to force checking bind variables or i need to check myself? Jeffrey Seger <[EMAIL PROTECTED]> wrote: On your execution without a bound value, are you actually looking for rows where the empno column is null? If so, try this: instead of my @bind1 = (); try: my @bind1 = (undef); Otherwise, what exactly are you looking for? Actually, even that may not get you the null rows now that I think about it, because null=null is false as far as Oracle is considered. You may have to do something like this: my $sth = $dbh->prepare( q{select ename from emp where empno = ? or (empno is null and ? is null)}) or die "Can't prepare statement: $DBI::errstr"; and then pass in your values twice (or switch to named variables). On 5/10/07, ramesh thangamani <[EMAIL PROTECTED]> wrote: I tried your suggestion, but still getting the same result. When i tried printing $rc in my old code i get '0E0' which means success. John Scoles <[EMAIL PROTECTED] > wrote: well this is your problem my $rc = $sth->execute(@bind) or die "Can't execute statement: $DBI::errstr"; You are expecting statement handle "$sth" to return a recordset into $rc when it calls the execute method. It does not work like that. try this my $sth = $dbh->prepare( q{select ename from emp where empno = ?}) or die "Can't prepare statement: $DBI::errstr"; @bind = (7902); $sth->execute(@bind) or die "Can't execute statement: $DBI::errstr"; while ( $row = $sth->fetchrow_arrayref() ) { print Dumper $row; } my @bind1 = (); $sth->execute(@bind1) or die "Can't execute statement: $DBI::errstr"; while ( $row = $sth->fetchrow_arrayref() ) { print Dumper $row; } In your old code try printing out the value of $rc you might see the error code there. You code is working correctly as it is written by the way. You get the same results for the second execute because the record buffer in the statment handle is not cleaned out because no execute took place. ----- Original Message ----- From: ramesh thangamani To: John Scoles ; dbi-users@perl.org ; [EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 8:10 AM Subject: Re: Clarification on DBI module Hi John, I am attaching the code. Here is the result: $VAR1 = [ 'FORD' ]; $VAR1 = [ 'FORD' ]; Thanks, Ramesh John Scoles <[EMAIL PROTECTED]> wrote: Hard to say without some of the orginal code could be a number of things. Do you have raiserror or pringerror set on the handle. If you are only printing an error you may not see it and you end up just rereading the cached data from the last query. Post you code so we can have a look at it. cheers John Scoles ----- Original Message ----- From: "ramesh thangamani" To: ; Sent: Wednesday, May 09, 2007 3:09 AM Subject: Clarification on DBI module > Hi, > > Can you please clarify my doubts regarding DBI perl module used for > database connection. > > In my environment I am using single module to prepare and execute the sql > queries. The sql query can have bind variables or they may not have. In > order to improve performance i used prepare() and execute() sequence for > the queries. > > Recently I am facing a issue. When i prepare a query with bind variables > and pass the bind variables in execute() method it works fine, but > second > time if i invoke without passing bind variables it returns the previous > query results and it is not throwing the error: > > DBD::Oracle::st execute failed: ORA-01008: not all variables bound (DBD > ERROR: OCIStmtExecute) [for Statement " > > Which i believe is the expected behaviour since i should pass bind > variables without which the query should fail. How come the execute > functions fine without bind variables in the second/multiple query runs. > > Is there a way to solve this issue other that re preparing the query ?. > > Tried searching on Web regarding this issue but couldn't find any > discussion on this. > > Thanks, > Ramesh > > > --------------------------------- > Ahhh...imagining that irresistible "new car" smell? > Check outnew cars at Yahoo! Autos. --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check out new cars at Yahoo! Autos. --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos. -- -------------------------------------------------------------------------------------------------------------- The darkest places in hell are reserved for those who maintain their neutrality in times of moral crisis. Dante Alighieri (1265 - 1321) They who would give up an essential liberty for temporary security, deserve neither liberty or security. Benjamin Franklin Our lives begin to end the day we become silent about things that matter. Martin Luther King The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment IV to the Constitution of the United States -------------------------------------------------------------------------------------------------------------- --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check out new cars at Yahoo! Autos. --------------------------------- Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.