Cursor parameters - problems with 'FROM [inTablename]' statement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sugus

    Cursor parameters - problems with 'FROM [inTablename]' statement

    I'd like to declare a cursor, which accepts parameters also for the
    "FROM" tablename-clause, like:

    CURSOR cFielddef(pfrom Table IN ?????, pTableName IN VARCHAR2) IS
    SELECT column_name, data_type, data_length, nullable FROM pfromTable
    WHERE table_name = UPPER(pTableNam e);

    Is it possible at all, and what type do I have to decalre in place of
    the questionsmarks? Any other solution?

    Thanks für your help,

    Sugus
  • Jim Kennedy

    #2
    Re: Cursor parameters - problems with 'FROM [inTablename]' statement

    "Sugus" <krug@europ.dew rote in message
    news:76f56553.0 308290221.4b4a6 5f3@posting.goo gle.com...
    I'd like to declare a cursor, which accepts parameters also for the
    "FROM" tablename-clause, like:
    >
    CURSOR cFielddef(pfrom Table IN ?????, pTableName IN VARCHAR2) IS
    SELECT column_name, data_type, data_length, nullable FROM pfromTable
    WHERE table_name = UPPER(pTableNam e);
    >
    Is it possible at all, and what type do I have to decalre in place of
    the questionsmarks? Any other solution?
    >
    Thanks für your help,
    >
    Sugus
    What do you want the query to do? You can't do it that way because Oracle
    is trying to compile it and make sure the columns exist etc. If it does not
    know the tablename then how could it? You would have to use dynamic sql
    which may cause scalability problems.
    Jim


    Comment

    • Alan Mills

      #3
      Re: Cursor parameters - problems with 'FROM [inTablename]' statement


      "Sugus" <krug@europ.dew rote in message
      news:76f56553.0 308290221.4b4a6 5f3@posting.goo gle.com...
      I'd like to declare a cursor, which accepts parameters also for the
      "FROM" tablename-clause, like:
      >
      CURSOR cFielddef(pfrom Table IN ?????, pTableName IN VARCHAR2) IS
      SELECT column_name, data_type, data_length, nullable FROM pfromTable
      WHERE table_name = UPPER(pTableNam e);
      >
      Is it possible at all, and what type do I have to decalre in place of
      the questionsmarks? Any other solution?
      >
      Thanks für your help,
      >
      Sugus
      you would have to use dynamic SQL for this. The parameter would then simply
      be a VARCHAR2 type, i.e., string.


      Comment

      Working...