Procedure containg select from Database link

Hi,
I have one database link xxx which is getting some data from one table from Sqlserver database.
Now I am writing one procedure which contain
if(c=1) --get from databaselink
select name,num from table1@xxx;
else --get from the Oracle table;
Now iam calling that procedure from .net application which is giving the following error :ORA-01002: fetch out of sequence
ORA-02063: preceding line from FSPDEV_TO_AVERY_ORGRPT
it is giving the above error if c=1 otherwise the else part is working fine.
What i need to do?
Thanks

Hi,
Thanks for your response.
my procedure is like this:
Cur_Out sysrefcursor
if(c=1) --get from databaselink
Open Cur_out for
select name,num from table1@xxx;
else --get from the Oracle table;
Open Cur_out for Select from Oracle table;
I will try to execute the procedure from SQLPLUS.
thanks

Similar Messages

  • How to Execute a Remote Procedure in Portal using Database Link

    Hi,
    I followed the instructions to create a Portal form for a remote procedure. But I am encountering the following error. Can someone advise what may be the cause?
    Failed to execute - Missing string(create_package_body) language(us) domain (wwv) sub_domain (wwv_builder) (WWV-04300)
    ORA-04020: deadlock detected while trying to lock object PUBLIC.PORTLET_SCHEMA (WWV-11230)
    Failed to parse as PORTAL - (WWV-08300)
    PURPOSE
    How to execute a remote procedure in Portal using Database Link.
    DESCRIPTION
    This procedure assumes that you have two databases, one of which is remote, and Portal is configured in the other.
    Remote Database A:
    ==================
    1) Create a procedure as follows: Create or Replace PROCEDURE SCOTT.ADD_TWO_VALUES ( v_one IN NUMBER, v_two IN NUMBER, v_result OUT NUMBER) as begin v_result :=v_one+v_two; end; 2) Grant execute privileges to PUBLIC on the procedure.
    Database B (where Portal is configured): ========================================
    1) Create a public database link and choose to connect as a specific user (say SYSTEM). By default, in an Oracle 8i database, the "global_names" parameter in initSID.ora (or init.ora) file is set to "true". This Global Naming parameter enforces that a dblink has the same name as the database it connects to. Therefore, if the remote global database (A) name is "ora8.acme.com" then the database link should also be named as "ora8.acme.com".
    2) Create a synonym for the procedure in Database A. Make sure you fully qualify the procedure name in the remote database (like SCOTT.ADD_TWO_VALUES).
    3) Create a dynamic page to execute the procedure. The ORACLE tags in the dynamic page will look similar to the following: <ORACLE> DECLARE v_total NUMBER; BEGIN ADD_TWO_VALUES(:v_one,:v_two, v_total); htp.p('The total is => '); htp.p('<input type="TEXT" VALUE='||v_total||'>'); htp.para; htp.anchor('http://<machine.domain:port#>/pls/portal30/SCOTT.DYN_ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure'); END; </ORACLE>
    4) Portal does not have an option to create a form based on a synonym. Therefore, if you want to create a form instead of a dynamic page, create a wrapper procedure and then create a form based on this procedure. For example: Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES_PR ( v_one IN NUMBER, v_two IN NUMBER, v_total OUT NUMBER) as begin add_two_values(v_one, v_two, v_total); end;
    5) Grant execute privileges to PUBLIC on the procedure.

    hello...
    any input will welcomed... Thanks..

  • LTR - Error occurred when selecting from database

    Hi,
    We created couple of configurations using LTRC in our SLT systems. When i try to check these in transaction LTR, they are not displayed, just getting the error - Error occurred when selecting from database (Attached screenshot). All the required SICF for SLT has already been activated. Any suggestions how to fix this issue?
    Thanks,
    Saravanan

    Hi Experts,
    Did anybody get the solution of this error ,if yes please reply?
    I am getting below error when I am refreshing the current config or creating a new one in LTR
    " Error occurred when selecting from database"
    Thanks for your help,
    Balwant

  • The way to open 3D pdf with specific model selection from url link

    I guess this feature is not supported, but let me ask one thing.
    I am looking for the way to open 3D pdf with specific model selection from url link.
    For example, if the following link is opened, is it possoble to open 3d.pdf with automatic selection of "abc" model in the model tree? 
    http://example.org/3d.pdf#model=abc
    If it can be done by javascript, it's really helpful.

    Impossible. There are only very limited command-line options for the Acrobat Family and you cannot change them.

  • Procedure with select from mysql db link problem

    Hi,
    first of all Oracle is new to me so if there are better ways to do this every suggestion would help.
    My problem is simple i cant use select from dblink inside a procedure.
    In Oralce SQL Developer 1.5.5:
    Im using oracle 11g and mysql 5.5.13 with mysql odbc 5.1
    in both db the user is root
    CREATE PUBLIC DATABASE LINK "MYSQL"
    CONNECT TO "root" IDENTIFIED BY "****"
    AUTHENTICATED BY "root" IDENTIFIED BY "****"
    USING 'mysql';
    select * from t1@mysql;
    run; -> result OK
    select "MAXID" from t1@mysql where "TNAME"='first';
    run; -> result OK
    create or replace
    PROCEDURE T1_IDS_PROC AS
    maxi number;
    BEGIN
    select "MAXID" into maxi from t1@mysql where "TNAME"='first';
    END T1_IDS_PROC;
    compile -> not working:
    Fehler(7,3): PL/SQL: SQL Statement ignored
    Fehler(7,47): PL/SQL: ORA-00904: "TNAME": unknown identifier
    How to solve this?

    Thanks for replay,
    yes the owner of the procedure can acces the remote table.
    I can use
    select count(*) into i from t1@mysql
    inside the procedure, but if i use specific columns inside the select i cant compile.
    Why i need double quote?
    I dont know if i need them but i read some tutorial for dblink to mysql and there was explanied
    Oracle use upercase names and Mysql is case sensitive for odbc 5.1 so i have to double qoute mysql names.
    But with or without double qoute it dont work inside procedures ;(

  • Select from a linked server fails when executed as a join to database tables

    Hi
    I have been using the following TSQL to update a results table for several years it is currently running on SQL Express version 11.0.2100.60 (I have successfully run this on various versions and editions from 2005 onwards)
    select c.Race_id , r.Runner_id , i.Time_secs
      from CHAMPS INPUT]...Results I
      join  [dbo].[Race] c
      on rtrim(I.Race)COLLATE SQL_Latin1_General_CP1_CI_AS
      = rtrim(c.Race_name)COLLATE SQL_Latin1_General_CP1_CI_AS
      join  [dbo].[Runner] r
      on rtrim(I.[Name]) COLLATE SQL_Latin1_General_CP1_CI_AS
      = rtrim(r.First_Name)COLLATE SQL_Latin1_General_CP1_CI_AS + ' '
      + rtrim(r.Surname)COLLATE SQL_Latin1_General_CP1_CI_AS
     where i.Time_secs > 0
    This worked earlier today then with no obvious change stopped working
    No error is given but no rows are returned
    running select * from [CHAMPS INPUT]...Results where Time_secs > 0 returns the expected rows
    Any ideas where to look for the problem

    Erland thanks for your reply. I have resolved the issue, it was caused by an error in updating the joined race table. I was looking for a problem with the linked server and missing the obvious.
    Hi philpits,
    You can try to use SQL Profiler to capture some events while run your query.
    In addition, can you get expected result while run the query on remote server? Please also check your underlying tables.
    Regards,
    Elvis Long
    TechNet Community Support

  • How can you SELECT via Database Link CLOB data using Application Express?

    Customer Issue:
    Developer using Oracle's Application Express 3.1. The Developer is trying to SELECT a CLOB datatype column from a remote (10.2.0.3) database, via a database link on her 10.2.0.4 based client Application. The Developer wants to be able to select CLOB data from the remote database which has limitation that she can't make any changes to the remote database.
    Developer's Comments:
    I do a select and get the error. Getting error ORA-22992: cannot use LOB locators selected from remote tables. So she feels she can't use dbms_lob.substr in this configuration I can do a "select into" but that is for one value. I am trying to run a select statement for a report that brings back more than one row. I do not have permission to change anything on the remote database. I want to access the remote database and multiple tables.
    This is not something I work with, would greatly appreciate help or ideas. Is this a limitation of the 3.1; or does she just not have this set up correctly; or should she be using a Collection (if yes, please share example)
    Thanks very much,
    Pam
    Edited by: pmoutrie on Jun 4, 2009 12:01 PM
    Hello???
    Would really appreciate an answer.
    Thanks,
    Pam

    This may not be a perfect solution for you but it worked for my situation.
    I wanted to grab some data from Grid Control's MGMT$JOB_STEP_HISTORY table but I couldnt' create an Interactive Report due to the existance of a CLOB column. I cheated this by creating a view on the GC DB, grabbing the first 4000 characters and turning it into a varchar2 column:
    create view test_job_step_history as
    select job_Name, target_name, status, start_time, end_time, to_char(substr(output,1,4000)) output
    from MGMT$JOB_STEP_HISTORY where trunc(end_time) > trunc(sysdate)-90
    In an APEX Interactive Report:
    select * from test_job_step_history@GCDB
    Granted, the output looks aweful right now but I am only looking for a very particular output (failed, denied, ORA-, RMAN-, etc) so the formatting isn't the most important thing to me right now.
    If anyone can improve -- and I'm sure you can -- on this I'd love to hear about it.
    Thanks,
    Rich

  • Browsing and selecting through database link to fill in a form item

    Hi
    I have created a database link named in my application
    dblink_3
    I have a form and report in my application. On the from I have an item called P6_USER_ for which I would like to access a table (trk_user) through the database link I created so that I can fill in the text field or select list with a user from the table.
    can I browse by a select list somehow? or do I need to create a button that takes me to a report with a list of the data in the table and select that way.
    Please steer me in the right direction,
    Thanks,
    Kirk

    Hi Kirk,
    The fact that the data is on an external table shouldn't make any difference. You can do:
    SELECT field1 d, field2 r FROM trk_user@dblink_3 ORDER BY 1
    and that will give you your select list

  • How to recover password from Database link in Oracle 10G

    Hi guys,
    How can I get a user password from DBLink in Oracle 10G?
    From sys.link$ the column "PASSWORD" is empty and the crypted data comming from the new column "PASSWORDX" does not work by using "... identified by values..."
    Any idea?
    Thanks...

    Why do you need to know the password? If you need to re-create the link in another database you can use dbms_metadata to generate the DDL for the database link and for a fixed database link the DDL will include an encrypted password that will match the remote database password.
    select dbms_metadata.get_ddl('DB_LINK','Link_name','Owner') from sys.dual
    On version 9.2 it extracts the actual visible plan text password. On 10g+ encrypted representation in values clause
    HTH -- Mark D Powell --

  • Create View from Database Links - Question

    Question
    I'm missing something simple.
    I'm trying to create a view, from a Database Link.
    CREATE VIEW view_name
    AS SELECT a.*
    FROM schema.tablename@dblink a;
    When I run this in the SQL Commands window.
    I get this error message.
    ORA-00933: SQL command not properly ended
    What am I missing? Any help is appreciated...

    <i>CREATE VIEW vw_name
    AS SELECT a.*
    FROM [email protected] a;
    </i>
    <br>
    1) User (schema) which is creating view must have proper db_link to source database. For that try this for testing purpose:
    select 1 from [email protected]<br>
    If this fail then db_link is not ok! This step is absolute must to go any further step to!!!
    <br>
    2) when db_link is set, then your view should be named as:
    CREATE VIEW vw_name
    AS SELECT *
    FROM <b>schema_name</b>.[email protected];<br>
    please pay attention to "schema_name", because from remote side every table is in some schema so it really need declaration of owner schema.
    <br>
    Hope this helps...

  • Return ref cursor from database link/stored proc? do-able?

    Is it possible to return a REF CURSOR from a stored procedure that is being called from a remote database via a database link???
    We are trying from Pro*Cobol on MVS (which has db link pointing to AIX thru db link) and get a 00993 error, which seems to say this is not possible.
    Before I give up, thought I would check with the experts....
    Thanks in advance.

    You can't return Java objects as stored procedure or query results.
    Douglas

  • 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

  • Why does "SELECT * FROM [database].[schema].[table]" not work in Azure ?

    Hi all
    In Microsoft Azure I have 2 databases.
    I work since more than 10 years with T-SQL and I always use
    fully qualified object names, means "[database].[schema].[table]".
    When I now make a connection to my database "A" in Azure and
    write a Query against database "B" ("SELECT * FROM [B].[schema].[table]")
    I get an exception. Of course when I connect to database "B" it works
    but again not to database "A". When I use "SELECT * FROM [schema].[table]"
    with the right database connected, it also works in Azure.
    Hope you understand what I mean :-)
    In MS-SQL, this of course works fine.
    Well my question is: What sense does this make ??
    Do I now have to re-write everything just for azure or will this behavior changed sometimes ?
    I know MS-SQL is not the same like Azure-SQL, but hey; does Microsoft think all projects have only one database ?? :-)
    Thanks for any answer
    Frank

    Hi Frank,
    According to your description, you want to retrieval data cross database in SQL Azure, right?
    As June said, Currently cross database joins are not supported in SQL Azure. Also you cannot change database mid query so you cannot, for example, put a USE [MyDB] in your query either. Please refer to the link below to see the details.
    http://www.britishdeveloper.co.uk/2011/11/cross-database-joins-in-sql-azure.html
    If you have any concern about this behavior, you can submit a feedback at
    http://connect.microsoft.com/SQLServer/Feedback and hope it is resolved in the next release of service pack or product. Your feedback enables Microsoft to make software and services the best that they can be, Microsoft might consider to add this feature
    in the following release after official confirmation.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Unable to execute Map from Database link

    Hi
    Been trying to research this issue but have had no luck in finding an answer. Here is the situation:
    We have an apex application that resides on database "A"
    Our OWB Design Repository (11.1.0.7) and Runtime Environment both exist on database "B"
    Maps exists and execute under normal procedures as the "ETL" user on database "B", However we would like to allow the "APEX" user to execute a map from database "A" across a database link to a user that can execute the map without any issue.
    When we try to execute the map across the database link from toad or sqlplus we get no error returned, the procedure runs and kicks off a map execution (as seen in ALL_RT_AUDIT_EXECUTIONS) or from the control center executions. However the Map execution immediately fails with no explanation as to why??
    what makes even less sense is that the user on database "B" that the database link connects to.. can execute the same procedure all day long if logged directly into database "B".. but the moment you try to call it across the database link.. it errors with no message as to why.
    We are calling the "WB_WORKSPACE_MANAGEMENT.SET_WORKSPACE".. so that is not the issue.. I am assuming this is either a bug.. or we are missing an additional call/privilege. The user for the database link is a registered user in the workspace, obviously this works since the database link user can run the procedure if logged in locally to database "B"
    Any thoughts???

    Figured out our problem..
    Found RETURN_CODE column in ALL_RT_AUDIT_EXECUTIONS table.. point to -2064 which is an ora-2064
    NOTE 1026597.6 - CALLING REMOTE PACKAGE RECEIVES ORA-2064 explains that a commit is issued in a coordinated session from an RPC procedure call with OUT parameters or function call. Action: simplify remote update statement.
    The problem here is that "Commit Control" was set to Automatic for the mappings we were calling. Oracle does not like when a transaction is initiated on database "A" and has a commit issued on database "B" from the map.
    Makes sense.. we switched the commit control to "Manual" and are able to process correctly by issuing a commit from the session on database "A"
    Hope this helps anyone that runs into this issue themselves..

  • Dynamic table  selection from database

    Hi ;
    I want to create  variable field that I will use at database selection.I tried to do it with   select *  from ( tabname )..... but I couldn't do it how you any offer fot this issue.

    Hi,
    DATA FCAT1 TYPE LVC_T_FCAT."fieldcat of type internal table
    DATA:DYN_ITAB TYPE REF TO DATA,"holding the dynamic internal table
    WA TYPE REF TO DATA."holding the wa for dynamic internal table
    FIELD-SYMBOLS: <DISP_TABLE> TYPE TABLE,
    <WA> TYPE ANY.
    SELECT SINGLE tab_name FROM table INTO DB_TABLE.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
            EXPORTING
              I_STRUCTURE_NAME = DB_TABLE
            CHANGING
              CT_FIELDCAT      = FCAT1[].
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE"creating dynamic internal table using fieldcat
        EXPORTING
        IT_FIELDCATALOG = FCAT1[]
        IMPORTING
        EP_TABLE = DYN_ITAB.
        ASSIGN DYN_ITAB->* TO <DISP_TABLE>."creating internal table by refering the dynamically generated internal table structure
        CREATE DATA WA LIKE LINE OF <DISP_TABLE>."creating work area for the internal table
        ASSIGN WA->* TO <WA>.
        SELECT * FROM (DB_TABLE) INTO <WA> UP TO MAX_HITS ROWS."filling the internal table
        APPEND <WA> TO <DISP_table>.
        ENDSELECT.
    <b>REWARD ALL HELPFUL ANSWERS.</b>
    rgds,
    bharat.
    Message was edited by:
            Bharat Kalagara

