Resolve database service name using in SQL

Hi all!
My question is:
Is it possible to resolve database service name (e.g. TNS) from SQL only (without logging into the server with oracle user and execute tnsping)?
I'll give you a bit background about my question:
In DataGuard, if you query v$archive_dest, you can see the SERVICE NAME of the standby database in the STANDBY records. I would like to know what is the real server name and database instance of the standby database.
I don't want to login to the primary server with oracle user (let's say that I can not - it's a program really, not me...).
Let's also say that the only user I have is a read-only user to the database (with grants to all tables and views, but cannot execute privileged DBMS sys packages).
Running "SQL> host tnsping NAME" doesn't do the job, since this is only for SQL plus.
Doe's anyone have any idea? maybe v$ view that contains the TNS resolution (tried to find, no success)? maybe a tnsping alike command/function?
Thanks a lot!
Maayan

MaayanB wrote:
I'll explain the reason.
I'm working on an agentless product that connects to databases, storage and hosts, and models them into a small CMDB.
Since my product needs to model the "STANDBY" relationship between primary and standby DataGuard databases - I need to be able to resolve the value of the "DESTINATION" field from "V$ARCHIVE_DEST", where TARGET IN ('STANDBY','REMOTE').
I could login to the server and execute "tnsping DBNAME", but the problem is that when a server has more than one ORACLE_HOME (hence, more than one tnsname.ora file), I need to make sure that the user I'm using to login to the server has all environment variables conigured properly for each database installed on the server (BTW, the unix user is also a "naked" user with no privileges except the sudo's defined for it).
So I assume that the best way to be sure that the environment variables are correctly defined is when I login to the database.
This is the reason I need to resolve service names using SQL.
BTW, the database process somehow uses the Oracle Net Services to resolve the same value when it sends the redo log files to the standby server - and I'd like to resolve it the same way (or other, if not possible). If it uses the sys privileges, and it executes the package that lets you execute something on the server ("tnsping", in this case), and this is the only way it can be done - I need to start thinking on a different way to resolve the problem.What you are missing is that when "the database process somehow uses the Oracle Net Services to resolve the same value when it sends the redo . . ." is that Net services is NOT just resolving the name for the database. It is also handling the actual transport of the files. That name resolution is not passed back to the database.
>
Anyway, I'm not a hacker or something alike, It's just that my product doesn't know how to pick up the phone and dial :)

