unable to create a SQL UDF in Sybase ASE using a case statement

create function ok (@boolean bit)
returns varchar(2000) as
declare @output_string varchar(2000)
select @output_string = case when @boolean = 1 then "" else "not " end
set @output_string = @output_string + "ok"
return @output_string

Msg 156, Level 15, State 2
Server ‘DBADEV1’, Procedure ‘ok’, Line 7
Incorrect syntax near the keyword ‘end’.
I’m trying to write an ASE implementation of TAP. A rudimentary TAP implementation for PostgreSQL is at http://www.justatheory.com/computers/databases/postgresql/introducing_pgtap.html
I’ve been able to use case in SQL UDFs before – see http://froebe.net/blog/2007/10/10/porting-mysqls-date_format-function-to-sybase-ase-1502/
Adaptive Server Enterprise/15.0.2/EBF 15654 ESD#4/P/Linux Intel/Linux 2.4.21-47.ELsmp i686/ase1502/2528/32-bit/FBO/Sat Apr 5 05:18:42 2008
I’m just missing something blindingly simple… I just know it.

Share Button

ASE 15 stored procedure “sp_tables” doesn’t work with SQL UDFs

The ASE 15 stored procedure sp_tables doesn’t work with SQL UDFs. sp_tables has the udfs coming back as system tables.

1) create a sql udf in a db
2) run sp_tables, you will see the UDF as a “SYSTEM TABLE”

DBADEV1.sybase_dba.1> sp_tables;
table_qualifier table_owner table_name table_type remarks
--------------- ----------- ---------- ---------- -------

In the above example, the DATE_FORMAT UDF is the one at Porting MySQL’s date_format function to Sybase ASE 15.0.2

I’ve opened a case with Sybase to get this fixed – I’ll post the CR # when I get it.

UPDATE:  Sybase assigned CR 497173 to this 🙂

Share Button