Friday, June 30, 2017

What is the difference between npm install and npm update:

I keep doing stuff that I don't understand.

I was wondering what was the reason we were instructed to always run npm install an npm update after pulling from the repository. Couldn't a single command do it?


So, here's a short note on the difference between npm install and npm update:

Sample package.json file:

{
  "name":          "my-project",
  "version":       "1.0",                             // install   update
  "dependencies":  {                                  // ------------------
    "already-installed-versionless-module":  "*",     // ignores   "1.0" -> "1.1"
    "already-installed-semver-module":       "^1.4.3" // ignores   "1.4.3" -> "1.5.2"
    "already-installed-versioned-module":    "3.4.1"  // ignores   ignores
    "not-yet-installed-versionless-module":  "*",     // installs  installs
    "not-yet-installed-semver-module":       "^4.2.1" // installs  installs
    "not-yet-installed-versioned-module":    "2.7.8"  // installs  installs
  }
}
Conclusion: The only big difference is that an already installed module with fuzzy versioning ...
  • gets ignored by npm install
  • gets updated by npm update

Thursday, June 29, 2017

PL/SQL: Simple cursors for example

Here a very basic demonstration of a PL/SQL program that updates data from a table. It uses an explicit cursor for loop:

The program is based on the EMPLOYEES table in HR Schema.

DECLARE

  CURSOR C1 IS 
  SELECT * FROM EMPLOYEES WHERE DEPARTMENT_ID = 60 
  FOR UPDATE;

BEGIN

  SAVEPOINT TX_START;

  FOR RC IN C1 LOOP

    DBMS_OUTPUT.PUT_LINE('Fetching record ' || RC.LAST_NAME);

    IF RC.SALARY > 5000 THEN
      UPDATE EMPLOYEES SET SALARY = SALARY*1.1 WHERE CURRENT OF C1;
    END IF;

  END LOOP;

  EXCEPTION

  WHEN OTHERS THEN
    ROLLBACK TO TX_START;
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    RAISE;

END;
/