Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 597
  • Last Modified:

Need help creating a procedure / function for repeatedly used SQL

I have a practice table called KEYBOARD_LEARNING  that I use as a log for my latest word per minute scores. I use this code so much I figured it's time to make a procedure or function or package. I'm honestly not sure which is best.

What remains static is emplid. All other columns are dynamic and will be different each time I use this insert to make a new row in my table

INSERT INTO keyboard_learning (emplid,wpm, date_completed,exercise,attempt,score_lvl)
VALUES ('000000000','67.66','14-AUG-2012','Keyhero.com','28','95.87% accuracy')

Open in new window

What is the best way to go about encapsulating this SQL? What would the code be?
Thank you
1 Solution
slightwv (䄆 Netminder) Commented:
You really only need a function/procedure to mask the business logic.

Untested but try the following.  You might need to adjust the data types to match your table.

create or replace procedure insert_keyboard_learning(
v_wpm in varchar2,
v_date_completed in varchar2,
v_exercise in varchar2,
v_attempt in varchar2,
v_score_lvl in varchar2)
INSERT INTO keyboard_learning (emplid,wpm, date_completed,exercise,attempt,score_lvl)
VALUES ('000000000',v_wpm, v_date_completed,v_exercise,v_attempt,v_score_lvl);

show errors
Mark_CoAuthor Commented:
Thank you slightwv. I will try this out as soon as I get to back to the office

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now