我有以下Scala代码:
db.run(sql"""
DECLARE @Ids TABLE (ID INT NOT NULL, UNIQUE CLUSTERED (ID));
INSERT INTO @Ids VALUES ...;
SELECT A.* FROM SomeTable AS A
INNER JOIN @Ids AS B ON A.ID = B.ID
""".as[Dto])
在这种情况下,Slick(3.2.1)返回INSERT
(受影响的行数)的结果。
如何从SELECT
获取数据?
答案 0 :(得分:0)
看起来Slick无法做到这一点,但是另一种方法是禁用sql更新的输出:
db.run(sql"""
SET NOCOUNT ON;
DECLARE @Ids TABLE (ID INT NOT NULL, UNIQUE CLUSTERED (ID));
INSERT INTO @Ids VALUES ...;
SELECT A.* FROM SomeTable AS A
INNER JOIN @Ids AS B ON A.ID = B.ID
SET NOCOUNT OFF;
""".as[Dto])