How to get the Primary key from  Synonym

Hi ,
I want to get the Primary Keys for my tables . I used
java.sql.DatabaseMetaData databasemetadata = connection.getMetaData();
    ResultSet rs = databasemetadata.getTables(null, null, "%", null);
rs.next();
    System.out.println(" TABLE_CAT "+ rs.getString(1));
    System.out.println(" TABLE_SCHEM  "+rs.getString(2));
    System.out.println(" TABLE_NAME "+rs.getString(3));
    System.out.println(" TABLE_TYPE  "+rs.getString(4));
    System.out.println(" REMARKS "+rs.getString(5)); gives :
TABLE_CAT null
TABLE_SCHEM PROGRESS
TABLE_NAME ApplicConv
TABLE_TYPE SYNONYM
REMARKS null
Now if I use :
  rs = databasemetadata.getPrimaryKeys(null,"PROGRESS","Applicconv");
  System.out.println("Is result set Non empty "+rs.next()); gives :
Is ResultSet non empty false .
Can you tell me why this result is empty? Is it because of my table is a Synonym?
If it is Synonym how to get the primary key ?

You can use DatabaseMetaData#getPrimaryKeys.

Similar Messages

  • Getting the primary key from order form

    Does anyone know how to get the primary key (DocEntry) off of the order form for an existing order?  I don't really want to use the DocNum field since it is not the primary key and theoretically two different orders could have the same DocNum.  Thanks in advance for your help.

    Hi Joe,
    DocEntry and DocNum values are unique, so you cannot have in db 2 orders with the same DocNum. It's possible, that DocEntry and DocNum values can vary.
    If you know the DocNum value (f.e. from Order's Form), you can simple use RecordSet object:
    Dim sQuery as String
    Dim oOrder as SAPbobsCOM.Documents
    Dim oRecordSet As SAPbobsCOM.Recordset
    Set oOrder = oCompany.GetBusinessObject(oOrders)
    Set oRecordSet = oCompany.GetBusinessObject(BoRecordset)
    sQuery = "Select DocEntry From ORDR Where DocNum = '" & DocNumber & "'"
    oRecordSet.doQuery sQuery
    If oRecordSet.RecordCount > 0 Then
      oOrder.GetByKey(oRecordSet.Fields(0).Value)
    End If
    And this should work.
    Regards
    Libor.

  • How to get the PRIMARY KEY of a table at runtime ???

    Hi everybody,
    My requirement is to update a z-table at runtime according to the data given ata runtime. So the main difficulties for me is that whenever I tried to update the table based on the data given in UI many rows are getting updated as these fields are not unique. So I think if I can get the PRIMARY KEY along with these given fields then I can update only one row at a time.
    So Can anyone suggest me how to get PRIMARY KEY of a table based on the data in UI..??
    Any suggestions will be appreciated..
    Thanks,
    Sekhar

    U will get primary keys of transparent tables using FM "REUSE_FIELDCALATLOG_MERGE".
    pass tyour table name and u will get fieldcatalog filled. In tht their is a field called "KEY" if it has 'X' then tht field is a primary key of transparent tables & if it has "space" then it is not a primary key...
    Or else you can try with 'DDIF_TABT_GET'
    Or try this code
    PARAMETERS: p_table TYPE tabname OBLIGATORY.
    DATA: go_strucdescr   TYPE REF TO cl_abap_structdescr,
          gt_tab_fields   TYPE ddfields.
    FIELD-SYMBOLS: <gwa_tab_field> TYPE dfies.
    TRY .
    *   Get the details of the DDIC table
        go_strucdescr ?= cl_abap_elemdescr=>describe_by_name( p_table ).
      CATCH cx_sy_move_cast_error .
        MESSAGE 'Error while casting' TYPE 'S'. RETURN.
    ENDTRY.
    * Check if input is a DDIC table
    CHECK go_strucdescr->is_ddic_type( ) = 'X'.
    * Get the details of the table fields
    gt_tab_fields = go_strucdescr->get_ddic_field_list( ).
    * Display the Key fields of the table
    LOOP AT gt_tab_fields ASSIGNING <gwa_tab_field> WHERE keyflag = 'X'.
      WRITE: / <gwa_tab_field>-fieldname.
    ENDLOOP.

  • How to get the primary key names right for child tables?

    I have a logical model with a parent table and two child tables. The engineering strategy is "table per child". The parent has an primary key attribute. This is a screen shot:
    https://lh5.googleusercontent.com/-iKMtA3Say5c/UIkG1iktgEI/AAAAAAAAAtc/mrwFeHm4gi4/s800/child_pk_log.png
    When I engineer the model I get two primary keys with the same name name, which is the name of the parent:
    https://lh3.googleusercontent.com/-N88a9VwoPKw/UIkG1spbXpI/AAAAAAAAAtY/eonf8WdUZ6I/s800/child_pk_rel.png
    The correct names would be CHILD1_PK and CHILD2_PK. I can change the relational model by applying the naming rules but the next engineering will trash the names again.
    How can I fix this?

    Hi,
    the problem with PK name is fixed in Data Modeler 3.2.
    You can change PK name in relational model it won't be changed on next engineering
    Philip

  • How to pass the primary key from a report to multiple forms

    I am trying to build an application that tracks a person's training records. I have a report and 3 forms (all tabbed). From the report I can click the edit link to modify a person. Is there a way I can pass the primary key of the person (from the report) to the other forms? Hope what I'm trying to do is clear.
    Thanks.

    Hi,
    You can specify items from other pages also.
    Did you use that popup to pick item ?
    Did you noticed that it filter by page where your link point. You can remove filter from popup and then select other items.
    Or just manually type your item names
    Br, Jari
    Edited by: jarola on Nov 11, 2009 1:08 AM

  • How I get the primary key in a interactive report?

    hi,I'm a noob of apex.
    I want to get a Interactive report's primary key or rownum,and I try to use the f01...but it doesn't work.
    how can I do this.
    zl

    Have a look at: Re: To reference Interactive Report filtered rows in PL/SQL

  • How to get the primary key generated by an Insert?

    My classpath is correct. So does anybody knows
    Why the following lines of code do not work?
    I get this message error.
    The line incorrect is line "6".
    Exception in thread "main" java.lang.AbstractMethodError:
    com.microsoft.jdbc.sqlserver.SQLSe
    rverConnection.prepareStatement(Ljava/lang/String;I)
    Ljava/sql/PreparedStatement;
    1. String strSql;
    2. PreparedStatement stmt;
    3.
    4. strSql = "insert into MYTABLE (MYFIELD) values ('SOMESTRINGVALUE')";
    5.
    6. stmt = myConnection.prepareStatement
    7. (strSql,Statement.RETURN_GENERATED_KEYS);
    8.
    9. stmt.executeUpdate();
    10. stmt.close();
    I try to use the method
    "ResultSet getGeneratedKeys()"
    from the class Statement but without effect since the program can�t proceed from line '6'.

    Hi,
    1. String strSql;
    2. PreparedStatement stmt;3.
    4. strSql = "insert into MYTABLE (MYFIELD) values ('SOMESTRINGVALUE')";5.
    6. stmt = myConnection.prepareStatement
    7. (strSql,Statement.RETURN_GENERATED_KEYS);8.
    9. stmt.executeUpdate();
    10. stmt.close();Can your go and look Ur code @4,
    4. strSql = "insert into MYTABLE (MYFIELD) values (?)";and then before @9,
    stmt.setString(1,SOMESTRINGVALUE);
    Raju

  • Get the primary key

    Hello,
    I would like to get the primary key of a MS Access table, but the DatabaseMetaData.getPrimaryKeys(...) doesn't work. An exception is thrown.
    Anybody knows how to get the primary key of a MS Access table?
    Thanks
    Arno

    Which code threw which exception?
    Searching this forum for
    Access primary
    could help, too.

  • How to get the return values from a web page

    Hi all :
       how to get the return values from a web page ?  I mean how pass values betwen webflow and web page ?
    thank you very much
    Edited by: jingying Sony on Apr 15, 2010 6:15 AM
    Edited by: jingying Sony on Apr 15, 2010 6:18 AM

    Hi,
    What kind of web page do you have? Do you have possibility to for example make RFCs? Then you could trigger events (with parameters that could "return" the values) and the workflow could react to those events. For example your task can have terminating events.
    Regards,
    Karri

  • How to get the current week from sysdate?

    Hi sir,
    i want to know how to get the current week from sysdate?
    thanks

    Hi Nicolas
    It seems you like to check my post and also make commend ;) thanks for your attention
    Have you ever read the posts above and given solutions ?Yes, I did
    Have you read the docs ? Yes, I checked
    What's the added value here ?Did youYou shared doc with solution(long one), I shared short one which point same solution(Check what Joel posted)..So what is benefit, As you can guess oracle docs are sometimes become so complicated as specialy for beginner...(At least it was like that for me and Belive me somedocs are still sooo complicated even for oracle coworkers ) But for you I dont know ;)
    => Why writting the PS in bold ?Why.. Let me think... Ohh Maybe I am looking some questions(many) and even user get answer they should not changed status so I am reading some posts and try to get problem and loosing time..
    So I am putting that PS wiht BOLD because I dont wanna lose time my friend ;) Because While I am trying to help ppl here In same time I am trying to giving support to my customer prod systems. Which mean time is very important for me...
    Hope my answer could satisfy you..
    One important PS for you.. You may not like my posts (or someone) but my friend I become tired to read&answer and make commend to on your comment which is about my posts.
    I am not newbie in forum(At least I fell like that) and I belive I know how I should make post..
    Thank you
    Regards
    Helios

  • How to get the selection parameters from logical database into one of the t

    Hi Sap ABAP Champians,
    How to get the selection parameters from logical database into one of the tab in the tabstrip selection-screen.
    Please help me for this
    Thanks
    Basu

    Hi
    Thanks, that will work, but then I'll have to insert code into all my reports.
    I can see that "Application Server Control Console" is able to rerun a report.
    This must mean that the Report Server has access to the runtime parameters.
    But how?
    Cheers
    Nils Peter

  • How to stop the option key from changing tools when trying to subtract from a selection?

    How to stop the option key from changing my tools when I am trying to subtract from a selection?
    I'm running CS3 on Mac OS Leopard, and the automatic tool switching slows me down, but even preferences doesn't show a way to turn this off.
    Thanks for your help.

    With any marquee tool, JUST holding down the option key should not switch tools. You need to explain the problem much more carefully, It's completely impossible to tell from your description whats going wrong.
    automatic tool switching
    The only preference related to this, is to do with the SHIFT KEY - "use Shift key for tool switch".

  • How to get the date starting from 1 to the current date from the system dat

    Dear all,
    Please tell me how to get the date starting from 1 based on the system date
    and it should come with respect of time also.
    example.
    suppose today is 6 Dec, 2006
    so ABAP report should find the 1 dec. 2006.
    Please help me as soon as possible.
    Regards,

    concatenate sy-datum0(2) '01' sy-datum4(4) into v_firstdate.
    or yo ucan use the fm:
    HR_JP_MONTH_BEGIN_END_DATE
    usage:
        call function 'HR_JP_MONTH_BEGIN_END_DATE'
             exporting
                  iv_date             = sy-datum
             importing
                  ev_month_begin_date = gv_begda
                  ev_month_end_date   = gv_endda.
    Regards,
    Ravi
    Message was edited by:
            Ravi Kanth Talagana

  • How to get the extension Info from firefox? Do we have any firefox API to communicate with the browser? I couldnt see the HTML of the widget displayed in the toolbar how to access the widget using JS or any way

    How to get the extension Info from firefox? Do we have any firefox API to communicate with the browser? I couldnt see the HTML of the widget displayed in the toolbar how to access the widget using JS or any way

    Hi,
    Thanks for the suggestion. I've been playing around with some of the classes of the java.net package and java.io
    Using the URL class i can get the content of the data from a STATIC page and output that response to file so that is does not display to the client broswer.
    But this only works if the URL i give points to a static html page.
    So the problem i'm getting is if i'm righting in arguments in the URL, this means that server needs to process the arguments i give and its sends back a dynamic result. Because its dynamic the URL class can not handle this and throws me an exception everytime :(
    Have u ever tried to do some things like this?
    Rahul

  • How to get the Database type from weblogic Db connection

    I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
    What my question is how to get the database type from the connection.

    For a normal jdbc driver you can use
    Connection.getMetaData()
    To get the meta data, in particular the getDatabase...() methods.
    That might or might not work.
    However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out.

Maybe you are looking for