Skip to content

Fetch all columns as strings #907

@mhgill

Description

@mhgill

This is my code:

var get_ddl = function(conn, cb) {
  conn.execute(
    ddl_cmd,
    [178],
    {
      fetchInfo :
      {
        ?ALL?:    { type : oracledb.STRING },  // return the date as a string
      }
    },
    function(err, result) {
      console.log(result.rows);

    });
};

This is the example code:

function(err, connection) {
    if (err) {
      console.error(err.message);
      return;
    }
    connection.execute(
      "SELECT last_name, hire_date, salary, commission_pct FROM employees WHERE employee_id = :id",
      [178],
      {
        fetchInfo :
        {
          "HIRE_DATE":      { type : oracledb.STRING },  // return the date as a string
          "COMMISSION_PCT": { type : oracledb.DEFAULT }  // override oracledb.fetchAsString
        }
      },
      function(err, result) {
        if (err) {
          console.error(err.message);
          doRelease(connection);
          return;
        }
        console.log(result.rows);
        doRelease(connection);
      });
  });

In the example, the columns have names: HIRE_DATE, and COMMISSION_PCT.
The column I am fetching, i assume has no name, the result is just some rows. I want to fetch all rows as strings. what should I replace ?ALL? with? Also, what is [178] and why did he put that there?

[Edite: code markdown added by @cjbj]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions