Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8341067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:21:30+00:00 2026-06-09T05:21:30+00:00

I am NEW to PL/SQL so please don’t mark me down if this seems

  • 0

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:21:31+00:00Added an answer on June 9, 2026 at 5:21 am

    First, let’s implement the simplest possible thing that could work

    CREATE OR REPLACE PROCEDURE INSERT_WPM_SCORE
    (
              P_EMPLID VARCHAR2
             ,P_WPM NUMBER
             ,P_DATE_COMPLETED DATE DEFAULT SYSDATE
             ,P_EXERCISE VARCHAR2
             ,P_ATTEMPT VARCHAR2
             ,P_SCORE_LVL VARCHAR2
    ) AS
    BEGIN
      INSERT INTO keyboard_learning (emplid, wpm, date_completed,exercise,attempt,score_lvl) 
        VALUES( p_emplid, p_wpm, p_date_completed, p_exercise, p_attempt, p_score_lvl );
    END;
    

    Assuming that works, then you can work on adding additional functionality to the procedure. Unfortunately, it’s not obvious to me what additional functionality you want to implement.

    • You have an exception that you appear to want to throw and/or catch based on a NULL input, for example, but I’m not sure what that is trying to accomplish. Are you trying to validate the inputs to the procedure? Are you trying to catch an exception that is thrown when you do the INSERT and violate a NOT NULL constraint? Something else?
    • I’m not sure what the SELECT statement in your original post is intended to do. Perhaps you are trying to override the p_attempt that is passed in to the procedure?

    Additionally, as a general rule, catching exceptions that you cannot handle is a mistake and a WHEN OTHERS that is not followed by a RAISE is almost always a mistake. If you catch the exception and write the SQLERRM to DBMS_OUTPUT, you lose all the useful stack trace information that the exception provides, you lose the line number of the piece of code that generated the error, you are reliant on the client application to actually enable the DBMS_OUTPUT buffer and to read from it (most client applications do not), and you are preventing the caller of your procedure from determining that the call failed. You would be better served by eliminating your exception handlers entirely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

please help me with writing this search sql stored procedure procedure may have different
Please explain the SQL query given below. I m new with SQL and struggling
Question: The new SQL Server 2008 database returns me values formatted English (date/float). Is
I would like to be able to add a new SQL LOGIN and name
I`m new to sql and have been stuck on the following issue for almost
I'm new to SQL. I have a simple problem with getting the results from
I'm a little new to SQL and have come across the following problem. I
I'm new in SQL queries. I have a problem with the query. I have
I know this question was answered, in C# and I have been trying to
I am new to C#. I have created the login screen.I this one am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.