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

notes

Evening

20 July 2022

I don’t know what makes the evening more beautiful,
you or the sunset.

evening

notes

PL/SQL SELECT INTO Clause

20 July 2022

The SELECT INTO is actually a standard SQL query where the SELECT INTO clause is used to place the returned data into predefined variables.

create or replace function auth_Name
( v_auth_state IN author.author_state%type)
return varchar2

as
    v_authName author.author_last_name%type;
    
    begin
    select author_last_name into v_authName
    from author
    where author_state = v_auth_state;

    return v_authName;

    exception

    when TOO_MANY_ROWS
    then return 'Too Many Authors in that State';

    when NO_DATA_FOUND
    then return 'No Authors in that State';

    when others
    then raise_application_error(-20011,'Unknown Exception in authName Function');

end;
References

dba-Oracle

notes

Count(*) is unsafe

19 July 2022
SELECT COUNT(*) INTO var WHERE CONDITION;

IF var > 0 THEN
SELECT NEEDED_FIELD INTO otherVar WHERE CONDITION;

In PLSQL method with count(*) is unsafe in above code. If another session deletes the row that met the condition after the line with the count(*), and before the line with the select ... into, the code will throw an exception that will not get handled.

Use the below insted,

SELECT NEEDED_FIELD INTO var WHERE CONDITION;
EXCEPTION
WHEN NO_DATA_FOUND
References

Stack Overflow

notes

Set Define OFF

18 July 2022

The SET DEFINE command changes the prefix character used to mark substitution variables. You can use SET DEFINE to turn variable substitution off.

SET DEF[INE] {OFF | ON | prefix_char}

Define is a SQL*Plus client variable. It is NOT a database level setting.

When you start SQL*Plus, variable substitution will be on by default, and the default prefix character is an ampersand. If you are running a script that uses ampersands in text strings, you may want to change the prefix character to something else. If your script doesn’t use substitution variables, you may find it easiest to turn the feature off.

References

Oreilly

notes
13 July 2022

When you started to look deep inside you, you will find the sparks of magic.

notes
11 July 2022

Sometimes we are in a war that doesn’t even exist.

notes
7 July 2022

Everything will end. Make it to the most.

notes
6 July 2022

May be peace is the higher version of happiness.

essay

How JS code is executed.

5 July 2022
JavaScript code execution involves a sequence of steps managed by the JavaScript engine, primarily through the use of the call stack and execution contexts...