How to change the table name during the runtime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gurujothi D
    New Member
    • Feb 2012
    • 23

    How to change the table name during the runtime

    I have the following,

    create table ssrr_emp(
    Emp_name varchar2(25),
    Emp_city varchar2(10),
    Emp_id number(2)
    );
    /


    create table ssrr_empsal(
    sal_grade char(1),
    salary number(7,2),
    Commission number(5)
    );
    /


    In the above code,the table names are prefixed with ssrr i.e ssrr_emp and ssrr_empsal,

    Here my question is when I am executing the above code

    I need to prefix the table name with er i.e er_emp and er_empsal.

    I mean during the runtime it should ask the name to enter only for ssrr,
    and
    if i enter er then the tables should be created in the name er_emp and er_empsal.


    How it can be done? can anyone suggest me the code.

    Thank you in advance.


    Regards,
    Gurujothi.
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    Not sure if I understand, but you just want user to be able to put table name prefix, so if user put ssrr then table name starts with ssrr_, if user put er then table name starts with er_.
    Right?

    Comment

    • Gurujothi D
      New Member
      • Feb 2012
      • 23

      #3
      Hi RSKI,
      Yes I need that only.

      Comment

      • rski
        Recognized Expert Contributor
        • Dec 2006
        • 700

        #4
        Well actually you can create PLSQL function which takes ona parameter (prefix) and creates new tables with given prefix. Is that enough for you or do you need the script to ask you for the prefix.

        Comment

        • Gurujothi D
          New Member
          • Feb 2012
          • 23

          #5
          Yes I need that script. Can Yoy please?

          Comment

          • rski
            Recognized Expert Contributor
            • Dec 2006
            • 700

            #6
            But is script with parameter where you can set prefix enough for you, or you need script that will ask for prefix.

            Comment

            Working...