在Node-RED中,你可以使用node-red-contrib-oracledb这个新版本的节点来连接Oracle数据库并实现增删改查操作。以下是一个基本的流程示例,它展示了如何使用这个节点来执行简单的数据库操作。
首先,确保你已经在Node-RED的管理界面中安装了node-red-contrib-oracledb节点。
以下是一个简单的Node-RED流程,它演示了如何连接到Oracle数据库并执行一些基本的操作:
[
    {
        "id": "n1",
        "type": "oracledb in",
        "z": "99d6f4b.6efd38",
        "name": "",
        "service": "oracle-config",
        "query": "SELECT * FROM your_table",
        "x": 260,
        "y": 50,
        "wires": [["n2"]]
    },
    {
        "id": "n2",
        "type": "debug",
        "z": "99d6f4b.6efd38",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 470,
        "y": 50,
        "wires": []
    },
    {
        "id": "n3",
        "type": "oracledb out",
        "z": "99d6f4b.6efd38",
        "name": "",
        "service": "oracle-config",
        "x": 260,
        "y": 150,
        "wires": [[]]
    },
    {
        "id": "oracle-config",
        "type": "oracledb-config",
        "z": "",
        "name": "Oracle DB Configuration",
        "user": "your_username",
        "password": "your_password",
        "database": "your_db_tns",
        "connectionTimeout": 60000,
        "poolAlias": "oracle-db-pool",
        "poolMin": 0,
        "poolMax": 10,
        "poolIncrement": 1,
        "poolTimeout": 600000
    }
]在这个流程中:
oracledb in节点用于执行查询并获取结果。debug节点用于调试信息输出。oracledb out节点用于执行插入、更新、删除操作。oracledb-config节点用于配置数据库连接信息。
请确保将your_username、your_password、your_db_tns和your_table替换为你的Oracle数据库的实际用户名、密码、数据库TNS名称和表名。
这个流程展示了如何从数据库中读取数据,并在debug节点中输出结果。要执行插入、更新或删除操作,你可以使用oracledb out节点,并在其中设置相应的SQL语句。例如,你可以设置一个HTTP请求节点来触发这个流程,并在oracledb out节点中发送INSERT、UPDATE或DELETE语句。