Find database name of sessions over database link

Hi,
I have a database in which i can see a few sessions which are connected to this database from one of my server which is hosting 2 databases. Now if i query v$session on my local database, i can only find the host name in program and module column of v$session view. How can i find out that from which database these sessions are established because i have two databases on that remote host from where these sessions are estableshed.
Thanks
Salman

only way is if i have set the client info.alternatively application info.
I've never tried the following, but perhaps using different LISTENER or port could be used as a differentiator.
Keep in mind that what the local DB server "knows" is it serviced some connection request from remote client.
Local DB server knows little to nothing about any remote DB masquerading as a client connection.
This is an application issue not Oracle RDBMS issue.

Similar Messages

  • Problem establishing SNA session over DLSw link

    We are experiencing sporadic problems establishing an SNA session over a DLSw tunnel. The session is between a Tandem host and a CICS region on OS/390. A Cisco 7500 router performs one end of the DLSw link; that same router is channel-attached to the OS/390 mainframe using CIP and uses CSNA for SNA traffic.
    The connection is initiated by the SNA software on the Tandem box, but it rarely works on the first attempt. The session goes into a pending state and has to be cancelled and re-tried. This has to be repeated until such time it is successful. Once the session is started it works without problem.
    At the point of attempting to start the session all the components are in the 'correct' state, i.e.
    -DLSw tunnel is connected
    -Host PU is in 'connectable' (CONCT) state
    -Host XCA defining CIP SNA and virtual lines are active
    No action needs to be taken on the OS/390 end of the link (or anywhere else for that matter) between start attempts on Tandem.
    From device traces on OS/390 my suspicion is that the session requests are not actually getting to VTAM on OS/390 for some reason. DLSw traces on 7500 appear the same in both case of success or fail of session start.
    Has anyone experienced this, or know of problems in this area that may explain what we are seeing?
    Thanks.
    Keith

    Mary,
    thanks for the extra information.
    I would advice at this point the following:
    Open a case with the Tac. Provide the information you have at that point and agree on a action plan, i.e. what to look at what trace to take, when you are able to recreate the problem.
    What i can see from the documents you attaches is the following:
    I only see sna circuits in the dlsw circuit history.
    In you show dlsw reach there are quite some netbios names aswell and a large number of mac addresses learned from the remote peer.
    You may want to discuss some filter options with the tac to make sure we cut down on the size of the reach cache and to make sure we advertise only those mac addresses which are really needed.
    From the show version, 12.1(17) should be fine for dlsw in the way you described it.
    From the show dlsw circuit history detail we have a couple of times that circuits are disconnecting.
    Most of the time these circuits are up for a long time and they get the following sequence before terminating:
    Index local addr(lsap) remote addr(dsap) remote peer
    1157627904 4000.0410.0001(08) 0800.8e00.9708(08) 10.19.2.124
    Created at : 12:02:55.115 GMT Mon Nov 29 2004
    Connected at : 12:02:55.447 GMT Mon Nov 29 2004
    Destroyed at : 22:04:01.158 GMT Wed Dec 1 2004
    Local Corr : 1157627904 Remote Corr: 3321888773
    Bytes: 140092/145133 Info-frames: 1748/2327
    XID-frames: 1/2 UInfo-frames: 0/0
    Flags: Remote created, Local connected
    Last events:
    Current State Event Add. Info Next State
    CONNECTED DLC DataInd 0x0 CONNECTED
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED DLC DataInd 0x0 CONNECTED
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED DLC DataInd 0x0 CONNECTED
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED DLC DataInd 0x0 CONNECTED
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED DLC DataInd 0x0 CONNECTED
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED DLC DataInd 0x0 CONNECTED
    CONNECTED ADM WanFailure 0x0 HALT_NOACK_PEND
    HALT_NOACK_PEND DLC DiscCnf 0x0 CLOSE_PEND
    CLOSE_PEND DLC CloseStnCnf 0x0 DISCONNECTED
    this circuit was up for more than a month and the reason for disconnection was ADM WAN failure which means the dlsw peer went away at some point.
    Some other circuits get these sequence:
    CONNECTED WAN infoframe 0x0 CONNECTED
    CONNECTED WAN halt-dl 0x0 HALT_PENDING
    WAN halt-dl means the other end tells us to disconnect. No information on this end why. Most of the time it is a legitimate disconnect. but you would need to look at the dlsw peer to get information who terminated the session.
    I dont see anything specific in a sense that a circuit did not go to connect at all. In the information you supplied.
    Again my advice open a case with the tac and then you can work the issue to completion.
    thanks...
    Matthias

  • Finding NLS_LANG of a Session from Database

    Hi
    Is there any way to find the NLS_LANG of a particular session?
    Regards
    GS

    No "standard" function returning client character set (at least I didn't find one), but we can use Java, if this is not a problem for you. See http://www.oracle-base.com/articles/8i/ShellCommandsFromPLSQL.php
    $ echo $NLS_LANG
    AMERICAN_AMERICA.WE8MSWIN1252
    $ sqlplus scott/tiger
    SQL*Plus: Release 10.1.0.3.0 - Production on Wed Oct 19 10:27:44 2005
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select sys_context('userenv','language') from dual; -- DB character set
    SYS_CONTEXT('USERENV','LANGUAGE')
    AMERICAN_AMERICA.WE8ISO8859P15
    SQL> SET SERVEROUTPUT ON SIZE 1000000
    SQL> CALL DBMS_JAVA.SET_OUTPUT(1000000);
    Call completed.
    SQL> exec Host_Command ('echo $NLS_LANG'); -- Client character set
    AMERICAN_AMERICA.WE8MSWIN1252
    PL/SQL procedure successfully completed.
    SQL>                                                                                                                     Of course this solution is generic, and can be used for any OS command from Pl/Sql.

  • How do I find out my Database name

    Hi All,
    I have recently installed Oracle 10g Express Edition for Windows. Its working well but when I tried to login into my Oracle Discoverer Administration, I was asked to type in the database name in the connect filed.
    Can anyone tell me if I can use Disco Administration with Oracle 10g Express Edition? Also how do I find out my database name in the TSN file.
    Your reply would highly appreciated.

    Hi,
    The "Database Name" is actually your Database SID or the Service Name. If you have installed XE, it would be XE by default. You can check this out in Control Panel -> Services - you will notice an ORCL Service with the name appended with XE.
    XE does not come with the OLAP or Data Mining or Partitioning options & you can't use Oracle Discoverer OLAP. You can have a look at a post on the Oracle Business Intelligence Blog for more information :-
    http://oraclebi.blogspot.com/2005/11/oracle-xe-database-and-discoverer-1.html
    Regards,
    Sandeep

  • Can we enable Database Name box while scheduling report

    Hi, I am boxi administrator and I am working on a unique client requirement. I don't know if it needs to be in administration forum or crystal reports.   we are using crystal reports  and  We are on boxi R2 SP3 on IIS.
    We have 8 DB servers for load balancing ( look www.intersystems.com for details of how). We want to publish report in BOXI and user will then schedule report. We don't want multiple copies as it will be difficult to maintain at several places. So please rule out the possibility of  8 copies of same Crystal report connected to each 8 DB servers.
    When user schedules report then we want to load balance the DB servers i.e. we have defined 8 ODBC connections on each application servers and want to use all ODBC ( DB) for each report. When we schedule reports then I see server name and Database name is disabled in Database logon properties.
    Please let me know if this  is possible. We will be using standard infoview to schedule reports.
    Thanks,

    This is not feasible. I figured out one option that is using Virtual IP with Load balancer. We can load balance ODBC using this. This is tested in another project of state govt.
    Thanks,

  • Inactive sessions increasing database

    Hi
    We are using oracle11.5.10.2 on windows 2000 server and database version 10.2.0.3
    we are facing problem with inactive sessions,grdually inactive sessions increasing and thats leads database crash.
    Temporary i increased processes parameter value tp 400 prviously it was 200
    Most of inactive session from apps user only
    How can i fix this problem?
    Thanks
    With Regards
    OH

    Hi,
    Please see these threads.
    how to kill inactive sessions????????
    how to kill inactive sessions????????
    Inactive sessions in Database
    Re: Inactive sessions in Database
    Regards,
    Hussein

  • Global Database Name for OCS Database

    Hi guys,
    The domain name for the network that I'm installing OCS 10g have a dash in the domainname. When installing the OCS database, it stated that the global database name cannot have a dash. So I change the dash in domain name of the server with an underscore.
    After restart the installation, and putting the global database name with a underscore, the installation is sucessfull. My question is if I change back the server domain name back to include the dash, will this affect the running of the database ? and after the installation can I changed the global database name to include the dash ?
    Thanks for any info.
    Regards
    Lanang

    I was looking in the wrong place. I found the right documentation. Thanks all.
    Rename the global database name using an ALTER DATABASE statement. For example, enter:
    ALTER DATABASE RENAME GLOBAL_NAME TO sales.us.oracle.com;

  • Incorrect Standby Database name in V$database

    I'm trying to create a standby database (mptstb on server mptdb2) from a primary database (mptpr on server mptdb1). I create the standby controlfile on the primary database using the 'alter database create standby controlfile...' and then move it to the standby server. When I do a startup mount of the standby database and check the contents of the v$database view, it shows name=mptpr. It should be mptstb. When I try to run RMAN on the standby (rman target /), it connects to target MPTPR and not mptstb. I cannot figure this one out. Any help would be greatly appreicated.

    The database name for the standby database is the same (but using NID utility there is a chance to change the database name).
    You can use service names to connect to the standby and lock_name_space (Oracle 9i)/db_unique_name(Oracle 10g) to differ databases using different names.
    That might be the case for databases on the same server. But if you use different servers you can use the same database name.
    Andrey

  • Cannot connect to sys giving the database name

    Hello All,
    I cannot connect to sys user when giving the database name but with no database name I can connect.
    [oracle@ccoshs02xvdbs04 trace]$ sqlplus sys/passwdA123system@mps01dev as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 1 10:38:36 2011
    Copyright (c) 1982, 2009, Oracle. All rights reserved.
    ERROR:
    ORA-01017: invalid username/password; logon denied
    Enter user-name:
    ERROR:
    ORA-01017: invalid username/password; logon denied
    Enter user-name:
    ERROR:
    ORA-01017: invalid username/password; logon denied
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    [oracle@ccoshs02xvdbs04 trace]$ sqlplus sys/passwdA123system as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 1 10:40:06 2011
    Copyright (c) 1982, 2009, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> show parameter instance
    NAME TYPE VALUE
    active_instance_count integer
    cluster_database_instances integer 1
    instance_groups string
    instance_name string mps01dev
    instance_number integer 0
    instance_type string RDBMS
    open_links_per_instance integer 4
    parallel_instance_group string
    parallel_server_instances integer 1

    [oracle@ccoshs02xvdbs04 script]$ sqlplus sys/passwdA123system as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 1 11:19:47 2011
    Copyright (c) 1982, 2009, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> alter user sys identified by passwdA123system
    2 ;
    User altered.
    SQL> connect sys/passwdA123system@mps01dev
    ERROR:
    ORA-28009: connection as SYS should be as SYSDBA or SYSOPER
    Warning: You are no longer connected to ORACLE.
    SQL> exit
    [oracle@ccoshs02xvdbs04 script]$ sqlplus sys/passwdA123system@mps01dev as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Mar 1 11:21:15 2011
    Copyright (c) 1982, 2009, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    Many thanks.

  • What is the Global Database Name for?

    Hi All,
    I installed 10g on Linux and it seems to work ok. But I used the same string "abc" for the SID and the global database name (GDN). The recommendation for the GDN was sid.domain_name.com but I didn't know the domain_name at the time.
    I don't know why the GDN exists or what it is used for. I am wondering how this lame GDN will affect the database and if there is an easy way to change it. I don't expect that we will be using the db outside of our little network, no internet users. Will users on other machines be able to connect to my db?
    Thanks

    I was looking in the wrong place. I found the right documentation. Thanks all.
    Rename the global database name using an ALTER DATABASE statement. For example, enter:
    ALTER DATABASE RENAME GLOBAL_NAME TO sales.us.oracle.com;

  • How to find the logins,program name and databases for a session id?

    I used the following the following query.
    select pr.spid ,pr.dbid,pr.program_name,pr.loginame,ss.session_id,ss.host_name,ss.login_time,db.name from master.dbo.sysprocesses pr,sys.dm_exec_sessions ss,sys.databases db
    where pr.spid = ss.session_id and pr.dbid = db.database_id
    order by ss.login_time desc
    Is spid in master.dbo.sysprocesses the same as session_id in sys.dm_exec_sessions and dbid in master.dbo.sysprocesses the same as database_id in sys.databases?
    My intention is to get the active sessions with the program name,login Name and database name corresponding to the session?

    1)Why you included the clause session_id > 50?
    Sessions with session_id <= 50 are system processes.
    2)Is there any problem with the query I used?
    You query was better than Latheesh's. To wit, his query will only show the database for sessions who are actually running something.
    On SQL 2005 and SQL 2008, this is the best solution:
    SELECT  des.session_id, des.[status], des.login_name,
            d.name AS database_name, des.program_name
    FROM    sys.dm_exec_sessions des
    JOIN    sys.sysprocesses p ON des.session_id = p.spid
    LEFT JOIN sys.databases d ON p.dbid = d.database_id
    WHERE   des.session_id > 50
      AND   p.ecid =0
    ORDER BY des.session_id;
    The condition p.ecid = 0 is needed to weed out extra rows when there are parallism in force.
    On SQL 2012, you don't need sysprocesses, but this works:
    SELECT  des.session_id, des.[status], des.login_name,
            d.name AS database_name, des.program_name
    FROM    sys.dm_exec_sessions des
    LEFT JOIN sys.databases d ON des.database_id = d.database_id
    WHERE   des.session_id > 50
    ORDER BY des.session_id;
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Interactive report performance problem over database link - Oracle Gateway

    Hello all;
    This is regarding a thread Interactive report performance problem over database link that was posted by Samo.
    The issue that I am facing is when I use Oracle function like (apex_item.check_box) the query slow down by 45 seconds.
    query like this: (due to sensitivity issue, I can not disclose real table name)
    SELECT apex_item.checkbox(1,b.col3)
    , a.col1
    , a.col2
    FROM table_one a
    , table_two b
    WHERE a.col3 = 12345
    AND a.col4 = 100
    AND b.col5 = a.col5
    table_one and table_two are remote tables (non-oracle) which are connected using Oracle Gateway.
    Now if I run above queries without apex_item.checkbox function the query return or response is less than a second but if I have apex_item.checkbox then the query run more than 30 seconds. I have resolved the issues by creating a collection but it’s not a good practice.
    I would like to get ideas from people how to resolve or speed-up the query?
    Any idea how to use sub-factoring for the above scenario? Or others method (creating view or materialized view are not an option).
    Thank you.
    Shaun S.

    Hi Shaun
    Okay, I have a million questions (could you tell me if both tables are from the same remote source, it looks like they're possibly not?), but let's just try some things first.
    By now you should understand the idea of what I termed 'sub-factoring' in a previous post. This is to do with using the WITH blah AS (SELECT... syntax. Now in most circumstances this 'materialises' the results of the inner select statement. This means that we 'get' the results then do something with them afterwards. It's a handy trick when dealing with remote sites as sometimes you want the remote database to do the work. The reason that I ask you to use the MATERIALIZE hint for testing is just to force this, in 99.99% of cases this can be removed later. Using the WITH statement is also handled differently to inline view like SELECT * FROM (SELECT... but the same result can be mimicked with a NO_MERGE hint.
    Looking at your case I would be interested to see what the explain plan and results would be for something like the following two statements (sorry - you're going have to check them, it's late!)
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two),
    sourceqry AS
    (SELECT  b.col3 x
           , a.col1 y
           , a.col2 z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5)
    SELECT apex_item.checkbox(1,x), y , z
    FROM sourceqry
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two)
    SELECT  apex_item.checkbox(1,x), y , z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5If the remote tables are at the same site, then you should have the same results. If they aren't you should get the same results but different to the original query.
    We aren't being told the real cardinality of the inners select here so the explain plan is distorted (this is normal for queries on remote and especially non-oracle sites). This hinders tuning normally but I don't think this is your problem at all. How many distinct values do you normally get of the column aliased 'x' and how many rows are normally returned in total? Also how are you testing response times, in APEX, SQL Developer, Toad SQLplus etc?
    Sorry for all the questions but it helps to answer the question, if I can.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • Report over database link error

    Good morning all.
    I have a database link LINKA from USERA on LOCALSERVER to USERB on REMOTESERVER.
    (create database link LINKA connect to USERB identified by mypassword using validtns)
    In USERC on REMOTESERVER I have a TABLEX, with grant all on TABLEX to USERB on REMOTESERVER.
    In USERB on REMOTESERVER I have a view TABLEXV, select * from USERC.TABLEX
    From USERA on LOCALSERVER I can select * from TABLEXV@LINKA. In fact I can insert/update/delete tablexv from USERA.
    I also have a view TABLEXV on USERA, select * from TABLEXV@LINKA. I can also select/insert/update/delete from USERA.TABLEXV.
    So far so good - all working as expected.
    Then, my APEX app on LOCALSERVER, interactive report, parsing schema USERA, querying TABLEXV, I get the following:
    when "Exclude Link Column", I get the error "The requested URL /pls/apex/f was not found on server.
    when "Link to Single Row View", report displays correctly.
    when "Link to Custom Target", I get the error "The requested URL /pls/apex/f was not found on server.
    When I run the select * from TABLEXV as a regular report (i.e. not interactive), I also get the error.
    So the only time I get the report displayed correctly is using IR and "Link to Single Row View".
    However, clicking on the link (for Single Row View) I get "The requested URL /pls/apex/wwv_flow.show was not found on this server.".
    To summarize:
    - accessing table via view over database link
    - works outside of apex without issue
    - inside only works when Link to Single Row View set
    - But clicking on link fails
    I could live with just having the Link to Singe Row View option if I could disable displaying of the icon so that the user cant click on it.
    APEX 3.2.00.27
    EE Database - 10.2.0.3 (yes I know out of support)
    Remote EE Database - 10.2.0.5
    Real object names replaced to protect the innocent!
    Anyone got any clues?
    I have used remote tables many times in my APEX applications and never had this issue.
    Thanks,
    Rob @ very confused .com

    Good morning all.
    I have a database link LINKA from USERA on LOCALSERVER to USERB on REMOTESERVER.
    (create database link LINKA connect to USERB identified by mypassword using validtns)
    In USERC on REMOTESERVER I have a TABLEX, with grant all on TABLEX to USERB on REMOTESERVER.
    In USERB on REMOTESERVER I have a view TABLEXV, select * from USERC.TABLEX
    From USERA on LOCALSERVER I can select * from TABLEXV@LINKA. In fact I can insert/update/delete tablexv from USERA.
    I also have a view TABLEXV on USERA, select * from TABLEXV@LINKA. I can also select/insert/update/delete from USERA.TABLEXV.
    So far so good - all working as expected.
    Then, my APEX app on LOCALSERVER, interactive report, parsing schema USERA, querying TABLEXV, I get the following:
    when "Exclude Link Column", I get the error "The requested URL /pls/apex/f was not found on server.
    when "Link to Single Row View", report displays correctly.
    when "Link to Custom Target", I get the error "The requested URL /pls/apex/f was not found on server.
    When I run the select * from TABLEXV as a regular report (i.e. not interactive), I also get the error.
    So the only time I get the report displayed correctly is using IR and "Link to Single Row View".
    However, clicking on the link (for Single Row View) I get "The requested URL /pls/apex/wwv_flow.show was not found on this server.".
    To summarize:
    - accessing table via view over database link
    - works outside of apex without issue
    - inside only works when Link to Single Row View set
    - But clicking on link fails
    I could live with just having the Link to Singe Row View option if I could disable displaying of the icon so that the user cant click on it.
    APEX 3.2.00.27
    EE Database - 10.2.0.3 (yes I know out of support)
    Remote EE Database - 10.2.0.5
    Real object names replaced to protect the innocent!
    Anyone got any clues?
    I have used remote tables many times in my APEX applications and never had this issue.
    Thanks,
    Rob @ very confused .com

  • Database link in forms is different that actual database name

    I am using a database link in Oracle Forms 6i, however, the database link name for the referenced database is not the same as the actual databse service/instance name.
    It does not work, and I suppose its something to do with the global names feature which is true in the source database it is in a replication group.
    I would like to know whether the dblink name which I am using in oracle forms, does it have to have the same name as an entry in the tnsnames.ora file, or can be substituted thgrough any so-calld alias from within oracle forms?
    Windows 2k Ad svr, Oracle Forms 6i, DB 9.2.0.1

    I recently upgraded my development environment from Forms 10.1.2.0.2 to Forms 10.1.2.3 and am experiencing the same problem -- not able to COMPILE a form that references a database link. The error is: "Error 352 at line 99, column 3 Unable to access another database 'LINKNAME'". This occurs on an UPDATE statement within PL/SQL code in a form trigger that used to compile and work fine.
    I tried the database link in SQL Plus and the link is working fine.
    Database environment is 10g 10.2.0.3 on Windows Server 2003.
    Is anyone able to do this?

  • 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