Maybe you are looking for

  • Importing old project to new project

    Hi All- My client wants a different backgorund/template on the project that exists now. I decided the easiest way to make this change might be to open a new project, design the new background (actually I imported a new background into the new project

  • Cannot install AIR 2.0.4.13090 sidecar application on Windows 7 64 bit

    Our team is experiencing consistent failure to install our AIR-developed application on Windows 7 64 bit. It fails to install, but apparently eventually can be installed only after a complete uninstallation of AIR and subsequent install attempts are

  • Remote Desktop Printer Redirection Stops Working Randomly on Server 2008 R2

    We have a MS Windows Server 2008 R2 that is used SOLELY as a Terminal Services remote desktop server onto our network. It is used for employees who are off site and need to use the networked company software. VPN works, but is extremely slow for this

  • Acrobat crashes when extracting pages

    Version Adobe Acrobat X 10.1.12 When extracting and emailing pages from a pdf multiple times, Acrobat crashes.  Here is the process: 1. Open pdf 2. Tools -> Pages -> Extract 3. Select any number of pages -> delete after extracting -> Yes at prompt 4.

  • Bizarre audio sync issues

    I'm having trouble even understanding how the following is possible. I have an after effects composition that I am importing as a lower third graphic on video track 2.  When I place it on the timeline, all my audio goes out of sync.  Not just the aud