From c91bcb7aa0155e31a4396cb5b2c69b2f57bdece4 Mon Sep 17 00:00:00 2001 From: totoro Date: Sun, 10 Apr 2022 18:17:48 +0200 Subject: [PATCH] [+] get_db_ids_by_clause helper to get list of DB_id from table and column. For example this help to get list of foreign keys --- controller/hk_sql_utils.anubis | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+), 0 deletions(-) diff --git a/controller/hk_sql_utils.anubis b/controller/hk_sql_utils.anubis index 8d308cf..929b68e 100644 --- a/controller/hk_sql_utils.anubis +++ b/controller/hk_sql_utils.anubis @@ -179,6 +179,26 @@ public define List(Int) } . +public define List(DB_id) + get_db_ids_by_clause + ( + SQLite3DataBase db, + String table_name, + String id_col, + String clause + )= + with final_clause = if clause = "" then + "" + else + "WHERE "+clause, + + if sql_query_timeout(db, "SELECT \""+id_col+"\" FROM "+table_name+" "+final_clause+";", [], "get_ids_by_clause") is + { + error(_) then [], + ok(_, cursor, _) then db_get_List_DB_id(cursor) + } +. + public define Maybe(Int) get_mb_id_by_clause ( -- libgit2 0.21.4