?
Solved

bind variables not allowed for data definition operations when using DATES

Posted on 2009-05-19
10
Medium Priority
?
759 Views
Last Modified: 2013-12-18
I have a script in which I need to replace dates in the selection criteria, however I keep getting the above mentioned error when using them.

i need the proper syntax for using a date as a variable
0
Comment
Question by:shelbyinfotech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
10 Comments
 
LVL 74

Expert Comment

by:sdstuber
ID: 24422596
please post your script
0
 
LVL 16

Expert Comment

by:Milleniumaire
ID: 24422604
Can you please provide an example of the code that is causing the problem.
0
 

Author Comment

by:shelbyinfotech
ID: 24422631
The replace is at line 106:


DEFINE LAST_VAL ='4/27/2009'

DROP TABLE RESPOSTROLL_NVC_1
/
CREATE TABLE RESPOSTROLL_NVC_1
  AS
  SELECT IAS4.PARDAT.PARID,
         IAS4.PARDAT.TAXYR,
         IAS4.LEGDAT.ADRPRE
         ||' '
         ||TO_CHAR(IAS4.LEGDAT.ADRNO)
         ||' '
         ||IAS4.LEGDAT.ADRADD
         ||' '
         ||IAS4.LEGDAT.ADRDIR
         ||' '
         ||IAS4.LEGDAT.ADRSTR
         ||' '
         ||IAS4.LEGDAT.ADRSUF
         ||' '
         ||IAS4.LEGDAT.ADRSUF2
         ||' '
         ||IAS4.LEGDAT.UNITDESC
         ||' '
         ||IAS4.LEGDAT.UNITNO AS PROPERTY_LOCATION,
         IAS4.PARDAT.USER2                           AS REGION,
         IAS4.PARDAT.NBHD,
         DECODE(IAS4.PARDAT.CLASS,'E','EXEMPT',
                                  'F','FARM',
                                  'I','INDUSTRIAL',
                                  'C','COMMERCIAL',
                                  'U','UTILITY',
                                  'M','MULTIPLE',
                                  'R','RESIDENTIAL') AS PAR_CLASS,
         IAS4.LEGDAT.SUBDIV,
         IAS4.LEGDAT.SUBLOT,
         IAS4.LEGDAT.ACRES,
         IAS4.OWNDAT.OWN1                            AS OWN_OWNER,
         IAS4.OWNDAT.OWN2                            AS OWN_OWNER2,
         TO_CHAR(IAS4.OWNDAT.ADRNO)
         ||' '
         ||IAS4.OWNDAT.ADRADD
         ||' '
         ||IAS4.OWNDAT.ADRDIR
         ||' '
         ||IAS4.OWNDAT.ADRSTR
         ||' '
         ||IAS4.OWNDAT.ADRSUF
         ||' '
         ||IAS4.OWNDAT.ADRSUF2
         ||' '
         ||IAS4.OWNDAT.UNITDESC
         ||' '
         ||IAS4.OWNDAT.UNITNO AS OWNER_ADDRESS,
         IAS4.OWNDAT.ADDR2                           AS OWN_INCO,
         IAS4.OWNDAT.CITYNAME                        AS OWN_CITY,
         IAS4.OWNDAT.STATECODE                       AS OWN_STATECODE,
         IAS4.OWNDAT.ZIP1                            AS OWN_ZIP1,
         IAS4.OWNDAT.ZIP2                            AS OWN_ZIP2,
         DECODE(IAS4.ASMT.CLASS,'E','EXEMPT',
                                'F','FARM',
                                'I','INDUSTRIAL',
                                'C','COMMERCIAL',
                                'U','UTILITY',
                                'M','MULTIPLE',
                                'R','RESIDENTIAL') AS ASMT_CLASS,
         NVL(IAS4.ASMT.VAL03,0)                      AS CURR_MKT_TOTL_APPR,
         NVL(IAS4.ASMT.VAL07,0)                      AS CURR_MKT_TOTL_ASMT,
         NVL(IAS4.ASMT.VAL14,0)                      AS CURR_GBT_TOTL_APPR,
         NVL(IAS4.ASMT.VAL20,0)                      AS CURR_GBT_TOTL_ASMT,
         IAS4.ASMT.FLAG2                             AS CURR_GB_USE,
         IAS4.ASMT.FLAG4                             AS CURR_SOIL_APP,
         IAS4.PARDAT.NOTE1,
         IAS4.PARDAT.NOTE2,
         IAS4.APRVAL.REVWHO,
         IAS4.APRVAL.REVREAS,
         IAS4.APRVAL.REVDT,
         IAS4.ASMT.NOTE1                             AS NOTE1_AA13,
         IAS4.ASMT.NOTE2                             AS NOTE2_AA13,
         IAS4.APRVAL.NOTE1                           AS NOTE1_APRVAL,
         IAS4.APRVAL.NOTE2                           AS NOTE2_APRVAL,
         IAS4.PARDAT.LUC                             AS LUC_PARDAT,
         IAS4.APRVAL.WHO                             AS APRVAL_WHO,
         TO_CHAR(IAS4.APRVAL.WEN,'MM/DD/YYYY')       AS APRVAL_WEN
  FROM   IAS4.PARDAT,
         IAS4.LEGDAT,
         IAS4.OWNDAT,
         IAS4.ASMT,
         IAS4.APRVAL
  WHERE  IAS4.PARDAT.PARID = IAS4.LEGDAT.PARID
         AND IAS4.PARDAT.TAXYR = IAS4.LEGDAT.TAXYR
         AND IAS4.PARDAT.CUR = IAS4.LEGDAT.CUR
         AND IAS4.PARDAT.PARID = IAS4.OWNDAT.PARID
         AND IAS4.PARDAT.TAXYR = IAS4.OWNDAT.TAXYR
         AND IAS4.PARDAT.CUR = IAS4.OWNDAT.CUR
         AND IAS4.PARDAT.PARID = IAS4.ASMT.PARID
         AND IAS4.PARDAT.TAXYR = IAS4.ASMT.TAXYR
         AND IAS4.PARDAT.CUR = IAS4.ASMT.CUR
         AND IAS4.PARDAT.PARID = IAS4.APRVAL.PARID
         AND IAS4.PARDAT.TAXYR = IAS4.APRVAL.TAXYR
         AND IAS4.PARDAT.CUR = IAS4.APRVAL.CUR
         AND (IAS4.PARDAT.TAXYR = 2010)
         AND (IAS4.PARDAT.CUR = 'Y')
         AND (IAS4.ASMT.VALCLASS IS NULL)
         AND (IAS4.APRVAL.REVREAS = '39')
             AND (IAS4.APRVAL.WEN >= TO_DATE( &LAST_VAL, 'MM/DD/YYYY'))
/
0
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 
LVL 16

Expert Comment

by:Milleniumaire
ID: 24422646
Create the table first, then use an insert select statement to populate it.
0
 
LVL 16

Expert Comment

by:Milleniumaire
ID: 24422661
Alternatively, build up a create table string, such that all bind variables are literals within the string and then use execute immediate to run it.  Assuming this is a one-off statement it shouldn't cause any performance issues, but if it is run regularly, with different values then this probably isn't the solution.
0
 
LVL 16

Accepted Solution

by:
Milleniumaire earned 2000 total points
ID: 24422704
The solution may be simpler than I thought.  Try changing the last line to use quotes around the variable:

            AND (IAS4.APRVAL.WEN >= TO_DATE( '&LAST_VAL', 'MM/DD/YYYY'))
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24425656
yes, as Milleniumaire is correct, the reason is:

without the quotes the &LAST_VAL looked like a variable and, like the error indicates, you can't have binds in a create, only literals.

With the quotes, the &LAST_VAL is correctly substituted as a literal and the create should work.

0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24614056
Milleniumaire's post #24422704  answers the question,

mine afterward mearly offered explanation as to why that post worked
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Read about achieving the basic levels of HRIS security in the workplace.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question