1

We are using Unidac Stored Proc Component in Delphi 10 with Sybase 12.5 drivers

In Sybase proc we are raising error like below,i found it is retruning back but it not showing error message.Isthis not working in Unidac or any other issue?

if @number <> null
 begin
  select @errmsg = 'Already active for location ' 
  raiserror 20001 @errmsg 
   return 1 
 end 

am executing storedproc in delphi like below

try 
  ExecProc; 
  except on E:Exception do 
    begin 
     ErrorMsg(EDatabaseError(ExceptObject).Message,0); 
     Exit; 
   end;

but still we are not able to catch the exception.

even i have tried like below.

try 
  UniStoredProc.StoredProcName := 'test'; 
  UniStoredProc.ExecProc; 
except 
  on E:EUniError do 
    ShowMessage(E.Message); 
end

Same code is working fine with Sybase 15 Client Libraries

We are using Sybase 15 server and Sybase 12.5 Client libraries to connect to server,will this be a problem? Earlier we are using BDE with Sybase 12.5 Client libraries so we didnt got any issues now we found this issue with unidac

menjaraz
  • 7,551
  • 4
  • 41
  • 81
SSE
  • 445
  • 2
  • 10
  • 29

2 Answers2

5

For comparison against null you need to use the is operator like so:

if @number is not null
begin
  select @errmsg = 'Already active for location ' 
  raiserror 20001 @errmsg 
  return 1 
end 

Now it should execute the code inside the if-then statement.

Johan
  • 74,508
  • 24
  • 191
  • 319
  • I have already tried "is not" option,we already set the option so it is going into if cluase but it is not returning error raised. – SSE Aug 24 '11 at 06:37
  • @stupid, comparisons against `null` can only be made using `is`. It's standard SQL. – Johan Aug 24 '11 at 14:11
  • @stupid, there is another way to raise an exception, select from a non-existing table. like so: `select * from table_error_already_active_for_location` If you try that does an error come out? – Johan Aug 24 '11 at 14:13
  • Am able to capture error raised with Sybase 15 Client Libraries but not with Sybase 12.5 libraries Is there any issue with Syb 12.5 libraries @Johan..We are migrating from BDE to Unidac earlier in BDE is <> null is allowed,so to allow that we have made ansinull off ..and one more thing when i am selecting from the table it is not compiling..i guess it is not correct solution. – SSE Aug 25 '11 at 09:24
  • I guess Unidac with Sybase 12.5 drivers it is not able to identify the exceptions raised..Is there any way to change in delphi rather than proc..becuase we have about 120+ procs with this issue. – SSE Aug 25 '11 at 09:31
0

Seems the answer is re-deploying the apps using Sybase 15 Client instead of 12.5. Since you already turned off the "ANSINULL" options, the code in procs certainly would have produced an exception triggering. And they do, when using Sybase 15.

Side thinking: have Sybase 12.5 have any connection/client-scoped configuration that was turned off in that release and turned "ON" in Sybase 15 version?

If it's not, it's a bug with Sybase 12.5 that is corrected in Sybase 15 release (or even before on 13, I don't know).

You don't need to rewrite nothing, just redeploy.

PS: I never liked to deploy app to a server with client libs that don't match on version, there's always a possibility to open a can of worms... And this is case, apparently.

PS2: Certainly UniDAC uses more functionality than BDE (which was a middleware with a "minor common denominator" approach) which touched that weak spot on 12.5 client libs.
Another point is that, in SQL Server (which have a common heritage with Sybase), raiseerror have a severity parameter. And only severity 16+ (AFAIR) messages are considered errors - maybe BDE decided that everything is a error, where UniDAC is only following documentation.
This a VERY WILD guess.

Fabricio Araujo
  • 3,810
  • 3
  • 28
  • 43
  • Thanksfor quite interesting guesses..redeploying app with sybase 15 may effect other apps running on syb 12.5 drivers.I believe the problem is with Syb 12.5 but still not able to find the soln :( – SSE Aug 30 '11 at 05:55
  • Sybase site have nothing in their knowledge base? – Fabricio Araujo Aug 30 '11 at 19:20