I tried node-jt400 (SQL stream)

SQL stream In the coding example, it behaves like CPYF, so let's code it in the same way. Create a physical file to copy to. I changed it a little because it was a big deal. (Change the attributes of LNAME and FNAME, change TOKUTEN to TENSU, change the record format)

MYLIB/MEMBER2.PF


      ***************************************************************** 
      *File ID: MEMBER2                                 
      ***************************************************************** 
     A          R MEMBER2R                  TEXT('member')          
      *                                                                 
     A            ID             3S 0       COLHDG(' ID ')            
     A            LNAME          6G         COLHDG('Last name')            
     A            FNAME         12J         COLHDG('name')            
     A            PROF          40O         COLHDG('profile')    
     A            TENSU          7P 3       COLHDG('Score')            

SQLstream.js


var jt400 = require("node-jt400");
var JSONStream = require("JSONStream");
var express = require("express");
var app = express();


var pool = jt400.pool({ host: '192.168.X.XXX', user: 'MYUSER', password: 'MYPASS' });

var server = app.listen(8888, function () {
    console.log("curl http://localhost:" + server.address().port + '/~');
});

app.get("/stream", function (req, res, next) {
  pool.createReadStream("select * from member") 
    .pipe(JSONStream.parse([true]))
    .pipe(pool.createWriteStream("insert into member2 (ID,FNAME,LNAME,PROF,TENSU) VALUES(?,?,?,?,?)"));
  res.send('end');
});

Try to run it. nodejt05.png Execution result nodejt06.png

The surname and first name were correctly replaced and set.

Recommended Posts

I tried node-jt400 (SQL stream)
I tried node-jt400 (SQL Update)
I tried node-jt400 (SQL query)
I tried node-jt400 (Programs)
I tried node-jt400 (execute)
I tried node-jt400 (Transactions)
I tried node-jt400 (Environment construction)
I tried node-jt400 (IFS write)
I tried node-jt400 (IFS read)
I tried using Java8 Stream API
I tried tomcat
I tried youtubeDataApi.
I tried to summarize the Stream API
I tried refactoring ①
I tried FizzBuzz.
I tried JHipster 5.1
[I tried] Spring tutorial
I tried running Autoware
I tried using Gson
I tried using TestNG
I tried Spring Batch
I tried using Galasa
I tried what I wanted to try with Stream softly.
I tried Java Lambda input / output type ~ Stream version ~
I tried DI with Ruby
I tried using azure cloud-init
I tried Spring State machine
I tried Rails beginner [Chapter 1]
I tried the Docker tutorial!
I tried using Apache Wicket
I tried the VueJS tutorial!
I tried using Java REPL
I tried source code analysis
I tried the FizzBuzz problem
I tried putting XcodeGen + SwiftPM
I tried Rails beginner [Chapter 2]
I tried UPSERT with PostgreSQL.
I tried BIND with Docker
I tried to verify yum-cron
I tried Jets (ruby serverless)
I tried metaprogramming in Java
I tried to implement flexible OR mapping with MyBatis Dynamic SQL
I tried using anakia + Jing now
I tried Angular tutorial + SpringBoot + PostgreSQL
I tried something called recursive search
I tried using Spring + Mybatis + DbUnit
I tried using JOOQ with Gradle
[K8s] I tried communication between pods!
I tried morphological analysis with MeCab
I tried a little digdag docker.run_options
I tried to summarize iOS 14 support
I sincerely hope for Stream # reject
I tried to interact with Java
I tried to explain the method
I tried putting Domino11 in CentOS7
I tried the Java framework "Quarkus"
[Rails] I tried deleting the application
I tried Java's micro-benchmark tool JMH
I tried using JWT in Java
I tried GraphQL with Spring Boot
I tried to summarize Java learning (1)