A collection of tech notes, personal reflections, and evolving thoughts about whatever’s caught my curiosity.

notes

Column-Level Collation and Case-Insensitive Database in Oracle

24 October 2022

Collation determines how strings are compared, which has a direct impact on ordering (sorting) and equality tests between strings.

There are two basic types of collation.

  • Binary : Ordering and comparisons of string data are based on the numeric value of the characters in the strings.
  • Linguistic : Ordering and comparisons of string data are based on the alphabetic sequence of the characters, regardless of their numeric values.

When using binary collations there are three suffixes that alter the behavior of sorts and comparisons.

  • “_CI” : Case insensitive, but accent sensitive.
  • “_AI” : Both case and accent insensitive.
  • “_CS” : Both case and accent sensitive. This is default if no extension is used.

If no collation is specified, directly or via a default setting, the default USING_NLS_COMP pseudo-collation is used, which means the NLS_SORT and NLS_COMP parameters are used to determine the actual collation used.

// Syntax
COLLATE BINARY_CS / BINARY_CI / BINARY_AI

column_name  VARCHAR2(15 CHAR) COLLATE BINARY_CI
create table (...) DEFAULT COLLATION BINARY_CI;
ALTER TABLE t1 DEFAULT COLLATION BINARY_AI;
References

Oracle Base, Oracle Doc

notes

Oracle NLS / National Language Suppport

23 October 2022

The NLS_DATABASE_PARAMETERS shows the values of the NLS parameters for the database. Oracle notes these differences between the parameters.

  • NLS_SESSION_PARAMETERS shows the NLS parameters and their values for the session that is querying the view. It does not show information about the character set.
  • NLS_INSTANCE_PARAMETERS shows the current NLS instance parameters that have been explicitly set and the values of the NLS instance parameters.
  • NLS_DATABASE_PARAMETERS shows the values of the NLS parameters for the database. The values are stored in the database.
SELECT * FROM NLS_SESSION_PARAMETERS ORDER BY 1;   
SELECT * FROM NLS_INSTANCE_PARAMETERS ORDER BY 1;  
SELECT * FROM NLS_DATABASE_PARAMETERS ORDER BY 1; 

The NLS_LANGUAGE and NLS_TERRITORY values in NLS_DATABASE_PARAMETERS cannot be changed once the database has been created

References

dba-oracle
Oracle Blog

notes

Working with my plants

15 October 2022

Working with my plants.

notes

List the months between two dates - PL/SQL

11 October 2022

PL SQL Query to list the months between two dates

SELECT TO_CHAR(ADD_MONTHS(TRUNC(TO_DATE('01-JAN-22','DD-MON-YY'), 'MM'), LEVEL -1),'MON-YY')
MONTH_YEAR 
FROM DUAL
CONNECT BY LEVEL <= MONTHS_BETWEEN(TO_DATE('01-DEC-22','DD-MON-YY'), 
    TO_DATE('01-JAN -22','DD-MON-YY')) + 1
ORDER BY LEVEL;

Result set

MONTH_YEAR
JAN-22
FEB-22
MAR-22
APR-22
MAY-22
JUN-22
JUL-22
AUG-22
SEP-22
OCT-22
NOV-22
DEC-22
essay

Hoisting in JavaScript

10 October 2022
JavaScript Hoisting refers to the process whereby the interpreter appears to move the declaration of functions, variables or classes to the top of their scope, prior to execution of the code...
notes

Fairy tales

19 September 2022

Come, Let’s head to the nights where every fairy tales are true 🦄🦋

notes

ഓണാംശംസകൾ

8 September 2022

അവസാനിക്കാത്ത പൂമഴകളുടെ
ആനന്ദംപോലെ, ഏറ്റവും
മനോഹാരിതയുള്ളൊരു
ഓണാംശംസകൾ നേരുന്നു
ഞാൻ നിങ്ങൾക്ക്. ✨

നിറയെ നന്മകളുണ്ടാകട്ടെ ഏവർക്കും. 🦋

notes

Middleware in the Express.js

1 September 2022

Middleware functions are functions that have access to the request object (req), the response object (res), and the next function in the application’s request-response cycle. The next function is a function in the Express router which, when invoked, executes the middleware succeeding the current middleware.

Middleware functions can perform the following tasks:

  • Execute any code.
  • Make changes to the request and the response objects.
  • End the request-response cycle.
  • Call the next middleware in the stack.

If the current middleware function does not end the request-response cycle, it must call next() to pass control to the next middleware function. Otherwise, the request will be left hanging.

To load the middleware function, call app.use(), specifying the middleware function.

For example, the following code loads the myLogger middleware function before the route to the root path (/).

const express = require('express')
const app = express()

const myLogger = function (req, res, next) {
  console.log('LOGGED')
  next()
}

app.use(myLogger)

app.get('/', (req, res) => {
res.send('Hello World!')
})

app.listen(3000)
notes

Snippet for creating a progress bar

27 August 2022

Snippet for creating a progress bar in the header section.

  <div class="header mt-100">
    <div class="row">
      <div class="progress">
        <div class="progress-bar" id="myBar"></div>
      </div>
    </div>
  </div>

  <script>
    // When the user scrolls the page, execute scrollFn 
    window.onscroll = function () { scrollFn() };

    function scrollFn() {
      var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
      var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
      var scrolled = (winScroll / height) * 100;
      document.getElementById("myBar").style.width = scrolled + "%";
    }
  </script>