Changing database links in query's

I'm currently using query's with a syntax like 'select * from table@dblink'. Works fine, however the dblink (DWHD1) should at some time in the future be changed so it points at the production instead of the development server (DWHD1 should become DWHP1). This could mean changing numerous queries by hand after importing in the production server.
I would rather like that this could be accomplished by changing a configuration item or something like that. Is there an easy way to accomplish this in APEX 3.0 by using a 'global variable' or..?
regards
Martin
Message was edited by:
mjb001

This can be done only if you create dynamic queries. A better way to solve this is not to
include any database links in your reports. Use Views and point them to a database.
Denes Kubicek

Similar Messages

  • Problems with Database Link in query

    When I run this code:
    SELECT NVL2(wbs1.wbs1_seq, wbs1.wbs1, pcn.pron) AS pron
         , h.fy AS data_fy
    FROM pcn_list@THE_LINK pcn
         JOIN project@THE_LINK x
         ON x.pcn_seq = pcn.pcn_seq
         JOIN
           SELECT h.project_seq
                , EXTRACT(year FROM (h.data_dt + 92)) AS fy
           FROM pcn_data@THE_LINK h
                JOIN setup@THE_LINK
                ON (
                     setup.data_dt = h.data_dt
                     OR (
                          EXTRACT(year FROM h.data_dt) > DECODE(setup.site, 'TYAD', 2006, 2007)
                          AND h.data_dt < setup.data_dt
                          AND TO_CHAR(h.data_dt, 'MMDD') = '0930'
                     OR (
                          EXTRACT(year FROM h.data_dt) BETWEEN 2000 AND DECODE(setup.site, 'TYAD', 2006, 2007)
                          AND TO_CHAR(h.data_dt, 'MM') = '09'
                          AND h.data_dt = NEXT_DAY(LAST_DAY(h.data_dt) - 7, 'FRIDAY')
           WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'
         ) h
         ON h.project_seq = x.project_seq
         LEFT JOIN wbs1_list@THE_LINK wbs1
         ON (
                wbs1.fiscal_yr = pcn.fiscal_yr
                AND (
                      wbs1.legacy_pron = pcn.pron
                      OR SUBSTR(wbs1.legacy_pron, 1, 2) || SUBSTR(wbs1.legacy_pron, 4) = pcn.pron
              OR (
                   TRIM(wbs1.legacy_pron) IS NULL
                   AND wbs1.wbs1 = SUBSTR(pcn.pron, 1, 2)
                                   || SUBSTR(TO_CHAR(wbs1.start_dt + 92, 'YY'), 1, 1)
                                   || SUBSTR(pcn.pron, 3, 1)
                                   || SUBSTR(pcn.mission, 1, 1)
                                   || SUBSTR(pcn.pron, 4, 5)
                                   || DECODE(
                                              SUBSTR(pcn.pron, 12, 1)
                                            , '0', SUBSTR(pcn.pron, 13, 2) || SUBSTR(pcn.pron, 13, 2)
                                            , SUBSTR(pcn.pron, 11, 4)
         LEFT JOIN xref_pron_command cmd1
         ON cmd1.command_cd = SUBSTR(pcn.pron, 11, 2)
         LEFT JOIN xref_pron_command cmd2
         ON cmd2.command_cd = SUBSTR(pcn.pron, 1, 2)
         LEFT JOIN mdms@THE_LINK mdms
         ON mdms.pron = SUBSTR(pcn.pron, 1, 8) || SUBSTR(pcn.pron, 11, 1)
         LEFT JOIN if_fedlog fedlog
         ON fedlog.fsc || fedlog.niin = SUBSTR(pcn.nsn, 1, 13)
         LEFT JOIN awpsammo@THE_LINK ammo
         ON ammo.pron = pcn.pron
         LEFT JOIN if_core_workload c
         ON (
              c.site = 'SITE'
              AND NVL2(wbs1.wbs1_seq, wbs1.wbs1, pcn.pron) = c.pron
              AND h.fy = c.data_fy
    WHERE pcn.mission != 'NOP'
    AND   x.pmc_cancel_fg = 'F'
    AND   NVL(wbs1.cancel_fg, 'F') = 'F'
    AND   NVL2(wbs1.wbs1_seq, wbs1.wpc, pcn.wpc) <> 'ZZ'I get:
    ORA-00904: "SETUP"."SITE": invalid identifier
    ORA-02063: preceding line from THE_LINK
    However, if I remove any of the cmd1, cmd2, fedlog, mdms, or ammo joins, it runs properly.
    It also runs properly if I remove both "WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'" (line 25) and "AND x.pmc_cancel_fg = 'F'" (third line from the end).
    Also, there are three different external sites; the problems happen on two of them, but on a third, the code works as is.
    The query also works if:
    * I remove the links and run it directly on the external sites
    * I add something that makes it return no rows immediately (for example, "AND 0 = 1" as the last line)
    * "WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'" is replaced by "WHERE h.data_dt = '30-SEP-09'" (which returns rows)
    * For that matter, at one of the problem sites, changing the first date in that WHERE clause to anything between '19-JUN-09' and '29-SEP-09' works, but '18-JUN-09' and earlier causes the error; at the other, the earliest working date is '02-NOV-08'.
    All three external databases, as well as the database on which this is run, are running 11.2.0.1.0 64-bit Production.
    Any ideas as to what is happening?

    sb92075 wrote:
    WHERE h.data_dt BETWEEN '01-SEP-06' AND '31-OCT-08'With Oracle characters between single quote marks are STRINGS!
    'This is a string, 2009-12-31, not a date'
    When a DATE datatype is desired, then use TO_DATE() function.Actually, usually I do (since there's no guarantee as to what the "default" date format will be - besides, the default tends to be 2-year dates). The one line where I don't is really just something I added to speed up the query when testing for the error.
    However changing that line to:
    WHERE h.data_dt BETWEEN TO_DATE('09/01/2006', 'MM/DD/YYYY') AND TO_DATE('10/31/2008', 'MM/DD/YYYY')causes the same results.

  • How to execute remote query by Oracle Database Link

    I use Oracle Database Link to query data from SQL Server. The query is like:
    select *
    from tableA@DL_SqlServer a
    join tableB@DL_SqlServer b
    on a.ID = b.ID*
    tableA and tableB is large and the result is relatively small. This query executes quickly in SQL Server since indexes are built both on the two tables. But it is very slow on Oracle Database Link to SQL Server.
    I guess the join operation is performed on Oracle side not on SQL Server side, thus the indexes are not used. Since I just need the joined result, I prefer to perform the query entirely on SQL Server and get the small result only. But I have no privilege to create views on SQL Sevrer.
    I konw that using SQL Server's linked server and OPENQUERY function can achieve this goal. I wonder how to do this on Oracle Database Link. Thanks!

    DO NOT DO THIS....specifically:
    "select *
    from tableA@DL_SqlServer a
    join tableB@DL_SqlServer b
    on a.ID = b.ID*"
    You would be better off to do the following:
    create a Materialized View in Oracle and once/day (or as frequently as you feel necessary) pull the data from SQLServer and then do the join locally by creating MV as TABLEA_MV and TABLEB_MV and then have views that have the REALTABLEA and REALTABLEB names that point to these MVs. This can be done without recompiling or changing your code. Trust me, I have seen this sort of thing in the past that completely crippled an IBM mainframe using DB2 along with a major network segment by having this sort of join via DB links. You must understand the ramifications of your "design" and I can tell you for certain that it is a very BAD!!! idea... Fix this before you are issuing another command: "alter DBA update resume/CV;"
    The app went into production at 7AM. By 9:30AM, the mainframe had executed more than 10Billion I/O's. It took > 15hrs for the mainframe to recover once we shutdown the app and implemented the view/MV described above.
    I will leave it as an excercise for the OP to develop the syntax for this.
    Edited by: onedbguru on Feb 15, 2013 7:27 PM

  • Database link works for OS user "oracle" but not for other clients

    My DBA connects as user1 to db1 and successfully queries over database link db2.
    [oracle@linux19 ODA]$ sqlplus user1/****@db1
    SQL*Plus: Release 11.2.0.3.0 Production on Fri Apr 12 07:39:49 2013
    Copyright (c) 1982, 2011, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> SELECT * FROM DUAL@db2;
    D
    XI log in from a Windows XP client and test the same database link with a ORA-12154 result.
    C:\>sqlplus user1/****@db1
    SQL*Plus: Release 11.2.0.1.0 Production on Fri Apr 12 11:18:18 2013
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> SELECT * FROM DUAL@db2;
    SELECT * FROM [email protected]
    ERROR at line 1:
    ORA-12154: TNS:could not resolve the connect identifier specifiedI can create and successfully use database links by including the full TNS entry in the USING string.
    What are some possible causes for the different results?
    What additional information might I supply to help troubleshoot?
    Thanks very much.
    - Doug
    Edited by: enquad on Apr 12, 2013 2:56 PM
    changed "database link db1" to "database link db2" per comments by SB
    Edited by: enquad on Apr 12, 2013 3:00 PM
    Changed "user" to "OS user" in subject for clarity

    enquad wrote:
    Sorry gentlemen and SB, but my question is still not answered. It is a new question, which I have not found answered elsewhere.
    To summarize:
    SB97025 informs me that db1 is not a database link, but I never said that it was. It is the second database (anonymized as "db2") that is connected to through the database link "db2.mycompany.net".
    SB97025 also wonders intriguingly if my DBA and I are we really connecting to the same database when we each connect to user1 on db1. Perhaps the Oracle server and my PC have TNSNAMES.ORA files that lead us to different databases for the same TNS alias? I do not believe this is the case, because my DBA created that user1 and that database link in the db1 database specifically for the purpose of doing this test and I see that same link when I connect to user1 on db1. Unless my DBA is spoofing me by creating user1 in two different databases - only one of which contains a working dblink named db2.mycompany.net - just for the purpose of throwing me off, I would have to conclude that he and I are actually connecting to the same database.There is no reason to "believe" (or not) that "this is the case". The entire point of SB's comment on that was to get you to verify. President Reagan famously said "trust but verify". He never worked as a DBA. I say "don't trust, just verify".
    Obviously something is different. And at this point the most likely and easiest to confirm is that you and your DBA really are connecting to the same database, on the same host server, using the same link. And at this point all we really have is to trust your DBAs statement.
    >
    Ed Stevens reminds me that db1 is acting as a client to db2 and so the solutions to the ORA-12154 are the same as for any client connection as listed on his blog (which I had already read), none of which solve my problem. Rembember, the DBA can use the database link, so by whatever means the TNS lookup is happening when he uses it, the correct connection description is being found. The question is not "why does this stinkin' database link not work"? It does work for the DBA.
    Pierre wants to make sure I know that it is the Oracle server's TNSNAMES file that is the important thing, not my client's TNSNAMES file, which is true but not relevant to my problem and I was never so naive. He also says that I could try creating a database link by including the full TNS entry in the USING string, which does work as I had already mentioned in my original post.
    Amar asks if my DBA can: sqlplus username/password@db2.
    The answer is yes. The dba can use SQL*Plus to connect to db2 from the server hosting db1 and can connect to db1 from the server hosting db2. There is almost nothing my DBA cannot do.
    None of the posters addressed the key information in my post, which was the different result my DBA and I get when using the same database link in the same schema on the same database. That AND the fact that my DBA is logged on to Linux Oracle serve as user "oracle" and I am logged in to my PC. Why should it matter to a database link which computer is running SQL*Plus or who the OS user is?
    Also the GLOBAL_NAMES parameter is set to FALSE.
    - Doug

  • Problems with query via Database-Link (Oracle 7.3.4)

    I made the following simple query via database-link.
    select count (*) from [email protected]
    I got the result in about 200 miliseconds.
    Then I4ve tried the following query.
    select * from [email protected]
    It took about 2 hours end ended with an error message "ORA-03113: end-of-file on communication channel"
    So I made another choice
    select * from [email protected] where rownum <=1
    Took about 200 miliseconds.
    So I made the query again an changed only the number of rownums,until I was at rownum <=8
    then it went sleeping again(I've canceled the statement because I didn't want to wait 2 hours again).
    We made the same things from another server with the same database-link on the same remote server
    and we had no problems.
    Any Idea???

    No, network is OK!
    Other links are running, I have also no problems when I connect directly to the remote server.

  • Change of a database link in OWB

    I have a good suggestion to change a a database link when a server is moved to another location (in that case the database link of the source module has to be changed)
    In OWB 9.0.2 it's not impossible to delete a database link in OWB, so you have to do it manually
    (in 9.0.4 it should be possible, but this version is also not easy to use).
    - Start SQL Plus and log in as the schema on which the OWB repository is created (e.g. OWB).
    - Drop the database link ('drop database link <dblink name>')
    - Create a new database link in the same schema with the new parameters, e.g:
    CREATE DATABASE LINK "<dblink name>"
    CONNECT TO "<...>" IDENTIFIED BY "<...>"
    USING '(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (Host = <hostname>) (PORT = 1521))) (CONNECT_DATA = (SID = <sid> )))'
    Done!
    No stupid errors in OWB when you create the database link in OWB itself.
    Regards,
    Maurice
    ;

    SQL> create view test_view as select dummy from [email protected]
    2 ;
    View created.
    SQL> select dummy from test_view;
    D
    X
    Execution Plan
    0 SELECT STATEMENT (REMOTE) Optimizer=CHOOSE
    1 0 TABLE ACCESS (FULL) OF 'DUAL' FIRST9.XXXX.COM
    Statistics
    7 recursive calls
    4 db block gets
    2 consistent gets
    0 physical reads
    212 redo size
    363 bytes sent via SQL*Net to client
    425 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    NOW WE PULL OUT THE NETWORK CABLE connecting the two servers.
    SQL> select dummy from test_view;
    select dummy from test_view
    ERROR at line 1:
    ORA-02068: following severe error from FIRST9.XXXX.COM
    ORA-03113: end-of-file on communication channel
    So all you have to do is to test for the communications error.

  • Variable database name in SQL Server query using Oracle database link

    Hi All,
    I have an ApEx 4.1 app running on 11g x64 (11.2.0.1) on Windows Server 2008 x64, and I have some data integration points with a SQL Server (2005 and 2008) that I need to establish. I have configured the database link with dg4odbc and it works beautifully... I can execute queries against the SQL Server database without any problems using the database link.
    However, there is a scenario where the SQL Server database name is dynamic, and I need to generate it on the fly in a PL/SQL block, and then use that in a dynamic SQL query (all of this in ApEx). This is where I run into problems... when I am querying the default database based on the ODBC connection and I don't have to specify the database name, there is no issue. But when I need to access one of several other non-default databases, I keep receiving the "invalid table" error.
    This runs fine:* (note that "fv" is the name of my database link)
    v_query1 := 'select "ReleaseDate" from dbo.Schedules@fv where dbo.Schedules."SchedID" = :schedule';
    EXECUTE IMMEDIATE v_query1 into rel_date using schedule;
    I then take that rel_date variable, convert to a varchar2 (rel_date_char), and then use it as the database name in the next query...
    This returns an error_ (Error ORA-00903: invalid table name)
    v_query2 := 'select "PARTNO" from :rel_date_char.dbo.ProdDetails@fv where "SchedID" = :schedule and "UnitID" = :unit
    and "MasterKey" = :master and "ParentKey" = :parent';
    EXECUTE IMMEDIATE v_query2 into part_number using schedule, unit, master, parent;
    I have also tried using all of the following to no avail:
    'select "PARTNO" from ' || :rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from ' || rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from ' || @rel_date_char || '.dbo.ProdDetails@fv where "SchedID"...
    'select "PARTNO" from @rel_date_char.dbo.ProdDetails@fv where "SchedID"...
    Is there a way to do this in PL/SQL?
    Thanks for any help!
    -Ian C.
    Edited by: 946532 on Jul 15, 2012 7:45 PM

    Just did a test using passthrough:
    SQL> set serveroutput on
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 begin
    6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from EMP');
    8 LOOP
    9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    10 exit when nr=0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    12 dbms_output.put_line(val);
    13 end loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    15 end;
    16 /
    24576
    PL/SQL procedure successfully completed.
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 begin
    6 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'select count(*) from dbo.EMP');
    8 LOOP
    9 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    10 exit when nr=0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    12 dbms_output.put_line(val);
    13 end loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    15 end;
    16 /
    24576
    PL/SQL procedure successfully completed.
    So all 3 ways work for me.
    Edited by: kgronau on Jul 23, 2012 10:08 AM
    Now using variables to perform the select:
    SQL> declare
    2 val varchar2(100);
    3 c integer;
    4 nr integer;
    5 tabname varchar2(20) :='EMP';
    6 ownr varchar2(20) :='dbo';
    7 dbname varchar2(20) :='gateway';
    8 begin
    9 c:= dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    10 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 'SELECT count(*) FROM '||dbname||'.'|| ownr || '.'||tabname||'');
    11 LOOP
    12 nr:= DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    13 exit when nr=0;
    14 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c,1,val);
    15 dbms_output.put_line(val);
    16 end loop;
    17 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3(c);
    18 end;
    19 /
    24576
    PL/SQL procedure successfully completed.
    => instead of executing the statement using "execute Immediate" we have to use PASTHROUGH package to pass the statement to the SQL Server.
    Edited by: kgronau on Jul 23, 2012 10:10 AM

  • Query builder: tables from Database Link

    Hi APEX people,
    Is there a way to use tables from a (remote) Database Link in the Query Builder?
    In the Query Builder I seem to have only access to locally (schema) stored tables.
    I already tried to define a Synonym for the remote tables I wanted to use, but that didn't work either.
    Thanks in advance.
    Maurice

    Hi,
    First of all, can you select from them ie
    SELECT  *
    FROM my_table@my_linkAlso you can't see them as tables in the schema because they're not tables in the schema.
    Try creating a view like...
    CREATE OR REPLACE FORCE VIEW m_table_vw AS
    SELECT *
    FROM my_table@my_link;You should be able to see the view in the schema in the query builder and use that.
    Cheers
    Ben

  • Query to table in Database Link returns value from local table

    Hi
    I made a databaselink (Create database link db_a.world connect to db_a identified by <user> using 'db_a.world')
    Then I query a table, connected as a user in db_b.world (this is our developer database - identical to db_a): Select count(*) from table@db_a.world.
    When I get the result - it comes from the database I am logged in to (db_b)! - This is easy to check, because when I run select count(*) from table - it shows the same number. When I connect to the remote database, the same query shows another (correct) number.
    When I created the database link, Oracle demanded a loopback clause. Why is that, and can this be the reason for the strange behaviour?
    Thanx
    Anders
    Narvik, Norway

    Hi Anders,
    A loopback database link is when you want to test connecting to the same database as say a different user. It can be used for testing purposes. Creating a database link doesn't require a loopback clause. The reason why you are getting the same row count as db_b.world because db_a.world has been created as a loopback link.
    In the example you have Create database link db_a.world connect to db_a identified by <user> using 'db_a.world' , the clause after 'connect to' is meant to be the username and the clause after 'identified by' is meant to be the password.
    So, create a regular database link like this:
    create database link db_a_link connect to <user> identified by <passwd> using <service name>
    You shouldn't get an error message that the loopback clause has to be specified. Then try querying and hopefully it will work.
    -Raj

  • Frm-40208 from running in query mode. cannot change database fields

    Hi,
    Could some one help me with this.
    I am calling a form from another form. I am passing the parameter list to the calling form and doing a query by setting the block property. But when queries the message
    FRM-40208 Form running in query mode. cannot change database fields .
    I do not want the message to appear when they go the called form . Please some one could help me how could I avoid displaying the message.
    Regards
    Bain

    Hi,
    Good day! I am working with a module that also calls another form. It uses call_form with query mode parameter set to query_only. My problem is, whenever i call the other form using the call_form, it would display the called module and then as it populates the detail block of the called form, it will display frm-40208 from running in query mode. cannot change database fields per record. What I want is for the message to be displayed only once.
    I have tried capturing the error by using on-error trigger, but it doesn't go to that whenever the other form was being called. I think the message has to do with the post-query trigger, because it passes some values on a dbase block objects.
    Do you have any suggested solutions or workarounds to make the message display only once whenever the other form is being invoked by the call_form?
    I would greatly appreciate any suggestions/ideas.
    Thanks and regards,
    ASantiago

  • FRM-40208: Form running in query-only mode. Cannot change database fields.

    Hi,
    I am using forms 6i where it is calling a form from a menu in query like call_form(,query_only). Now an error is occurring on call of that form ‘FRM-40208: Form running in query-only mode. Cannot change database fields.’ Though this is been handled to give a certain message from on_error message from a package from library.
    Now the issue is that the error keeps on popping even after the ok button is pressed. There are number of records from the table. How can we handle the error. Any suggestion would be really appreciated!!!
    Regards,
    Rajesh

    thanks Gred but i have resolved the issue. it seems that each row was going into query_only mode (program written such a way). therefore the error was showing even after the OK button. handled the issue from ON_ERROR trigger. anyway thanks for your time Gred!

  • Query to find database links of  a user

    hi all,
    can anyone please help me in finding out thro a query that how many database links are associated with a user.

    select * from dba_db_links where owner = 'Bill Gates';

  • Same sql query with multiple database links

    Hi All,
    i want to execute an sql query for a SELECT LIST Item. which should use database links in it's query.
    i'm having a list of database links in the region. say :LOC which is having 10 items each linking to different databases.
    i want to use following query for another item in same page.
    select customer_name from working_lines@:LOC where
    phone_no:phone_no
    can i do this.
    Thank you All.

    What we have done before is to create a report based on a PL/SQL procedure that returns a SQL statement.
    The PL/SQL code grabs the "selected" database link from :LOC and parses the SQL QUERY you want to execute replacing some token (like [LINK]) with '@DBNAME'.
    Lets say your SQL statement is coded like this:
    mySQL := 'SELECT cust_name FROM working_lines[LINK] where phone_no = :Phone;'
    Then all you would have to do to replace '[LINK]' with the proper DB alias would be:
    mySQL := REPLACE(mySQL, '[LINK]', '@'||:LOC);
    and then return the new SQL ...
    if :LOC has something like 'V10GPROD' your SQL would look like :
    SELECT cust_name FROM working_lines@V10GPROD where phone_no = :Phone;
    The beauty of this is that you can also include a "null" option that means the select statement will be executed on THIS database...
    Doug

  • Query a remote table with Database Links

    How do database links work with ODP.NET? The following code produces an "ORA-02041: client database did not begin a transaction" error on the Fill method.
    SQL (in acme instance):
    CREATE DATABASE LINK sales.hq.acme.com
    CONNECT TO scott IDENTIFIED BY tiger
    USING 'sales'
    VB .NET:
    Dim cn As New OracleConnection("Data Source=acme;User ID=scott;Password=tiger;")
    Dim da As New OracleDataAdapter("SELECT * FROM [email protected]", cn)
    Dim ds As New DataSet
    da.Fill(ds, "RemoteEmp")

    Just read running procedure on remote db???
    Changed first line to
    Dim cn As New OracleConnection("Data Source=acme;User ID=scott;Password=tiger;Enlist=false")
    and it works now.
    That's what I get for searching the forum instead of browsing.

  • Query the column names from Public database links

    Greetings,
    I would like to retrieve the list of all the column names from a public database link. A regular ALL_TAB_COLUMNS doesn't seem to be working.
    Thanks
    John9569

    Hi,
    I think your DBA needed to create a synonym for you to have access of that remote database view.
    CREATE SYNONYM synonym_name
    FOR view_name@db_link;Then you can find the column names by
    DESC   synonym_nameGuru's , please correct me If I am wrong.
    Thanks
    Edited by: user10679113 on Mar 12, 2009 12:28 PM
    Edited by: user10679113 on Mar 12, 2009 12:33 PM

Maybe you are looking for

  • HT5704 I have a iphone 3G. How do I upgrade the IOS . My email no longer works and I get a message to upgrade my IO

    How do I upgrade the IOS in my 3G iphone using the usb cable hooked to my computer ?

  • Download Not Working

    After installing Adobe Download Assistant, signing in and selecting Photoshop CS5.1, nothing happens.  I have refreshed; exitied; removed ADA and reloaded it, but can not get beyond the sign-in screen.  Using Windows 7 on a 64-bit machine.

  • AlwaysOn Management Pack not functioning - SCOM 2007R2

    Hi all I am a DBA but am new to SCOM and have been trying to get the AlwaysOn Management pack to work.  I manually installed some agents on the 2 boxes I want to manage and can see they are being monitored in the inventory. The management pack was al

  • Html code without be interpreted

    Hi, How can I write html code without be interpreted. I want to write a header like: * @param html A text like <div>hello</div> and I want that JavaDoc doen't interprets <div> as HTML. How can I do it? Thanks a lot for helping me :) Cheers

  • Blank screen 6680

    hi can anyone tell me if there is anything i can do to cure my problem with my 6280 it makes calls, recieves calls and has sound but all i get is a blank screen,please help