Further info:
The whole big idea is to take input as follows: <database> <table name="testtable"> <pk name="id"/> <col name="id" type="int"/> <col name="compositekey1" type="int"/> <col name="compositekey2" type="dec" size="9" scale="3"/> <col name="compositekey3" type="varchar" size="10"/> <col name="uniquekey" type="varchar" size="30"/> <col name="nonnullval" type="varchar" size="30" allownull="no"/> <col name="nonnullval2" type="varchar" size="30" allownull="no"> <default>DEFAULT VALUE</default> </col> <col name="nullableval" type="varchar" allownull="yes"/> <col name="constrained_col" type="varchar"> <constraint name="simple_constraint"> <values select="exclude"> <val>hum</val> <val>de</val> <val>dum</val> </values> </constraint> </col> <unique-key cols="compositekey1,compositekey2,compositekey3"/> <unique-key cols="uniquekey"/> </table> </database>
And create some SQL similar to the following:
CREATE TABLE testtable id int,
compositekey1 int,
compositekey2 dec(9, 3),
compositekey3 varchar(10),
uniquekey varchar(30),
nonnullval varchar(30) NOT NULL,
nonnullval2 varchar(30) DEFAULT 'DEFAULT VALUE' NOT NULL,
nullableval varchar NULL,
constrained_col varchar constraint simple_constraint check constrained_col not in ("hum",
"de",
"dum");
It almost works but as I include multiple table elements in my XML it falls apart. Like in my prior email a subsequent table element:
<table name="employee"> <pk name="id"/> <col name="id" type="int"/> <col name="salaried" type="boolean"/> <col name="rateamt" type="dec" size="9" scale="4"/> <col name="rateunit" type="varchar"> <doc>Determines the frequency that rateamt is paid.</doc> <constraint name="valid_values"> <values> <val>hour</val> <val>year</val> </values> </constraint> </col> <col name="grade" type="varchar"/> <col name="title" type="varchar"/> <related table="user" how="onetoone"> <match><onpks/></match> </related> </table>
...produces the following output:
CREATE TABLE employee id int,
salaried boolean,
rateamt dec(9, 4),
rateunit varchar constraint valid_values check rateunit #if($sltAtr.get(0) .getValue() =='exclude') not #else #end in ("hour",
"year"),
grade varchar,
title varchar;
I'm frustrated because as I look back on what I've created it looks less like a template and more like a programmed procedure. I blame myself for my lack of experience and lack of understanding Velocity. However I was hoping that this approach would be something I could hit the ground running with. Given time I'm sure I'd accept Velocity's syntax (had a similar experience with Ant). Just feeling frustrated.
Clifton C. Craig, Software Engineer Intelligent Computer Systems - A Division of GBG 2101 Embassy Drive Lancaster, PA 17603
Phone: 717-295-7977 ext. 621 Fax: 717-295-7683 [EMAIL PROTECTED] [EMAIL PROTECTED]
Shinobu Kawai wrote:
Hi Clifton,
I've had it. I'm trying my best but I can't get Velocity/Anakia to properly convert my XML to SQL. The code is starting to smell and it just doesn't feel quite right. I'm ready to hang up my efforts and call it quits. I can't see why something as simple as expanding a constraint list like this: <constraint name="simple_constraint"> <values select="exclude"> <val>hum</val> <val>de</val> <val>dum</val> </values> </constraint>
would take code that looks like this:
## snip
And even that doesn't work.
Can you explain what output you want, and what you are actually getting?
Best regards, -- Shinobu Kawai
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]