Icon

kn_​example_​db_​sqlite_​switch_​query

DB SQLite - switch datase source based on a case when selection

DB SQLite - switch datase source based on a case when selection

// create a new string variableString input_value = "";input_value = $NAME$;// capture a possible problem with null values - if not the code might crash// https://www.dummies.com/article/technology/programming-web-design/java/and-operators-and-in-java-172137if(input_value == null) { return 0;}else if ($NAME$.equals("Jogi")) {return 1;}else {return 0;} Just prepare a (simulated) database in a (temporary) SQLite database DB SQLite - switch datase source based on a case when selectionhttps://forum.knime.com/t/db-query-case-switch/63990/7?u=mlauber71 in memory databasevar_port_choiceBubu = 0Jogi = 1assignrandomnumbersvar_port_choiceDROP TABLE IF EXISTS "Jogi";DROP TABLE IF EXISTS "Bubu";DROP TABLE IF EXISTS "tab_decision";CREATE TABLE "tab_decision" ( ID INTEGER PRIMARY KEY , NAME STRING);INSERT INTO "tab_decision"VALUES (1, 'Jogi') , (2, 'Bubu');Jogiprepare dataBubuRowIDdecide ifport 0 = topport 1 = bottomJogiwhich streamwill deliver the data?BubuBubuJogiSELECT * FROM "tab_decision" SQLite Connector Java Snippet(simple) Random NumberAssigner (Apache) Table Rowto Variable DB SQL Executor DB Writer Data Generator Column Rename Partitioning DB Writer RowID Sorter Row Filter CASE Switch Start DB Table Selector CASE Switch End DB Table Selector ConstantValue Column ConstantValue Column DB Reader Merge Variables DB Query Reader // create a new string variableString input_value = "";input_value = $NAME$;// capture a possible problem with null values - if not the code might crash// https://www.dummies.com/article/technology/programming-web-design/java/and-operators-and-in-java-172137if(input_value == null) { return 0;}else if ($NAME$.equals("Jogi")) {return 1;}else {return 0;} Just prepare a (simulated) database in a (temporary) SQLite database DB SQLite - switch datase source based on a case when selectionhttps://forum.knime.com/t/db-query-case-switch/63990/7?u=mlauber71 in memory databasevar_port_choiceBubu = 0Jogi = 1assignrandomnumbersvar_port_choiceDROP TABLE IF EXISTS "Jogi";DROP TABLE IF EXISTS "Bubu";DROP TABLE IF EXISTS "tab_decision";CREATE TABLE "tab_decision" ( ID INTEGER PRIMARY KEY , NAME STRING);INSERT INTO "tab_decision"VALUES (1, 'Jogi') , (2, 'Bubu');Jogiprepare dataBubuRowIDdecide ifport 0 = topport 1 = bottomJogiwhich streamwill deliver the data?BubuBubuJogiSELECT * FROM "tab_decision"SQLite Connector Java Snippet(simple) Random NumberAssigner (Apache) Table Rowto Variable DB SQL Executor DB Writer Data Generator Column Rename Partitioning DB Writer RowID Sorter Row Filter CASE Switch Start DB Table Selector CASE Switch End DB Table Selector ConstantValue Column ConstantValue Column DB Reader Merge Variables DB Query Reader

Nodes

Extensions

Links