Solved

bind variables not allowed for data definition operations when using DATES

Posted on 2009-05-19
10
692 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
  • 4
  • 3
10 Comments
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
please post your script
0
 
LVL 16

Expert Comment

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

Author Comment

by:shelbyinfotech
Comment Utility
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
 
LVL 16

Expert Comment

by:Milleniumaire
Comment Utility
Create the table first, then use an insert select statement to populate it.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Expert Comment

by:Milleniumaire
Comment Utility
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
Comment Utility
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 73

Expert Comment

by:sdstuber
Comment Utility
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 73

Expert Comment

by:sdstuber
Comment Utility
Milleniumaire's post #24422704  answers the question,

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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
crm 2010 on premise 5 29
Invalid Identifier Error 3 65
Parametric query in oracle 6 36
Oracle TEXT search question 9 26
Oracle Apps Profiles option: A user profile is a set of shifting options that alter the way one runs an application. A value is set for each option under the user's profile when the Oracle application user logs on to any responsibility or changesā€¦
Hello All, In previous article we used Hortonworks sandbox to work with Hadoop. Now, lets think to create own single node Hadoop on Linux. Here we Install and Configure Apache Hadoop on UI based Oracle Linux. I assume, you have VMware installeā€¦
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now