Maybe you are looking for

  • PO is not creating in system

    Hello Experts, Iu2019m trying to create a PO through u2018BAPI_PO_CREATE1u2019. Iu2019ve gathered all the structure and fields which this bapi needs to create PO. When I call this BAPI in my report program the whole code get execute but I never get a

  • Pagination of results.

    Hi All, Just wondering if anyone has come across a nice way to do pagination of results from a database call. I am getting back a populated container object (extended from Vector, for which I have no control over) in my jsp. I only want to display 10

  • More than 999 line items in Invoice

    Hi All, We are having a scenario where more than 999 line items needs to be invoiced in a single billing document. If more than 999 line items are invocied in a single billing document, system can not post the acct document. Our requirement is to cre

  • How to write a create method for a table Not null fields

    Hi all, I have a table with four columns, process prs_seqid NUMBER(4) NOT NULL, prs_sbs VARCHAR2(2) NOT NULL, prs_name VARCHAR2(64) NOT NULL, description VARCHAR2(128) Where prs_seqid is primary key and prs_sbs is foreign key. I tried to create a CMP

  • Fireworks CS3 Connect Session in 2 hours!

    Hello Fireworkers! Today is the weekly Fireworks CS3 session I host informally via my blog. For the geeks that find me, feel free to come and ask questions or if you did something cool in fireworks, feel free to show it off! Where Adobe Connect: http