After long, tiring hours,
I want to drink you,
and the tea, slowly
Poets are wizards
who can make you dream.
Whenever I am looking into my brown eyes,
I can see the magic.
Its says believe in yourself.
PL/SQL SELECT INTO Clause
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
Count(*) is unsafe
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
Set Define OFF
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
When you started to look deep inside you, you will find the sparks of magic.
Sometimes we are in a war that doesn’t even exist.
Everything will end. Make it to the most.