0

My stored proc returns one output parameter, and along with it it has alot of print statements like below

Create Proc
myParam out

begin
  select 'this is a log statement'
  select @myParam = 0
end

I am calling the above from a perl script using DBI, for a Sybase server. I am not sure how to get print the value of select print statement as well as myParam?

Here's what I have done

$sth = $fdadbh->prepare($db_query) or die "Could not prepare statement: ". $fdadbh->errstr;
$sth->execute() or die "Couldnt execute statement: ".$sth->errstr;
do {
      while($row = $sth->fetchrow_arrayref) {
         print join("\t\t", @$row), "\n";
      }
  } while ($sth->{syb_more_results});

Output I get is this is a log statement 0 0

If I remove the line select @myParam = 0 and run it again, I get

this is a log statement
0
-1

How do I remove that 0 coming additionally. Also, Is there any way of cpturing the outputParam in a variable (apart from traversing and keeping the last value)

Kraken
  • 23,393
  • 37
  • 102
  • 162
  • If the duplicate does not help you please tell us and we'll reopen your question. But I'm pretty sure it should be exactly what you need. – simbabque Feb 02 '17 at 13:32
  • @simbabque So the above prints all of the select statements and the output one after the other. But I see that there is an additional 0 returned after select statement and before theoutput param is printed. How do I get rid of that? – Kraken Feb 02 '17 at 13:43
  • I don't know. What database are you using? Please [edit] and include the Perl code you are using to fetch. Also show the output as you see it. I don't know what you mean. – simbabque Feb 02 '17 at 13:50
  • @simbabque done. thanks – Kraken Feb 02 '17 at 13:55
  • It looks like this is not a duplicate after all. I'll reopen. Sorry. – simbabque Feb 02 '17 at 14:04
  • Related: http://stackoverflow.com/a/41441486/1331451 – simbabque Feb 02 '17 at 14:05
  • I've asked it in a different manner again. – Kraken Feb 03 '17 at 07:04
  • That's the one I already closed once. Did it help after all? – simbabque Feb 03 '17 at 07:49
  • @simbabque It did in parts, I was able to fetch multiple output params and print them as well, but I needed to know how to differentiate between thos outputs as well, hence had to ask a different question. Thanks for your help – Kraken Feb 04 '17 at 18:22

0 Answers0