try { sql connect "session1" {cm get "demo_cm_mysql";}; #Open a reader; file reader_open "r1" "data/file.txt" TEXT "utf-8"; #Parse the file; while (is not null (-> "[line]" (file reader_get_line "r1"));) { -> "[A]" (atom get [line] 1 ","); -> "[B]" (atom get [line] 2 ","); -> "[C]" (atom get [line] 3 ","); sql dml "session1" (concat "insert into products (id, name, quantity) values (" (sql encode [A]) ", " (sql encode [B]) ", " (sql encode [C]) ");"); }; #Close the reader; file reader_close "r1"; sql disconnect "session1"; } { try {file reader_close "r1";} {} "[sub_err]"; try {sql disconnect "session1";} {} "[err]"; } "[err]";
try { sql connect "session1" {cm get "demo_cm_mysql";}; #Open a reader; file reader_open "r1" "data/file.txt" TEXT "utf-8"; #Parse the file; while (is not null (-> "[line]" (file reader_get_line "r1"));) { -> "[A]" (string substring [line] 0 1); -> "[B]" (string substring [line] 4 9); -> "[C]" (string substring [line] 10 15); sql dml "session1" (concat "insert into products (id, name, quantity) values (" (sql encode [A]) ", " (sql encode [B]) ", " (sql encode [C]) ");"); }; #Close the reader; file reader_close "r1"; sql disconnect "session1"; } { try {file reader_close "r1";} {} "[sub_err]"; try {sql disconnect "session1";} {} "[err]"; } "[err]";