Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Location
    Waukesha WI
    Posts
    78

    Unanswered: Pass a table name to a function?

    I have a rather lengthy Insert statement inside of a pl/sql package.
    I am combining three like tables into one and adding a field.


    Is it possible to pass a table name to a procedure that uses it in an INSERT statement?
    How would it be accepted...a VACHAR2 doesnt seem to work..
    what I envision is something like:

    PROCEDURE Myproc IS
    Begin
    FILLTABLE("MYTABLE1")
    FILLTABLE("MYTABLE2")
    ....
    END


    PROCEDURE FILLTABLE(TABLE1 AS ??)
    INSERT INTO MYMASTER
    (
    FIELD1
    FIELD2
    ...)
    PT.FIELDa
    PT.FIELDb
    ...)
    FROM TABLE1 PT

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    INSERT does NOT contain any FROM clause.
    Why do you insist on using invalid syntax?
    I strongly suggest that you read the fine SQL Reference manual found at http://tahiti.oracle.com
    http://download-west.oracle.com/docs...b14200/toc.htm
    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
    Dec 2003
    Posts
    1,074
    Look into EXECUTE IMMEDIATE.
    -cf

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    You will also have to use execute immediate to make it work.
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  5. #5
    Join Date
    Jun 2005
    Location
    Waukesha WI
    Posts
    78
    Thanks for the help on execute immediate - that was very helpful and much appreciated.

Posting Permissions

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