无法确定 SQL 语句的类型
当我尝试执行以下查询时,
<!-- language: sql -->
CREATE TABLE STUDENT (
ID INTEGER NOT NULL PRIMARY KEY,
NAME VARCHAR(255) NOT NULL
);
CREATE GENERATOR GEN_STUDENT_ID;
SET TERM ^ ;
CREATE OR ALTER TRIGGER STUDENT_BI FOR STUDENT
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_STUDENT_ID,1);
END^
SET TERM ; ^
出现错误“无法确定 SQL 语句的类型”
此脚本由 c# 代码运行
FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
csb.ServerType = FbServerType.Embedded;
csb.Database = "mydb.fdb";
csb.UserID = "SYSDBA";
csb.Password = "masterkey";
string conString = csb.ToString();
FbConnection.CreateDatabase(conString);
FbScript script = new FbScript("DB_GEN.sql");
script.Parse();
using (FbConnection conn = new FbConnection(conString))
{
conn.Open();
Console.WriteLine("Connection opened");
FbBatchExecution fbe = new FbBatchExecution(conn);
foreach (string cmd in script.Results) {
fbe.SqlStatements.Add(cmd);
}
try {
fbe.Execute();
}catch(Exception e)
{
Console.WriteLine(e.Message);
}
conn.Close();
Console.WriteLine("Connection closed");
Console.WriteLine("Press any key to continue . . . ");
Console.ReadKey(true);
}
我正在使用 Firebird Embedded v2.5.1 和 FirebirdSql.Data.FirebirdClient v2 .7.0.0
When I'm trying to execute following query
<!-- language: sql -->
CREATE TABLE STUDENT (
ID INTEGER NOT NULL PRIMARY KEY,
NAME VARCHAR(255) NOT NULL
);
CREATE GENERATOR GEN_STUDENT_ID;
SET TERM ^ ;
CREATE OR ALTER TRIGGER STUDENT_BI FOR STUDENT
ACTIVE BEFORE INSERT POSITION 0
AS
BEGIN
IF (NEW.ID IS NULL) THEN
NEW.ID = GEN_ID(GEN_STUDENT_ID,1);
END^
SET TERM ; ^
I'm getting the error "The type of the SQL statement could not be determinated"
This script is running by c# code
FbConnectionStringBuilder csb = new FbConnectionStringBuilder();
csb.ServerType = FbServerType.Embedded;
csb.Database = "mydb.fdb";
csb.UserID = "SYSDBA";
csb.Password = "masterkey";
string conString = csb.ToString();
FbConnection.CreateDatabase(conString);
FbScript script = new FbScript("DB_GEN.sql");
script.Parse();
using (FbConnection conn = new FbConnection(conString))
{
conn.Open();
Console.WriteLine("Connection opened");
FbBatchExecution fbe = new FbBatchExecution(conn);
foreach (string cmd in script.Results) {
fbe.SqlStatements.Add(cmd);
}
try {
fbe.Execute();
}catch(Exception e)
{
Console.WriteLine(e.Message);
}
conn.Close();
Console.WriteLine("Connection closed");
Console.WriteLine("Press any key to continue . . . ");
Console.ReadKey(true);
}
I'm using Firebird Embedded v2.5.1 and FirebirdSql.Data.FirebirdClient v2.7.0.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从另一个网站得到了答案。看来需要将此行替换
为此
脚本已正确运行!
Got the answer from another site. It appears there was need to replace this line
by this
Script was run correctly!