|
Post by davidy13 on Sept 13, 2023 10:45:16 GMT
Hi, here is the code I tried to run below as a verbatim string with:
dbManager.Execute(verbatimString);
Unity gave me a "SQLiteException: near "WITH": syntax error". Is there a way to fix this? Did I make a mistake somewhere? This code is supposed to look at similar tags in the IPC column and return pairs of objects that have similar tags.
This same SQL command runs fine using something like DB Browser for SQLite. But it does not seem to work with SimpleSQL.
CREATE TEMP TABLE TempTable AS
WITH RECURSIVE SplitIPC AS (
SELECT
PatentId,
substr(IPC, 1, instr(IPC || '|', '|') - 1) AS tag,
substr(IPC || '|', instr(IPC || '|', '|') + 1) AS remainder
FROM
PatentInfo
UNION ALL
SELECT
PatentId,
substr(remainder, 1, instr(remainder || '|', '|') - 1),
substr(remainder, instr(remainder || '|', '|') + 1)
FROM
SplitIPC
WHERE
remainder != ''
),
Pairings AS (
SELECT DISTINCT
a.PatentId AS PatentId1,
b.PatentId AS PatentId2
FROM
SplitIPC a
JOIN
SplitIPC b
ON
a.tag = b.tag AND a.PatentId <> b.PatentId
)
SELECT
PatentId1,
GROUP_CONCAT(DISTINCT PatentId2) AS LinkedPatents
FROM
Pairings
GROUP BY
PatentId1;
UPDATE Year2021
SET LinkedPatents = (
SELECT LinkedPatents
FROM TempTable
WHERE Year2021.PatentId = TempTable.PatentId1
);
|
|
|
Post by echo17 on Sept 14, 2023 9:40:54 GMT
I haven't tried to use the WITH command before, so I'm not sure what the issue might be. It could be that the version of the sqlite library included with the plugin doesn't have that support. You can try to use a different version by downloading from sqlite.org Please see this FAQ for more information: link
|
|
|
Post by davidy13 on Sept 16, 2023 11:10:46 GMT
Thanks so much! I updated to SQLite version 3.43.1 and it seems to work, but I have to do more tests on it.
Just one more thing, in the SimpleSQL_Runtime and SimpleSQL_Runtime_Lite folders there is only the sqlite3.dll_32.resource and sqlite3.dll_64.resource.
However, in the SimpleSQL_Runtime_x64 folder there is an additional file: sqlite3.dll.resource. I did not replace this. Do I need to replace it? Or just leave it alone?
Thanks again!
|
|
|
Post by echo17 on Sept 18, 2023 14:15:06 GMT
Yes, that one can be ignored. I think it was in an earlier version of the plugin, but I didn't remove it for legacy code purposes.
|
|