Solved

bind variables not allowed for data definition operations when using DATES

Posted on 2009-05-19
10
703 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
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
 
LVL 16

Expert Comment

by:Milleniumaire
ID: 24422646
Create the table first, then use an insert select statement to populate it.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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 73

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 73

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Join SQL view with APEX item as the join condition 4 47
Oracle Syntax 8 55
PL/SQL Search for multiple strings 5 39
'G_F01' is not a procedure or is undefined 3 12
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…
"Disruption" is the most feared word for C-level executives these days. They agonize over their industry being disturbed by another player - most likely by startups.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

912 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

15 Experts available now in Live!

Get 1:1 Help Now