isau
Deity
- Joined
- Jan 15, 2007
- Messages
- 3,071
I'm going through my existing code and making it more customizable, and one thing that would be very useful would be a way to exit a SQL file is a certain condition is not true. I don't think there is any way in SQL to do this. However, due to how Civ 6 runs SQL files, there is one way to exit a file midway: make it crash before it finishes execution.
My question is how "safe" this operation is. Here's basically how I'd picture it:
CREATE TABLE tblCrasher
(
CrashID text PRIMARY KEY ;
)
INSERT INTO tblCrasher
(CrashID)
VALUES (1) ;
INSERT INTO tblCrasher
(CrashID)
VALUES (1) [[where whatever condition is true ]];
Basically, you'd attempt an INSERT statement into a table that has no bearing on gameplay This would cause Civ 6 to abandon that SQL file and move to the next.
As code goes, it's very, very dirty. Maybe even unstable. I haven't actually included it in any files yet, but the temptation is there. Is there a better way to conditionally abandon a file (short of using Rulesets to exclude them from execution)?
My question is how "safe" this operation is. Here's basically how I'd picture it:
CREATE TABLE tblCrasher
(
CrashID text PRIMARY KEY ;
)
INSERT INTO tblCrasher
(CrashID)
VALUES (1) ;
INSERT INTO tblCrasher
(CrashID)
VALUES (1) [[where whatever condition is true ]];
Basically, you'd attempt an INSERT statement into a table that has no bearing on gameplay This would cause Civ 6 to abandon that SQL file and move to the next.
As code goes, it's very, very dirty. Maybe even unstable. I haven't actually included it in any files yet, but the temptation is there. Is there a better way to conditionally abandon a file (short of using Rulesets to exclude them from execution)?