Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011

    Unanswered: Same Proc for different tables in a single proc

    Hi Folks,

    Well i have a procedure which basically checks for the count of the records in the table and if its 0, it inserts one dummy record...Now the problem is i have multiple tables running into some 40 Tables to be precise and i have implement the same logic for all tables...

    Here is the sample proc..Please help me..How do i incorporate a logic mentioning all tables in the proc at one go..

    create or replace procedure test_proc as
    v_count number :=0;
    select count(*) into v_count from test;
    if v_count = 0 then
    INSERT INTO test (column1, column2,column3)
    end if;

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    how does code "know" or decide which tables need to be run against?
    how does code "know" column names & datatypes to be inserted for 40 different tables?
    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
    Sep 2011

    Pass all the table names into comma seperated values to SP and then using oracle system table retrieve the columns for them build up a dynamic query for insertion and then execute it using execute immediate

Posting Permissions

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