Data Inserting problem

Last post 05-18-2007 9:45 AM by sthauttam. 4 replies.

Sort Posts:

  • Data Inserting problem

    05-16-2007, 3:50 PM
    • Member
      29 point Member
    • sthauttam
    • Member since 01-03-2007, 1:10 PM
    • Posts 75

    Hi!

    I have two tables Address(address_id, street) and Employee(emp_id,address_id,name).  // address_id in Employee table is foreign key

    Here is my stored procedure.

    CREATE OR REPLACE PROCEDURE address_proc
           (street in varchar2,
            name in varchar2)
     is
     BEGIN
         INSERT INTO address
             VALUES (address_id_seq.nextval,street);
         INSERT INTO employee
             VALUES (emp_id_seq.nextval,address_id_seq.currval,name);
         commit;
     END;

    Now, how can I insert data from  a webpage that has input text field for street and name?  I mean to say that a webpage has two input fields street and name. Now I have to save those two fields in separate tables with using the single stored procedure as given above. I am using Oracle 9i and ASP.NET 2.0

    Any suggestions are highly appreciated.

  • Re: Data Inserting problem

    05-17-2007, 3:58 PM
    • All-Star
      16,433 point All-Star
    • stiletto
    • Member since 07-10-2003, 8:42 AM
    • Louisville, KY
    • Posts 3,208

    You'd just create an OracleDbConnection that points to your Oracle server, you'd create an OracleDbCommand that points to your sproc and is of the StoredProceudre CommandType, you add the parameters (named and in the correct order) to your Command and you call ExecuteNonQuery.

    Which part are you having trouble with?

  • Re: Data Inserting problem

    05-17-2007, 10:06 PM
    • Member
      29 point Member
    • sthauttam
    • Member since 01-03-2007, 1:10 PM
    • Posts 75

    Hi Stiletto,

    Thanks for suggestion,

    I have found that there was a problem in Stored Procedure. Could you please suggest me how to wrtie stored procedure for the mention problem?

    I would appreciate your help.

    Thank you,

  • Re: Data Inserting problem

    05-18-2007, 8:17 AM
    Answer
    • All-Star
      16,433 point All-Star
    • stiletto
    • Member since 07-10-2003, 8:42 AM
    • Louisville, KY
    • Posts 3,208

    What's the error the stored procedure is giving? 

    The only thing that looks like it sould be an issue to me is the reference to currValue.  If that's it, then select the nextValue into a local variable and them pass it explicitly to both the tables.

  • Re: Data Inserting problem

    05-18-2007, 9:45 AM
    • Member
      29 point Member
    • sthauttam
    • Member since 01-03-2007, 1:10 PM
    • Posts 75

    Hi stiletto,

    Thanks, I have solved the problem. Hope you will guide me in near future.

     Thanks,

     

Page 1 of 1 (5 items)