Preprocessor Directives

@include

  @include _fileName_

This allows you to drop your CAL definitions around in multiple files. If your filename ends with a \ it is assumed to be a Directory reference and it will load all *.cal files in that directory.
default.cal
  @include Other.cal
  Customers <- { FirstName } NVARCHAR(20)

Other.cal
  Customers < Orders <- { OrderDate } DATETIME

Running Crank.exe default.cal will result in the following file being generated:
default.cal.sql
IF EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[FK_Orders_Customers]') AND parent_object_id = OBJECT_ID(N'[Orders]'))
ALTER TABLE [Orders] DROP CONSTRAINT [FK_Orders_Customers]
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Customers]') AND type in (N'U'))
DROP TABLE [Customers]
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[Orders]') AND type in (N'U'))
DROP TABLE [Orders]
GO

CREATE TABLE [Customers] (

	CustomerID INT IDENTITY(1, 1),
	FirstName NVARCHAR(20),
	CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED
	(
		[CustomerID] ASC
	)
)
GO

CREATE TABLE [Orders] (

	OrderID INT IDENTITY(1, 1),
	OrderDate DATETIME,
	CustomerID INT,
	CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED
	(
		[OrderID] ASC
	)
)
GO

ALTER TABLE [Orders] WITH CHECK ADD CONSTRAINT [FK_Orders_Customers] FOREIGN KEY([CustomerID]) REFERENCES [Customers] ([CustomerID])
GO

@default {NOT} NULL

Changes the default optionality of fields

Last edited Nov 28, 2007 at 1:40 AM by michaelminutillo, version 5

Comments

No comments yet.