Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews DB Oracle Interviews:Concepts and ArchitectureData AccessDatabase ArchitectureDatabase ManagementDatabase Security OracleDistributed ProcessingFlexfieldForms ReportsGeneral OracleMemory ManagementMTO-SAP Financial AccountingOCIOracle AOLOracle AROracle Backup RecoveryOracle D2KOracle DatabaseOracle Database DeveloperOracle DB OptimizationOracle DBAOracle DeveloperOracle ETLOracle Forms 3.0Oracle Forms 4.0Oracle GLOracle PL-SQLOracle RMANOracle ScenariosOracle SecurityOracle SQLOracle System ArchitectureOracle Technology Network (OTN)Programmatic ConstructsRAC (Real Application Clusters)SQL Plus
Copyright © 2018. All Rights Reserved
Oracle Database Interview Question:
How To Run SQL Functions in PL/SQL?
Submitted by: AdministratorOf course, you can run SQL functions in SQL statements. But many SQL functions can also be executed in regular PL/SQL statements, as shown in the following sample script:
DECLARE
now DATE;
id NUMBER;
str VARCHAR2(40);
BEGIN
now := SYSDATE;
DBMS_OUTPUT.PUT_LINE('Time #1 = ' ||
TO_CHAR(now,'HH24:MI:SS'));
SELECT SYSDATE INTO now FROM DUAL;
DBMS_OUTPUT.PUT_LINE('Time #2 = ' ||
TO_CHAR(now,'HH24:MI:SS'));
id := UID;
DBMS_OUTPUT.PUT_LINE('User id #2 = ' || TO_CHAR(id));
SELECT UID INTO id FROM DUAL;
DBMS_OUTPUT.PUT_LINE('User id #2 = ' || TO_CHAR(id));
str := CHR(70)||CHR(89)||CHR(73);
DBMS_OUTPUT.PUT_LINE('String #1 = ' || str);
SELECT CHR(70)||CHR(89)||CHR(73) INTO str FROM DUAL;
DBMS_OUTPUT.PUT_LINE('String #2 = ' || str);
END;
/
Time #1 = 21:41:16
Time #2 = 21:41:16
User id #2 = 33
User id #2 = 33
String #1 = ggl
String #2 = ggl
Submitted by: Administrator
DECLARE
now DATE;
id NUMBER;
str VARCHAR2(40);
BEGIN
now := SYSDATE;
DBMS_OUTPUT.PUT_LINE('Time #1 = ' ||
TO_CHAR(now,'HH24:MI:SS'));
SELECT SYSDATE INTO now FROM DUAL;
DBMS_OUTPUT.PUT_LINE('Time #2 = ' ||
TO_CHAR(now,'HH24:MI:SS'));
id := UID;
DBMS_OUTPUT.PUT_LINE('User id #2 = ' || TO_CHAR(id));
SELECT UID INTO id FROM DUAL;
DBMS_OUTPUT.PUT_LINE('User id #2 = ' || TO_CHAR(id));
str := CHR(70)||CHR(89)||CHR(73);
DBMS_OUTPUT.PUT_LINE('String #1 = ' || str);
SELECT CHR(70)||CHR(89)||CHR(73) INTO str FROM DUAL;
DBMS_OUTPUT.PUT_LINE('String #2 = ' || str);
END;
/
Time #1 = 21:41:16
Time #2 = 21:41:16
User id #2 = 33
User id #2 = 33
String #1 = ggl
String #2 = ggl
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.