I am NEW to PL/SQL so please don't mark me down if this seems too beginner-like of a question. I have spent a couple hours working on this and am now seeking help. Additionally, please bear in mind that this code is incomplete. I'm seeking help to complete it. So I am trying to create a simple procedure for my test table called KEYBOARD_LEARNING. I used to have to manually use this code:
INSERT INTO keyboard_learning (emplid, wpm, date_completed,exercise,attempt,score_lvl)
VALUES ('000000000','37.66','04-JUL-2012','Keyhero.com','28','95.87% accuracy')
..for every time I wanted to log a new score to KEYBOARD_LEARNING. I figured I could make a procedure to handle this for me but I need it to not be static because the values I input when I call this procedure are always changing. Any thoughts on how I can make the code I have work with this optimal funcionality? By the way, the code below is not executing, which I'm sure an experienced Oracle user will be able to figure out why right away.
Thank you
CREATE OR REPLACE PROCEDURE INSERT_WPM_SCORE
(
P_EMPLID VARCHAR2
,P_WPM NUMBER
,P_DATE_COMPLETED SYSDATE
,P_EXERCISE VARCHAR2
,P_ATTEMPT VARCHAR2
,P_SCORE_LVL VARCHAR2
) AS
/*
Original Author:
Created Date: 2-Aug-2012
Purpose: For inputting latest WPM score from typing practice
*/
/*variables*/
L_EMPLID VARCHAR2(4000);
L_WPM NUMBER;
L_DATE_COMPLETED SYSDATE;
L_EXERCISE VARCHAR2(4000);
L_ATTEMPT VARCHAR2(4000);
L_SCORE_LVL VARCHAR2(4000);
L_PREVENT_NULL_INPUT EXCEPTION;
PRAGMA EXCEPTION_INIT(L_PREVENT_NULL_INPUT, -44002); --GET CORRECT ERROR # BY TESTING WITHOUT EXCEPTION
VALUES VARCHAR2(4000); [b]<-- getting an error here[/b]
/*Procedure 'W' is a wrapper for DBMS output*/
PROCEDURE W(STR VARCHAR2) IS
L_STRING VARCHAR2(4000);
BEGIN
/*Outputting string parameter passed into 'W' procedure*/
L_STRING := STR;
DBMS_OUTPUT.PUT_LINE(STR);
END;
BEGIN
VALUES := (L_EMPLID, L_WPM, L_DATE_COMPLETED, L_EXERCISE, L_ATTEMPT,L_SCORE_LVL);
SELECT INTO (SELECT *
FROM KEYBOARD_LEARNING A
ORDER BY A.EXERCISE
,TO_NUMBER(ATTEMPT))
-- DBMS_OUTPUT.PUT_LINE(RESULTS);
EXCEPTION
/* */
WHEN L_PREVENT_NULL_INPUT THEN
NULL;
/*this exception catches all other exceptions*/
WHEN OTHERS THEN
W('ERROR: ' || SQLERRM);
END;