Similar Messages

  • How to use the default database service name on creating procedure for data

    how to use the default database service name on creating procedure for datagaurd client failover ??? all oracle doc says create a new service as below and enable at DB startup. but our client is using/wanted database default service to connect from application on the datagaurd environment (rac to non rac setup).please help.
    Db name is = prod.
    exec DBMS_SERVICE.CREATE_SERVICE (service_name => 'prod',network_name =>'prod',failover_method => 'BASIC',failover_type => 'SELECT',failover_retries => 180,failover_delay => 1);
    says already the service available.
    CREATE OR REPLACE TRIGGER manage_dgservice after startup on database DECLARE role
    VARCHAR(30);BEGIN SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
    IF role = 'NO' THEN DBMS_SERVICE.START_SERVICE('prod');
    END IF;
    END;
    says trigger created, but during a swithover still the service is listeneing on listener.
    tns entry.
    prod =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (LOAD_BALANCE = YES)
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod1)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = prod2)(PORT = 1521)) ---> primary db entry
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = proddr)(PORT = 1521)) --> DR DB entry
    (CONNECT_DATA =
    (SERVICE_NAME = prod)
    thanks in advance.
    Edited by: 854393 on Dec 29, 2012 11:52 AM

    Hello;
    So in the example below replace "ernie" with the alias you want the client to use.
    I can show you how I do it :
    First an entry need to be added to the client tnsnames.ora that uses a SERVICE_NAME instead of a SID.
    ernie =
    (DESCRIPTION =
        (ADDRESS_LIST =
           (ADDRESS = (PROTOCOL = TCP)(HOST = Primary.host)(PORT = 1521))
           (ADDRESS = (PROTOCOL = TCP)(HOST = Standby.host)(PORT = 1521))
           (CONNECT_DATA =
           (SERVICE_NAME = ernie)
    )Next the service 'ernie' needs to be created manually on the primary database.
    BEGIN
       DBMS_SERVICE.CREATE_SERVICE('ernie','ernie');
    END;
    /After creating the service needs to be manually started.
    BEGIN
       DBMS_SERVICE.START_SERVICE('ernie');
    END;
    /Several of the default parameters can now be set for 'ernie'.
    BEGIN
       DBMS_SERVICE.MODIFY_SERVICE
       ('ernie',
       FAILOVER_METHOD => 'BASIC',
       FAILOVER_TYPE => 'SELECT',
       FAILOVER_RETRIES => 200,
       FAILOVER_DELAY => 1);
    END;
    /Finally a database STARTUP trigger should be created to ensures that this service is only offered if the database is primary.
    CREATE TRIGGER CHECK_ERNIE_START AFTER STARTUP ON DATABASE
    DECLARE
    V_ROLE VARCHAR(30);
    BEGIN
    SELECT DATABASE_ROLE INTO V_ROLE FROM V$DATABASE;
    IF V_ROLE = 'PRIMARY' THEN
    DBMS_SERVICE.START_SERVICE('ernie');
    ELSE
    DBMS_SERVICE.STOP_SERVICE('ernie');
    END IF;
    END;
    /lsnrctl status - should show the new service.
    When I do this the Database will still register with the listener. I don't give that to the clients. That one will still be available but nobody knows about it. Meanwhile "ernie" moves with the database role.
    So in my example the default just hangs out in the background.
    Best Regards
    mseberg
    Edited by: mseberg on Dec 29, 2012 3:51 PM

  • ORA-12154 TNS Could not resolve the service name

    I am working on Oracle 9i(Release 2) windows version. I want to change the value of
    shared pool size, buffer size and others database parameter through "Enterprise Manager Console" but
    when i connect to sysdba mode message comes "ORA-12154 TNS Could not resolve the service name".
    How can I solve this problem?

    these problem are you getting from OEM?
    post
    lsnrctl status
    lsnrctl services
    make sure database is running.. all the services running in services.msc
    check error code and start..
    ORA-12514:
         TNS:listener does not currently know of service requested in connect descriptor
    Cause:      The listener received a request to establish a connection to a database or other service. The connect descriptor received by the listener specified a service name for a service (usually a database service) that either has not yet dynamically registered with the listener or has not been statically configured for the listener. This may be a temporary condition such as after the listener has started, but before the database instance has registered with the listener.
    Action:      
    - Wait a moment and try to connect a second time.
    - Check which services are currently known by the listener by executing: lsnrctl services <listener name>
    - Check that the SERVICE_NAME parameter in the connect descriptor of the net service name used specifies a service known by the listener.
    - If an easy connect naming connect identifier was used, check that the service name specified is a service known by the listener.
    - Check for an event in the listener.log file.

  • Database Service Name or Global Database Name with Oracle 10G, when Oracle

    I have an old installation of Oracle 9i (SID=ORCL) and now have installed Oracle 10G (SID=ORC2). I can get connection to Oracle 10G if i define it as an Oracle 8 compatible identification (ie I access to a SID, and don´t provide a Service Name.
    Now I want to install Oracle HTML DB, and succeeded to install the SQL-script that came with the download, but when I install Apache and HTML DB from the Oracle Companion CD I am asked to give the Database Service Name (in the Help it is explained as the Global Database Name).
    When i give the Net Service Name I get error messages (incomprehensible).
    When I look in Net Manager, the Net Service Name does not have a Service Name, but only points to a SID (ie ORC2).
    Where can I find the Database Service Name (or Global Database Name), OR define it if it is not defined??
    Thanks for your help,

    create a net service for oracle10g and provide the name of this service during HTML DB installation it is required for installation.

  • DATABASE SERVICE NAME

    HOW TO GET DATABASE SERVICE NAME?
    I NEED IT INORDER TO INSTALL COMPANION PRODUCTS?
    ANY HELP
    THANKS ANYWAY

    This is what i recieve when i click on help regarding database service name?
    "Database Service Name Specify the database service name for the database where you want to install the Oracle HTML DB database objects. The database service name is usually the same as the global database name for the database, for example, sales.us.oracle.com."
    but I don't have domain name. I installed Oracle on a standalone machine for testing purposes.Do I need to be on a network using HTML DB??
    MY DB NAME IS GPI, CONNECTION STRING IS
    (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=GPI)))
    BUT IT IS NOT WORKING?
    AND WHAT IS WINDOWS DATABASE SERVICE NAME?

  • Get the service name using form 6i

    Dear Oracle Gurus
    Can anyone please tell me how can I get the connection service name using forms 6i.
    Fawad

    Let me explain in a bit detail.
    Lets suppose, using TNSNAMES.ORA, I created a service by the name DBServer
    similarly I have some other services in TNSNAMES.ORA and I may swith between these services
    Now I connect my forms using scott/tiger@dbserver
    I wish to get this service name i.e. 'dbserver' using the form 6i

  • How to add a new database service name to 9iDS

    Hello,
    I installed 9iDS and 9iDB on my laptop which worked fine for few months. I had trouble with 9iDB I/O system so I reinstalled 9iDB with a new SID name. I updated 9iDS by replacing old SID name with new SID name in tnsnames.ora file but it did not work.
    Please someone suggest where should I update in 9iDS to access my newly installed database service with new SID so that forms appication builder can connect properly.
    Currently it is saying :
    ORA-12514: tns listener could not resolve service name given in connect descriptor.
    Thanks,
    [email protected]

    Shyam,
    could it be that you are still starting the old database tnslistener. Please make sure that you start the listener for your new Db instance.
    Frank

  • Web service invocation using pl/sql

    Hi
    Am trying to invoke a webservice using PL/SQL.
    Any ideas?
    I will be recieving the response as XML and then present the information using XSL which I have ready.
    Or any other ideas to invoke Siebel Analytics report from portal (no BPEL). I have WSDL.

    1006367 wrote:
    I am calling a Web Service(RoadNet Application) from Oracle PL/SQL(11g Database). I would not use UTL_DBWS. I had to do another web service interface recently, had a look at UTL_DBWS, and again decided not to use it. Simply put. It lacks.
    I use SOAPUI (OpenSource/free version) to interrogate the web service (read wsdl) and format a sample SOAP envelope to use.
    I then use UTL_HTTP and code a HTML POST for that web service, using the SOAPUI generated envelope as template. Supporting WSSE is also not a problem (easily done using PL/SQL).
    I posted an example of my approach in {message:id=10448611} almost a year ago - and recent experience having looked at both UTL_DBWS and the plan vanilla PL/SQL HTTP approach, I still recommend the latter.

  • Asynchronous web service call using PL/SQL

    Hi Guys,
    i'm using Apex 4.1.
    Is that possible to invoke a web service asynchronously within PL/SQL code block ? If so,
    How can i access the return value of the service when execution of that web service completes ?

    Bolev wrote:
    We have (Oracle 10g) automated process (ETL) based on internal data. Now there is an offer to incorporate existing web service call (let's say for additional record verification) in this process. Service call (I do not know what type of it yet) is using data from remote database which is not ours.Web service calls from PL/SQL is not that complex. You can use the standard UTL_HTTP package as shown in {message:id=4205205}.
    I never heard anybody goes this way especially for ETL processes.Well, if you push a million rows through the ETL process and the call overhead for the web service call (assuming perfect network and web server response) is 1 sec, that translates into 277+ hours of runtime alone for the validation to be done via web service.
    So yeah - it would seem kind of silly to use something like a web service to validate large volumes ETL data.

  • Standby database service name

    hi,
    i made a physical standby database architecture with one db as a production db on PC1 and on the other site i created a physical standby db on PC2 ,,
    now i did a SWITCHOVER and after that the db on PC1 become physical standby and db on PC2 has become primary db,,,,
    my application running before SWITCHOVER was using a service name that connect it to PC1,,now that application is not running giving me error that initialization or shutdown in progress,,,
    what shud i do now?? will i need to change the service name of my application on each client,,,other option is to use an ORACLE NAMES SERVER,,but if i wanna wont use both of the ways then what can i do??
    Regards

    This is recommended in metalink notes.
    As you say, oracle names as one option. You just go and change the ipaddress/hostname,whatever you use in the tnsnames.
    Your end-users are still trying to access the old primary, which is secondary now. And this db is in mount stage, that is the reason they are getting this kind of error.
    If you have very less users and can be reachable to change the tnsnames then its okay.
    SJH
    OCP DBA

  • Database service name changed after streams configuration

    Hi All,
    I test setting streams replication in my database 10g from a stand-alone database to a RAC database.
    Replication worked fine but i sow strange thing, my service names in the target database (RAC environment) has changed like the following output:
    SQL> sho parameter service
    NAME TYPE VALUE
    service_names string SYS$STRMADMIN.STREAMS_QUEUE.AB
    DATAWH
    So the value of my service names has changed, i don't know why. I tried to remove streams configuration and restart the database but it's not changed and it cause connexion problem from client.
    Does anybody can help me to solve this problem, why it's changing and how to take it back to the old service names.
    Thanks for your help
    raitsarevo

    Nona has any idea about my problem
    Please

  • Unable to resolve single DNS name using root hints

    Recently, we had reports that we could not internally resolve a certain .com domain name (discovered by undeliverable e-mails).  A lookup using an external server (Google's in our case) resolves the .com name just fine.
    Long ago, we had another DNS issue that lead us into implementing the following registry change:
    https://support.microsoft.com/kb/968372?wa=wsignin1.0
    1. Start Registry Editor (Regedit.exe).
    2. Locate the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS\Parameters
    3. On the Edit menu, click
    New, click DWORD (32-bit) Value , and then add the following value:
    Value: MaxCacheTtl
    Data Type: DWORD
    Data value: 0x2A300  (172800 in decimal = 2 days)
    That is the only DNS change that we have made.  We are using root hints, but temporarily added Google DNS as a forwarder so that we are able to resolve this .com address.
    As a test, I did remove that registry entry, restarted the DNS service and tested again to no avail.
    Any starting points?

    Hi,
    According to your description, my understanding is that DNS server can’t resolve .com with its root hint.
    Could you provide more information about the DNS architecture, such as numbers of DNS servers, their locations and relationships, system version, etc.
    And please post the results of NSlookup test(use local DNS server, and then use Google's server to resolve name ) here.
    Best Regards,
    Eve Wang
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]

  • How to get the database owner name in T-SQL script

    Hello, All!
    I want to get the database ower name (in format DOMAIN\user) by through T-SQL script. But SELECT * FROM sys.databases returns only owner_sid.
    Please show me a way - how to get the owner name, if you have only owner_sid. Or, may be, somebody know another way ?
    Andy Mishechkin

    SELECT suser_sname( owner_sid ), * FROM sys.databases
    http://www.t-sql.ru

  • Want To Capture The File name Using the SQL Loader

    Hi,
    I Am loading The Data To Staging Table Using The SQL*developer, The File That need to be Loaded Will be One Of The Input To the SQL*Loader Concurrent Program.
    In One Of The Column Of My staging Table I want To Put The File name.
    Can We do the Same.
    thanks,
    Ankit

    Not unless you generate the loader controlfile dynamically.. try this.. pass file name as $1 first parameter. Use the below example and modify as per your requirement
    1) create table with following table structure
    create table temp_table (x varchar2(20),file_name varchar2(30));
    2) create data file - test.dat (contains only values for x)
    abc
    def
    geh
    ggg
    fff
    3) create a host file host file - test.sh with following content:
    echo "load data
    infile $1
    append
    into table temp_table
    fields terminated by ','
    (x,
    file_name constant "$1")" > test.ctl
    sqlldr <usr>/<pwd>control=test.ctl
    4) run the host file from unix prompt with data file name as parameter (ensure test.sh has execute permissions)
    test.sh test.dat
    Hope this helps
    Regards,
    Bhadri

  • DNS not querying/ recognizing/ resolving internal domain name using nslookup

    I've setup a virtual lab for practice purpose on VMware 8 workstation.
    I have already asked this question in vm community but still got no answers hence asking it here.
    In my vmware workstation 8, for practice lab purpose my setup is as follows:-
    1] Win 2k8R2 Enetrprise edi.vm as my DC with DNS & DHCP configured and working perfect. DNS is getting resolved internally via NSLOOKUP. Server has manual ip assigned...192.168.1.xx series.
    2] Win xp vm as my Client and getting dhcp lease address from the above DC and also the DNS is getting resolved internally via NSLOOKUP.
    Now that these two vms are communicating perfectly with each other, I thought about connecting them to my physical internet.
    So, in the Virtual network editor, I added a Host-only type network named
    VMnet 04 with Use local dhcp service checkbook Disabled and on each of these vms, in network adapter settings, selected specific virtual network and pointed it to
    VMnet 04 in both vms.
    Now, in both the vms, an additional network connection got added and hence was successfully able to browse internet from both vms.
    Now the REAL problem:--
    After the above configuration, when I do NSLOOKUP on the DC, the DNS doesnt resolves external sites on the internet.
    I havent specified any kind of conditional forwarding etc.., its a simple DNS setup.
    I want it to resolve to the internal domain and also be connected to the internet .
    What setting do I need to do in DNS or in VM network?
    I tried almost all types of settings in vm virtual network editor by specifying dns manually and so on but none worked.

    Sorry my bad.... slight mistake in my question...Here is my corercted query--
    After successfully connecting to the internet, when I do NSLOOKUP on the DC, the DNS doesnt resolve my internal domain/site but instead resolves external sites on the internet.
    My computer FQDN is nri.wwe.com
    Domain dns name is wwe.com
    The above should get resolve internally but it searches on the internet.
    This is how it should work
    & it works perfect when I disable the other NAT network adapter (i.e. disable internet connectivity on my virtual DC)
    C:\>nslookup nri.wwe.com
    Server:  nri.wwe.com
    Address:  192.168.1.11
    Name:    nri.wwe.com
    Address:  192.168.1.11
    But when I again enable internet connectivity, this it what happens.
    C:\nslookup www.wwe.com
    DNS request timed out.
        timeout was 2 seconds.
    Server:  UnKnown
    Address:  192.168.12.2
    DNS request timed out.
        timeout was 2 seconds.
    Non-authoritative answer:
    DNS request timed out.
        timeout was 2 seconds.
    Name:    www.wwe.com.nsatc.net
    Address:  64.152.0.124
    Aliases:  www.wwe.com
    And when I again nslookup, this is what I get,
    C:\>nslookup www.wwe.com
    DNS request timed out.
        timeout was 2 seconds.
    Server:  UnKnown
    Address:  192.168.12.2
    DNS request timed out.
        timeout was 2 seconds.
    DNS request timed out.
        timeout was 2 seconds.
    DNS request timed out.
        timeout was 2 seconds.
    *** Request to UnKnown timed-out
    Now this 192.168.12.2 is VM assigned DNS via VM Natting with its own DHCP. If we do it manually, none of the virtual machines can connect to the internet. So I cannot fiddle with it anymore as I have already that as well.

Maybe you are looking for