You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Leo Gaggl <le...@autom-8.com> on 2004/04/01 02:18:00 UTC

RE: MSSQL problems with reserved words

Hi Alex,

I have had the same problem. the only change you need to make is the angle
brackets around $table.Name

here is my torque-gen-3.1\templates\sql\base\mssql\table.vm:

---------- snip ------------------------------------------------------------

/* ---------------------------------------------------------------------- */
/* $table.Name                                                      */
/* ---------------------------------------------------------------------- */

$generator.parse("$basepath/drop.vm", "", "table", $tbl)
CREATE TABLE [$table.Name]
(
#set ( $cols = $generator.parse("$basepath/columns.vm", "", "table", $tbl) )
#set ( $pk = $generator.parse("$basepath/primarykey.vm", "", "table", $tbl)
)
#set ( $unique = $generator.parse("$basepath/unique.vm", "", "table", $tbl)
)
#if($strings.allEmpty([$pk,$unique]))$strings.chop($cols,1)#else$cols#end
#if($strings.allEmpty([$unique]) &&
$pk.length()>0)$strings.chop($pk,2)#else$pk#end
#if($unique.length()>0)$strings.chop($unique,2)#end
);

#set ( $index = $generator.parse("$basepath/index.vm", "", "table", $tbl) )
#if($index.length() > 0)$index#end

---------- snip ------------------------------------------------------------

If any of the committers thinks that's worth putting into CVS - pls. go
ahead.

Leo Gaggl
Adelaide, South Australia

 

-----Original Message-----
From: Alexandru Dovlecel [mailto:alexandru.dovlecel@siemens.com] 
Sent: Wednesday, 31 March 2004 18:46 PM
To: 'Apache Torque Users List'
Subject: MSSQL problems with reserved words

Hi all,

Pls need help ASAP. I have a database that contains tables that are reserved
words for mssql. E.g. one table is called SCHEMA. When I generate the code
from my-schema.xml, it generates the my-schema.sql file. When running the
sql file in the mssql I get an error: SCHEMA keyword not expected after
CREATE TABLE (or something like this). I can do this by generating CREATE
TABLE [SCHEMA]. But if I put the table name as "[SCHEMA]" then the primary
key triggers are not correct (e.g. [SCHEMA]_PK is not a valid name).

How can I overcome this problem? Does anyone have some patched mssql
templates for generating the sql and the OM classes?

Any suggestions? Pls help.

Thanks alot,
Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org