New to PL/SQL, Please Give examples
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: New to PL/SQL, Please Give examples

  1. #1
    Join Date
    Nov 2006
    Posts
    6

    Smile New to PL/SQL, Please Give examples

    Hello PL/SQL Guru's,

    I am new to programming, but I wanted to write a store procedure that:

    Accepts an appID as input and use it to return the card number of any card(s) in an active state associated with the appID, if any from the database.

    I want this to work with our software, java.

    Could you please give me some examples of how to design this?

    Thanks in advance for your help!

  2. #2
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,333

  3. #3
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,001
    You want something like this. Although, you should add some error handling, like what do you return when you do not get any rows, or when you get more than one row. And I do not know your table name or column names. Try readiing PL/SQL Best Practices by Steven Feuerstein.

    Code:
    CREATE FUNCTION get_CardNumber (
       p_appid IN cardtable.appid%TYPE )
       RETURN cardtable.cardnumber%TYPE
    AS
       v_return cardtable.cardnumber%TYPE;
    BEGIN
       SELECT cardnumber
         INTO v_return
         FROM cardtable
        WHERE appid = p_appid;
    
       RETURN v_return;
    END get_CardNumber;
    /
    this space intentionally left blank

Posting Permissions

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



Click Here to Expand Forum to Full Width