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 ;(

Similar Messages

  • Performance problem with select from _DIFF view

    Hi,
    we have a versioned table with more then one million records. We use the DBMS_WM.SetDiffVersions procedure and select from DIFF view to get data differences between two workspaces. The problem is that the select from the DIFF view is very slow. I takes more than 15 minutes. Has anybody an idea why it consumes so much time? Is there any way how to improve it?
    Thanks and regards
    Ondrej

    Hi,
    This can be due to any number of things, but is typically caused by an inefficient optimizer plan. Make sure that statistics on the _LT table have been recently analyzed.
    Also the following information would be useful:
    1. What is the relationship of the workspaces that you are trying to compare (parent/child, children of the same parent, etc) ?
    2. How many and of what type dml are being performed in the workspaces ?
    3. What version of Workspace Manager are you using and what is the version of the database ?
    4. What is the time needed to select from the _DIFF view based on the primary key ?
    Regards,
    Ben

  • PROBLEM WITH Select * from table_name with JDBC

    Hello,
    I am using thin driver. The problem that i am having is as
    follows.
    when i execute select * from any_table_name from within java
    code i only get FIRST row back. I am using Employee.java example.
    Is there something else i should do?
    Alex
    null

    Hi Alex,
    I am writing a client application with Java. Everything works
    really well, but - same problem as you had (I know, you solved it
    - that's why I'm writing :) - reading only first column. Actually
    it works fine on its own, but when embedded in my java app -
    that's when I get the first column displayed.
    Also executing "select * from emp;" gives me a sequence of
    numbers (displayed in columns) 20, 30, 30 etc, which are in fact
    present as one of the columns when running this query without
    java.
    I appreciate your help!
    Malgosia
    Alex Korneyev (guest) wrote:
    : Hello,
    : I am using thin driver. The problem that i am having is as
    : follows.
    : when i execute select * from any_table_name from within java
    : code i only get FIRST row back. I am using Employee.java
    example.
    : Is there something else i should do?
    : Alex
    null

  • 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

  • Problem calling Procedure with parameter from Dynamic Page

    I received an error saying the Page not found
    here's how to reproduce the error.
    1. Create procedure in portal30 schema.
    Create or Replace PROCEDURE PORTAL30.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. Create Dynamic Page with following code
    <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/PORTAL30.DYN_
    ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure');
    END;</ORACLE>
    3. I clicked on Customize Link and entered 2 numbers as values for v_one and v_two.
    4. Got "The page cannot be found" error in I.E. or "The requested URL /pls/portal30/PORTAL30.DYN_SAMPLE_ADD.show was not found on this server." on Netscape
    However when I subsitute "ADD_TWO_VALUES(:v_one,:v_two, v_total);" in the dynamic page for "ADD_TWO_VALUES(3,2, v_total);", it runs just fine.
    What's wrong here? Can I not use a parameter from a dynamic page and call a procedure with it? Help is needed urgently and will be greatly appreciated.
    -Ahsun

    Hi,
    I tried with your code with few changes ,please try with them.
    Create or Replace PROCEDURE <myschema>.ADD_TWO_VALUES
    v_one IN NUMBER,
    v_two IN NUMBER,
    v_result OUT NUMBER)
    as
    begin
    v_result :=v_one+v_two;
    end;
    I created the procedure in <mySchema> and granted that to <application_schema> and made some changes
    <ORACLE>
    DECLARE
    v_total NUMBER;
    BEGIN
    <procedure_schema>.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://<your_host>/pls/<portal_schema>/<application_schema>.DYN_FOR_OTN.SHOW_PARMS', 'Re-Execute Procedure');
    END;
    </ORACLE>
    Hope this helps.
    rahul

  • Data Corrupted when using CREATE AS SELECT * FROM over DB LINK

    Hi ,
    I wonder if anyone has suffered a simillar issue as this:
    I have a DB Link Between a 10gR1 (Base install not patched) database on Windows 2003, and a 10gR2 (with latest Patch Database ) on Sun Solaris. The 10.1 DB is the SOURCE 10.2 is TARGET
    When using a statement like the following on the Target :
    CREATE TABLE a AS SELECT * FROM TABLE a@SOURCE
    The statement completes, however for some (not all) tables, the data content is seriously corrupted, I noticed this when trying to apply a UKey on the newly created table in TARGET. The data was completely messed up for around 600 out of 450000 rows, I could not easily tell which rows were messed up as it was the columns that build the UKey that were affected :-(
    The same happens if I precreate the table and use INSERT /*+APPEND*/ INTO AS SELECT.... etc
    I realise that using an unpatched 10.1 is not nessasarily advisable, however currently it is difficult for us to patch or upgrade the DB...
    If anyone has seen this before an/or has any ideas what might be the cause , I would appreciate any help I can get.
    Cheers
    JAmes

    The Problem Manifest itsself in that some fileds are created with incorrect Values, specificaly in easy to identify cases NULL where the original values where not NULL.
    These field do not contain special chars like ä or ß , so it does not seem to indicate a charset issue.
    JAmes

  • How to call sql procedure with parameter from java

    Hello,
    i am trying to call one sql procedure with two parameters from java.
    the first parameter is In parameter, the second is OUT.
    the return value of this java method should be this second parameter value.
    the following is my java code:
    protected String getNextRunNumber() {
         String runnumber=null;
         String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
    CallableStatement state = null;
    try{
         Connection con= getDatabaseConnection();
         state = con.prepareCall(sql);
         state.setString(1, m_appKeyExport);
         state.registerOutParameter(2,Types.NUMERIC,0);
         state.execute();
    ResultSet resultR = (ResultSet)state.getObject(2);
         while (resultR.next()) {
              runnumber=resultR.getBigDecimal(1).toString();
    catch (SQLException e){System.out.println("You can not get the export next run number properly");}
    return runnumber;
    i got error message like:
    java.lang.ClassCastException: java.math.BigDecimal
    As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
    Please help me to solve this problem.
    Thanks a lot.

    state.execute();
    i try to use debug to find the problem, in this line, i saw
    OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
    is this the problem?

  • Help with select from USREXTID table

    HI,
    I try to select from table USREXTID and when i try to use do the select like below
    SELECT bname FROM usrextid
       INTO TABLE lt_bname
           WHERE type    = 'DN'
           AND extid     =  temp_extid
           AND status    = 'X'.
    here when i take the exact entry from the table i get sy-subrc = 0.
    Working o.k.
    when i try to use the select for SAML like
    SELECT bname FROM usrextid
       INTO TABLE lt_bname
             WHERE type      = 'SA'
               AND extid     =  temp_extid
               AND status    = 'X'.
    I get sy-subrc = 4.
    I have entry on the table with SA and i copy all the entry from EXTID field and put it on
    temp_extid ,
    What can be the problem ?
    Best Regards
    Nina
    Edited by: Nina C on Jun 15, 2009 10:05 AM

    HI,
    i copy the entry from the table exactly and i put it ,
    The problem here is with SA.
    when i copy entry from table with DN it work fine.
    it's behave strange .
    Best Regards
    Nina

  • Update with Select from a non-existant column

    Hello,
    If I have two tables in Oracle database:
    Table_1 has column id, c1, c2
    Table_2 has column id, c1, c2
    If I run the following select statement, it will give error, because column c3 does not exist:
    select c3 from table_2;
    However, if I run the following update statement, it run successfully with error. It shows, for example, 10 rows updated:
    update table_1 t1 set t1.c2 =
    (select t2.c3 from table_2 t2
    where t2.id = t1.id);
    Could someone explain to me what happens?
    Regards!

    rp0428 wrote:
    >
    It's called a Correlated Sub-Query . It's documented, with examples, in the SQL Language manual
    >
    I'm familiar with correlated sub-queries. That link has NO examples using a column in the FROM list of a sub-query that is NOT in a table in the FROM list of that sub-query.
    You can certainly use constants, or functions in a select list without needing a table reference but I haven't seen any documentation showing an example of selecting a column in a sub-query that doesn't exist in one of the FROM tables.There are no examples of selecting a column from the outer query in a sub-query because in 99.999% of the cases it would be the wrong thing to do, however it is possible. Clearly the sub-query can "see" columns in the outer query otherwise how would it see the values for a correlated sub-query. As Frank said, there is nothing in the documenation that precludes using an outer column in the sub-query, and this paragraph from Frank's link certainly seems to pretty generally refer to the entire sub-query:
    If columns in a subquery have the same name as columns in the containing statement, then you must prefix any reference to the column of the table from the containing statement with the table name or alias. To make your statements easier to read, always qualify the columns in a subquery with the name or alias of the table, view, or materialized view.John

  • Any sample program to fetch data with JSP from MySQL

    Hi,
    Anybody can you ple give me a sample code to fetch data from MySQL and show it.
    Database server : localhost
    Databasename : test
    Database User : root
    Database Password : (database have no password)
    Table Name : category
    Table column name : catName
    I am trying the following code, but it gives error:
    exception
    org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    <%@ page import="java.sql.*" %>
    <%
    String connectionURL = "jdbc:mysql://localhost:3306/test";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    %>
    <html><body>
    <%
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    connection = DriverManager.getConnection(connectionURL, "root", "");
    statement = connection.createStatement();
    rs = statement.executeQuery("SELECT * FROM category");
    while (rs.next()) {
    out.println(rs.getString("catName")+"<br>");
    rs.close();
    %>
    </body></html>
    any help is appreciated.
    ---Sujoy

    Just replace the following code. I think it will work for u.
    <%@ page import="java.sql.*" %>
    <%
    try{
    String connectionURL = "jdbc:mysql://localhost:3306/test";
    Connection connection = null;
    Statement statement = null;
    ResultSet rs = null;
    Class.forName("com.mysql.jdbc.Driver");
    connection = DriverManager.getConnection(connectionURL, "root", "");
    statement = connection.createStatement();
    rs = statement.executeQuery("SELECT * FROM category");
    %>
    <html><body>
    <table>
    <%
    while(rs.next())
    %>
    <tr><td><%=rs.getString("catName")%></td></tr>
    <%
    %>
    </table>
    </body>
    </html>
    <%
    rs.close();
    statement.close();
    connection.close();
    catch(Exception e)
           e.printStackTrace();
    finally()
      try{
       rs.close();
       statement.close();
       connection.close();
      catch(Exception e)
            e.printStackTrace();
    %>

  • SELECT from MySQL, INSERT into Oracle

    Hallo,
    I am new to Java.
    My task is to collect data from about 30 tables inside MySQL database and then insert it to similar tables in Oracle.
    Script should copy data one a day, during the night.
    Number of rows in each table is about 30,000.
    MySQL version 5.1
    Oracle version 11.1.7
    Both of them are installed on really fast servers.
    The way i would do it is:
    1. connect to MySQL
    2. connect to Oracle
    3. select data from MySQL table and insert it to Oracle table.
    repeat this step for each table
    More precise about SELECT and INSERT:
    handle_one = "SELECT a, b, c FROM mysql_table1";
    while(handle_one is true)
    INSERT a, b, c INTO oracle_table1;
    4. close MySQL connection
    5. close Oracle connection
    Is it best way?
    Best Regards
    slk

    slkLinuxUser wrote:
    Script should copy data one a day, during the night.
    Number of rows in each table is about 30,000.There are variations on the above depending on what the above two statements mean.

  • Inventory Management :Delta IP of BF runs with selection from Init IP of BF

    I have an init IP for BF DS which i ran with selection on posting date.
    I have another IP for delta for BF without any selection criteria.
    But, when i run the delta IP, it runs with the selection on posting date, the same value that i used for init.
    Even if i modify and clear the delta IP of any selection, and run it, it still runs with the selection.
    How do i rectify this.
    Thanks,

    that is the correct process. if u do init with some filters then those would be applied to Delta by default. u cannt remove those filters from delta. if u want to do it anyway u have to delete the last init request then the filters wodnt be applied. but in this case u have to rerun ur init again without any filters so that u can get delta.

  • Code Inspector with 'SELECT * FROM'

    Hello all,
    I want to tell my code inspector, that it shall find
    Select * from.
    I put it in the ABAP STATEMENT PATTERNS but now the code inspector finds all selects for it interpretates * as wildcard.
    What can I do ?
    Please help
    Simone

    as you ask this question in the performance forum, I would also like to know why you want to see all 'select *'.
    If you want to solve any performance problems then I should say, that it will not help.
    Select ' are no real performance issue. Field lists are nice to have, but difference is only considerable, if you reduce the width of the table dramatically, i.e.
    it is enough if you check the very width tables.
    And please to not introduce new select statements which deviate from others just in the definition of the field list.
    The real performance issues are the indexes, or better the selects which have no proper index support.
    Siegfried

  • Update table with select from another table

    Hallo,
    I'd like to update table b with codes from a mapping table a.
    a has:
    town_id, town_code, town_name
    b has town_code, town_id, town_population, town_zip_code,...
    Table a has all the details - town_id, town_code and town_name and acts as the mapping between town_id and town_code
    In table b, town_code is null. I want to update the column b.town_code with town_code from table a where a.town_id = b.town_id.
    How will the update query look like?
    I tried
    UPDATE B SET town_code = (SELECT A.town_code FROM A,B WHERE A.town_id=B.town_id)
    and I get the error 'single-row subquery returns more than one row'
    Will appreciate your assistance

    This is what I did.
    First, I created and populated the TOWN_INFO table:
    CREATE TABLE "TOWN_INFO"
    (     "TOWN_ID" NUMBER,
         "TOWN_CODE" NUMBER,
         "E_MAIL" CHAR(15 BYTE)
    Table Created.
    insert all
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3024,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3040,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3052,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3065,'[email protected]')
    into TOWN_INFO (TOWN_ID, E_MAIL) values (3066,'[email protected]')
    select * from dual
    5 rows created.
    The following creates and populates the mapping table:
    CREATE TABLE "TOWN_MAPP"
    (     "TOWN_CODE" NUMBER,
         "TOWN_ID" VARCHAR2(255 BYTE),
         "TOWN_NAME" CHAR(6 BYTE)
    insert all
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3024,'1001','TOWN_1')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3040,'1003','TOWN_3')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3052,'1002','TOWN_2')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3065,'1004','TOWN_4')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3066,'1006','TOWN_6')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3088,'1007','TOWN_7')
    into TOWN_MAPP (TOWN_ID,TOWN_CODE, TOWN_NAME) values (3020,'1009','TOWN_9')
    select * from dual
    7 rows created.
    And now the update query:
    UPDATE TOWN_INFO
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    WHERE B.TOWN_ID=B.TOWN_ID)
    SET TOWN_CODE=(SELECT B.TOWN_CODE FROM TOWN_MAPP B, TOWN_INFO C
    ERROR at line 2:
    ORA-01427: single-row subquery returns more than one row
    Thanx in advance
    Edited by: user9954260 on Apr 13, 2010 7:40 AM
    Edited by: user9954260 on Apr 13, 2010 7:44 AM

  • How to select rowid with select * from table_name

    Hello guys i have a cursor like so.
      Cursor c1 IS SELECT * FROM FZRASST;
      -- Row of type FZRASST row
      fzrasst_row c1%ROWTYPE;when i try to reference the row id like this
    fzrasst_row.rowid;i get an error invalid indentifier? how can i reference the row id without implicitely selecting rowid? is this possible or do i need to change my select statement to select every column on the table?
    Any help would be greatly appreciated.

    Hi,
    mlov83 wrote:
    Hello guys i have a cursor like so.
    Cursor c1 IS SELECT * FROM FZRASST;
    -- Row of type FZRASST row
    fzrasst_row c1%ROWTYPE;when i try to reference the row id like this
    fzrasst_row.rowid;i get an error invalid indentifier? how can i reference the row id without implicitely selecting rowid? is this possible or do i need to change my select statement to select every column on the table?Fzrasst_row contains every column that is in the SELECT clause, and nothing more. If you want fzrasst_row to include pseudo-columns (such as ROWID) or anything else, then you have to include them in the SELECT clause.
    To avoid naming every single column in hte table, you can do something like this:
    Cursor c1 IS
        SELECT  FZRASST.*
        ,       ROWID   AS r_id
        FROM    FZRASST;(assuming the table doesn't already have a column called r_id).
    Edited by: Frank Kulash on Feb 13, 2012 3:29 PM

Maybe you are looking for