Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Bangalore, India
    Posts
    250

    Unanswered: stored procedures

    hi,

    am new to Oracle.and am attempting to write a stored procedure based on information i obtained from an article in the net.

    i have a table of the form

    MyTable
    (MyNumField number,
    MyStringField varchar2(10)
    )
    and am attempting to write a stored procedure to insert records into the table as follows

    Create procedure sp_Test
    (
    MyNum TBL_MyTable.MyNumField%TYPE,
    MyString TBL_MyTable.MyStringField%TYPE
    )
    AS
    BEGIN
    INSERT INTO
    TBL_MyTable(MyNumField,MyStringField)
    VALUES
    ( MyNum,MyString)
    EXCEPTION

    END sp_Test

    (i donno whether the syntax is correct.).

    pls tel how to validate the input. and to handle execptions that might occur in the stored procedure..

    it wud be a gr8 help if someone direct me to gud oracle tutorials in the net

    thanks in advance
    Cheers....

    baburajv

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Procedure you wrote will be correct when you remove EXCEPTION keyword and terminate INSERT statement with a semi-colon (;). Regarding, of course, that the table name is 'TBL_MyTable' instead of 'MyTable'.

    How to validate the input? Execute the procedure and check what was done. To execute it, issue such a statement at the SQL prompt:

    SQL> execute sp_test (1, 'a string'); -- it will pass or fail; in both cases, you'll receive a message
    SQL> select * from tbl_mytable;

    Error handling is up to you - you should anticipate what might go wrong and why could the procedure code fail.

    Here is a chapter that deals with PL/SQL errors handling.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •