Parameterized query for schema name?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • j420exe
    New Member
    • Jan 2008
    • 8

    #1

    Parameterized query for schema name?

    How can I parameterize the schema and table name? This is for a report. The user will be prompted to select the schema. The schema names are SALES_PRODUCT_D B.PRODUCT and SUPPORT_PRODUCT _DB.PRODUCT.

    Code:
    SELECT PRODUCT_ID as "ID", PRODUCT_NAME as "Product", to_char(CREATION_DATE, 'mm/dd/yyyy') as "Creation Date", PRODUCT_STATUS as "Status"
    FROM
    :DEFAULTDIVISIONPRODUCT
    WHERE
    CREATION_DATE >= :StartCreationDate and CREATION_DATE <= :EndCreationDate
    Any help is much appreciated.
    Thanks!
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to use EXECUTE IMMEDIATE to frame and execute the query dynamically.

    Comment

    • madankarmukta
      Contributor
      • Apr 2008
      • 308

      #3
      Hi,

      Yup.. you can resolve the query with the executable query. You bind the incoming prameter value with any of the bind variable and then pass this variable to the executrable query.

      Thanks!

      Comment

      • amitpatel66
        Recognized Expert Top Contributor
        • Mar 2007
        • 2358

        #4
        How are you executing this query?? in a PLSQL code?

        Comment

        Working...