If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Transform group

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-06-03, 08:49
MoeliTec MoeliTec is offline
Registered User
 
Join Date: Nov 2003
Location: Belgium
Posts: 12
Transform group

I have some problem using transform groups, I'm working with DB2 V8.1.0.36.
I have following code

CREATE TYPE AddressType AS (
street Varchar(50),
city Varchar(30),
zip Integer,
country Varchar(10)
)NOT FINAL
MODE DB2SQL;


CREATE TABLE person_tab (
name Varchar(15),
addr AddressType
);

I want to be able to execute the query:

SELECT * FROM person_tab

Therefore it seems I have to define a transform, calling a method or function. I wrote 2 working methods:

CREATE METHOD giveAll() FOR AddressType RETURNS Varchar() RETURN SELF..street || ', ' ||CAST(SELF..zip AS CHAR(5)) ||' '||SELF..city

CREATE METHOD fill(Str Varchar(50), cit Varchar(30), zip Integer, cou Varchar(10)) FOR AddressType
RETURNS AddressType()
RETURN AddressType()..street(Str)..city(cit)..zip(zip)..c ountry(cou)


and thought following would work:

CREATE TRANSFORM FOR AddressType
myGroup (FROM SQL WITH METHOD giveAll() FOR AddressType
TO SQL WITH METHOD fill( Varchar(), Varchar(), Integer, Varchar()) FOR AddressType)


But I got following error

SQL0104N An unexpected token "METHOD" was found following "Group
(FROM SQL WITH". Expected tokens may include: "FUNCTION ".
sqlcode : -104
sqlstate : 42601

Trivial question: What is wrong?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On