[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

bind variables not allowed for data definition operations when using DATES

Posted on 2009-05-19
10
Medium Priority
?
770 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
8 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I showed you how to use console view (HERE (http://www.experts-exchange.com/articles/18379/Getting-Started-and-Using-the-Salesforce-com-Console.html)) -– but how do you set it up on the admin side of Salesforce? Note that you have to have Admin leve…
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

834 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