help with "execute immediate" in oracle

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmuraz
    New Member
    • Nov 2008
    • 13

    help with "execute immediate" in oracle

    hi
    i need to insert values in a temporary teble which i dynamically create the columns like tbl_01, tbl_02....
    for eg.,
    execute immediate 'INSERT INTO TBL_MONTH_LEAVE _DETAIL(TBL_ADM _NO,TBL_MONTH,' TBL_'||TO_CHAR( SYSDATE,'DD'))'
    ||'VALUES (TRSTBD_ADM_NO, TO_CHAR(SYSDATE ,'MMYY'),1)';

    HERE THE COLUMNS ARE TBL_ADM_NO,TBL_ MONTH,TBL_01,.. ...TBL_30
    ACCORDING TO THE DAY THE COLUMN WILL BE SELECTED AND A VALUE 1 WILL BE INSERTED.
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    So what is the error that your dynamic insert statement is displaying?

    Comment

    • amitpatel66
      Recognized Expert Top Contributor
      • Mar 2007
      • 2358

      #3
      Try this statement:

      [code=oracle]

      execute immediate 'INSERT INTO TBL_MONTH_LEAVE _DETAIL(TBL_ADM _NO,TBL_MONTH,T BL_'||TO_CHAR(S YSDATE,'DD'))|| 'VALUES (TRSTBD_ADM_NO, TO_CHAR(SYSDATE ,''MMYY''),1)';

      [/code]

      Comment

      • cmuraz
        New Member
        • Nov 2008
        • 13

        #4
        the error says column not allowed here

        Comment

        • cmuraz
          New Member
          • Nov 2008
          • 13

          #5
          can we concatenate the column names in the execute immedite statement?

          Comment

          • Pilgrim333
            New Member
            • Oct 2008
            • 127

            #6
            Hi,

            Check you parenthesis and quotes, i think you are making a mistake with that.

            Pilgrim.

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              Originally posted by cmuraz
              can we concatenate the column names in the execute immedite statement?
              why you need to concatenate the column names in insert statement ?

              Comment

              • cmuraz
                New Member
                • Nov 2008
                • 13

                #8
                thanks

                thank u guys n sorry for the trouble..
                ive done a mistake in the paranthesis and quotation mark.
                i ve misplaced them in a wrong place...
                i got it working now..
                thanks a lot

                Comment

                • Pilgrim333
                  New Member
                  • Oct 2008
                  • 127

                  #9
                  Originally posted by cmuraz
                  thank u guys n sorry for the trouble..
                  ive done a mistake in the paranthesis and quotation mark.
                  i ve misplaced them in a wrong place...
                  i got it working now..
                  thanks a lot
                  Hi,

                  Good to see that your problem is solved.

                  Pilgrim.

                  Comment

                  Working...