Spiegazione dell'errore di Oslo & # 8220; M2037: errore interno di generazione SQL: generatore mancante per la variabile & # 8221 ;?
Domanda
In Microsoft Oslo SDK CTP 2008 (utilizzando Intellipad) il seguente codice viene compilato correttamente:
module T {
type A {
Id : Integer32 = AutoNumber();
} where identity Id;
As : A*;
type B {
Id : Integer32 = AutoNumber();
// A : A;
// } where A in As && identity Id;
} where identity Id;
Bs : B*;
type C {
Id : Integer32 = AutoNumber();
B : B;
} where B in Bs && identity Id;
Cs : C*;
}
e genera il seguente output Reach SQL:
set xact_abort on;
go
begin transaction;
go
set ansi_nulls on;
go
create schema [T];
go
create table [T].[As]
(
[Id] int not null identity,
constraint [PK_As] primary key clustered ([Id])
);
go
create table [T].[Bs]
(
[Id] int not null identity,
constraint [PK_Bs] primary key clustered ([Id])
);
go
create table [T].[Cs]
(
[Id] int not null identity,
[B] int not null,
constraint [PK_Cs] primary key clustered ([Id]),
constraint [FK_Cs_B_T_Bs] foreign key ([B]) references [T].[Bs] ([Id])
);
go
commit transaction;
go
Ma dopo aver cambiato la riga commentata nel modulo T come segue
A : A;
} where A in As && identity Id;
// } where identity Id;
il messaggio di errore " M2037: errore interno di generazione SQL: generatore mancante per la variabile "A" " viene visualizzato (nella finestra Reach SQL di Intellipad).
Qualche idea?
Saluti, tamberga
Soluzione
Penso che quello che vuoi sia:
type A {
Id : Integer32 = AutoNumber();
} where identity Id;
As : A*;
type B {
Id : Integer32 = AutoNumber();
A : A;
} where identity Id;
Bs : (B where value.A in As)*;
type C {
Id : Integer32 = AutoNumber();
B : B;
} where identity Id && B in Bs;
Cs : (C where value.B in Bs)*;
Nota che i vincoli sono sugli esterni, non sui tipi qui. Sono stato in grado di ottenere un codice simile quando i vincoli erano sui tipi ma non sono riuscito ad approfondire più di una relazione. Il loro spostamento verso l'esterno sembra corretto e genera il Reach SQL previsto.