Solved

Can you help me resolve a ORA-01006?

Posted on 2013-12-12
8
488 Views
Last Modified: 2013-12-16
hi, i get a ORA-01006: bind variable does not exist  ..... error with this, from a packaged proc, can you please help me with this...

EXECUTE IMMEDIATE
            'select  oldest_backup_time,newest_backup_time  into :lv_oldest, :lv_newest from '
            || lv_dbname
            || '.'
            || 'rc_backup_set_summary'
            || '@'
            || 'LINK_ABCDEF '
            USING lv_oldest,lv_newest,lv_dbname;
0
Comment
Question by:Rao_S
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 29

Expert Comment

by:MikeOM_DBA
Comment Utility
Missing colon, here: ...   || lv_dbname
0
 
LVL 20

Expert Comment

by:flow01
Comment Utility
You are passing 3 variables (using ,,)  and defined 2 in your query :lv.

You can't pass however the databaselink name as a bind variable, so you must include it in the query text.

Try
lv_dbname := ' 'LINK_ABCDEF ';
EXECUTE IMMEDIATE
            'select  oldest_backup_time,newest_backup_time  into :lv_oldest, :lv_newest from '
            || lv_dbname
            || '.'
            || 'rc_backup_set_summary'
            || '@'
            || lv_dbname
            USING lv_oldest,lv_newest;
0
 
LVL 20

Expert Comment

by:flow01
Comment Utility
Is the schema name same as dblink ?
0
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 500 total points
Comment Utility
Ooops, miss-read the code.

Actually it should be:
EXECUTE IMMEDIATE
       'SELECT  oldest_backup_time, newest_backup_time 
          FROM '|| lv_dbname  || '.rc_backup_set_summary@LINK_ABCDEF '
          INTO lv_oldest, lv_newest; 

Open in new window

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 10

Expert Comment

by:HuaMinChen
Comment Utility
Try
EXECUTE IMMEDIATE
            'select  oldest_backup_time,newest_backup_time  into :lv_oldest, :lv_newest from '
            || lv_dbname
            || '.'
            || 'rc_backup_set_summary'
            || '@'
            || 'LINK_ABCDEF '
            USING lv_oldest,lv_newest;

Open in new window

0
 
LVL 29

Expert Comment

by:MikeOM_DBA
Comment Utility
1) Your query does not have and conditions and therefore will none of the posted variations will work unless the table has ONE row.

2) In the EXECUTE IMMEDIATE statement, the "USING" part is to supply bind variable values to the query and the "INTO" part is to receive results from the query.

3) Other than variables, in order to supply information that builds the query and which is contained in variables (like schema and/or table name and/or database link. etc...), you must CONCATENATE these variables to the query  text.
0
 

Author Comment

by:Rao_S
Comment Utility
hi flow, the schema name is not same as the link name, i tried to use the link name as a variable, but your script did not work...
hi mikeom_dba, i tried your scipt, and it worked thank you...
0
 

Author Closing Comment

by:Rao_S
Comment Utility
thank you..
0

Featured Post

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.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

743 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

17 Experts available now in Live!

Get 1:1 Help Now