Link to home
Start Free TrialLog in
Avatar of Rao_S
Rao_S

asked on

Can you help me resolve a ORA-01006?

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;
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image

Missing colon, here: ...   || lv_dbname
Avatar of flow01
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;
Is the schema name same as dblink ?
ASKER CERTIFIED SOLUTION
Avatar of MikeOM_DBA
MikeOM_DBA
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

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.
Avatar of Rao_S
Rao_S

ASKER

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...
Avatar of Rao_S

ASKER

thank you..