0

how to handle no data found is sybase ? in oracle i can do it like below

BEGIN

select into...

EXCEPTION WHEN NO_DATA_FOUND
do_something
END;
Moudiz
  • 7,211
  • 22
  • 78
  • 156
  • Can't you just use [`@@rowcount`](http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1601/doc/html/san1278452893271.html), [the same as SQL Server](http://stackoverflow.com/questions/2884996/simple-check-for-select-query-empty-result)? – Ben Nov 18 '16 at 08:24
  • Assuming you mean Sybase ASE and not Sybase IQ or Sybase SQL Anywhere (you did not specify). Just check for @@rowcount = 0. But this must be done immediately after the statement, since any other statement will reset this variable.So in practice it's best to first (directly after the DML statement) copy the @@error and @@rowcount values into local variables, and then test the values of those. – RobV Nov 19 '16 at 10:59
  • 1
    Incidentally, SELECT INTO in ASE does something very different from Oracle: in ASE, it creates a new table. To assign a value to a variable, use SELECT @var = instead. – RobV Nov 19 '16 at 11:03

0 Answers0