Solved

bind variables not allowed for data definition operations when using DATES

Posted on 2009-05-19
10
750 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
Raise the IQ of Your IT Alerts

From IT major incidents to manufacturing line slowdowns, every business process generates insights that need to reach the people required to take action. You need a platform that integrates with your business tools to create fully enabled DevOps toolchains.

You need xMatters.

 
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 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

695 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