Skip to content

Instantly share code, notes, and snippets.

@bobby5892
Last active April 1, 2019 22:59
Show Gist options
  • Select an option

  • Save bobby5892/b22fb3a17de7a6b50d240b1c6957976e to your computer and use it in GitHub Desktop.

Select an option

Save bobby5892/b22fb3a17de7a6b50d240b1c6957976e to your computer and use it in GitHub Desktop.
Basic PL SQL
/* Inclass Question Wk 1 */
set serveroutput on;
DECLARE
firstName varchar2(50) := 'Robert';
lastName varchar2(50) := 'Moore';
output varchar2(100) := NULL;
BEGIN
output := firstName || lastName;
DBMS_OUTPUT.PUT_LINE(output);
END;
/
/* Lab 1 - Assignment */
-- Question 1
set serveroutput on;
DECLARE
TEST_DATE DATE := TO_DATE('2019/04/01', 'yyyy/mm/dd');
TEST_NUMBER NUMBER(10) := 50;
TEST_TIME VARCHAR2(25) := TO_CHAR(
TO_DATE('12:00:00', 'HH24:MI:SS')
, 'HH24:MI:SS') ;
output varchar2(100) := 'yep';
BEGIN
output := 'Test Date: ' || TO_CHAR(TEST_DATE) || ' Test Number:' || TO_CHAR(TEST_NUMBER) || ' Test Time:' || TEST_TIME;
DBMS_OUTPUT.PUT_LINE(output);
END;
/
--Question 2
set serveroutput on;
accept x char prompt 'Please enter your name: '
DECLARE
FIRST_NAME varchar2(50);
output varchar2(100) := 'Name: ';
BEGIN
FIRST_NAME := '&x';
DBMS_OUTPUT.PUT_LINE(output || FIRST_NAME);
END;
/
-- Question 6
set serveroutput on;
DECLARE
operand1 NUMBER(10) := 5;
operand2 NUMBER(10) := 4;
BEGIN
DBMS_OUTPUT.PUT_LINE('The result of multiplying '
|| operand1
|| ' and '
|| operand2
|| ' is '
|| operand1*operand2
|| '.'
);
END;
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment