_link98@yahoo.com wrote:
[color=blue]
> Running DB2 ESE V8.1.8 on WinXP.
> This is Fixpak 8.
>
> Have a structured-type and some methods for that type.
> One of my methods needs to do insert / update on tables.[/color]
Could you elaborate a bit why you think you need to run the insert/update in
the method?
[color=blue]
> The type specification includes "LANGUAGE SQL...CONTAINS SQL".
>
> But I get SQL0374N "The MODIFIES SQL DATA clause has not been
> specified for the CREATE FUNCTION statement for LANGUAGE function..."[/color]
That's correct. CONTAINS SQL means that the method has SQL statements but
it does *not* access any tables in any way - neither reading from nor
writing to the tables/view/nicknames/aliases/... This is good for simple
calculations like in MAX() functions:
CREATE FUNCTION MAX(a INTEGER, b INTEGER)
RETURNS INTEGER
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
RETURN CASE WHEN a > b THEN a ELSE b END
@
[color=blue]
> My type specification looks like (includes the method details):
>
> CREATE TYPE my_type (...)
> ...
> METHOD mytype_UPDATE(...signature details...)
> RETURNS my_type
> SPECIFIC XXX_UPDATE
> SELF AS RESULT
> LANGUAGE SQL
> DETERMINISTIC
> NO EXTERNAL ACTION
> CONTAINS SQL
>
> It is in the the subsequent method body, defined
> as follows:
>
> CREATE SPECIFIC METHOD XXX_UPDATE
> BEGIN ATOMIC
> IF (...)
> THEN UPDATE...
> ELSE ...
> END IF
> END%
>
>
> that I get the SQL0374N error. There are presently no other
> methods or functions explcitly created for this structured-type.
>
> The documentation suggests that I cannot specify MODIFIES SQL DATA
> on the CREATE TYPE statement where the methods get specified.[/color]
One of the questions that comes to mind is why you want to explicitly tie
the method to a certain table. You could (and usually do) have many
different tables.
Basically, only table functions and stored procedures are allowed to modify
the data in existing tables.
--
Knut Stolze
Information Integration Development
IBM Germany / University of Jena