How to use primary key in sql combined from 2 columns

table1
primary key = orderid+custname
orderid custname address
8889 Adrian london
8867 Clara manchester
2229 Peter warwick
table2
primary key = orderid+custname
orderid custname qty price
8889 Adrian 10 2500
8865 Adrian 20 9483
8867 Clara 30 3993
5869 Clara 15 1828
2290 Peter 10 2102
2298 Peter 13 3839
then how do i query ?
SQL> select t1.orderid, t1.custname, t1.address, t2.qty, t2.price from
table1 t1, table2 where ? = ?
what's the "?" should be ????
it doesn't work if i enter the primary constraint key for each table.
thanks.

thanks, it works ;)
btw, do you know how about the date field ?
what if one of the field in table1 is 12/12/2005 14:30
and table2 is 15/12/2005
table1
orderid orderdate
1234 12/12/2005 14:30
2234 15/12/2005 13:45
table2
orderid orderdate
1234 12/12/2005
2234 15/12/2005
so the query
select t1.orderid as t1 t1.orderdate , t2.orderid as t2, t2.orderdate from
table1 t1, table2 t2 where t1.orderid = t2.orderid
and to_char(to_date(t1.orderdate, 'dd/mm/yyyy hh24:mi'), 'dd/mm/yyyy') = t2.orderdate
thanks.

Similar Messages

  • How to use the EBS PL/SQL API from outside PL/SQL

    Hi,
    our attempts to call the stored procedures/functions of the EBS PL/SQL API via JDBC revealed the following issues:
    1. Logical values cannot be exchanged through boolean parameters as the OCI has no notion of this type. Instead we need to write PL/SQL wrappers converting boolean to integer and vice versa. Is that true or are we missing something?
    2. Complex values cannot be exchanged through record types as only PL/SQL code has a notion of this type. Instead we need to write PL/SQL wrappers converting record values to object type values. Is that true or are we missing something?
    3. Types must be defined outside of packages, i.e. in the schema, for whatever reason. Instead we need to write PL/SQL wrappers converting values of types defined in packages to values of types defined in the schema. Is that true or are we missing something?
    4. It is possible to let functions return tables so the results can be queried using SELECT * FROM TABLE. Such functions are called "table functions". Is there something similar for the other direction, i.e. is it possible to call a stored procedure and pass in a table value through an sql INSERT statement?
    5. Do we really have to write all those wrapper routines on our own or is there a PL/SQL library providing such? If not, is there some kind of code generation facility that can generate such wrappers?
    Thanks and Regards,
    Konrad

    Hi Helios,
    I belive its better to move your issue on Forum Home » Database » SQL and PL/SQL which you can get more quick responseYou are probably right! I was thinking about a different forum but I did not see this one. I just posted the question there...
    Still, if somebody has an idea here as well, just let me know ;-)
    Konrad

  • How do I use Primary Key and RowID in Materialized View Logs and MVs

    How do I use Primary Key and RowID in Materialized View Logs and Materialized Views????
    I don’t understand in the Materalized View Logs the diference between Primary Key and RowID. Besides, I could choose both Primary Key and RowID.
    When I have to use RowID?? Why?? And Primary Key??? And both, Primary Key and RowID????
    Thank you very much!

    Yes, I have already read it...
    But for example I don’t Understand:
    This is the example 8-1
    CREATE MATERIALIZED VIEW LOG ON products
    WITH SEQUENCE, ROWID
    (prod_id, prod_name, prod_desc, prod_subcategory, prod_subcat_desc, prod_
    category, prod_cat_desc, prod_weight_class, prod_unit_of_measure, prod_pack_
    size, supplier_id, prod_status, prod_list_price, prod_min_price)
    INCLUDING NEW VALUES;
    But if I create a Materialized View with TOAD if I choose a KEY field I receive the error:
    ORA-12026: invalid filter column detected
    Then I have to take out the Key (in the above example prod_id)
    And then the script is
    CREATE MATERIALIZED VIEW LOG ON products
    WITH ROWID, SEQUENCE, PRIMARY KEY!!!!!!!!!!!!!!!!!!!!
    (prod_id, prod_name, prod_desc, prod_subcategory, prod_subcat_desc, prod_
    category, prod_cat_desc, prod_weight_class, prod_unit_of_measure, prod_pack_
    size, supplier_id, prod_status, prod_list_price, prod_min_price)
    INCLUDING NEW VALUES;
    I have PRIMARY KEY in the definition (I don’t choose it) and I don’t have the prod_id field
    Why is it????
    Note: If I execute the script to create the MV Log manually the PRIMARY KEY option NO IS in the script and the prod_id field either is in the script.
    And on the other hand,
    What is this:
    CREATE MATERIALIZED VIEW LOG ON sales
    WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON times
    WITH ROWID;
    CREATE MATERIALIZED VIEW LOG ON customers
    WITH ROWID;
    These MATERIALIZED VIEW LOG contain any fields????
    Or it contain the primary key fields of this tables (sales, times and customers)??? Then, Why is it ROWID instead of PRIMARY KEY????
    Thanks!

  • How to find Primary Key for a particular SAP Databse Table?

    Hi Guys,
                  How to find Primary Key and foreign key  for Particular SAP Databse table ?for Ex : EKKO , EKPO , EKKN , EKBE , EKBEH  , EKET and EKETH.
    Thanks,
    Srinivas.

    Use transaction SE11 to display the table. Put the cursor on the field you want to display the check table and click 'Foreign key' push button (a key with an bottom point arrow), then it will show the check table of the foreign of a field.
    Or by just simple double click on the field, a pop-up window of all the attribute (including the foreign key and the check table if exists) will show too.
    <i><b>Please reward point for helpful answer.</b></i>
    Minami

  • Creating an unique index instaed of using primary key index

    Hi ,
    I heard in a debate sometimes it's better to create a unique index on a column and using it instaed of using primary key index in oracle.I couldn't understand what the reason propely.
    Can anyone please help me in thsi topic if it is a valid one .
    Thanks in advance

    Hi,
    They are exactly NOT identical.
    1. Unique key can have NULL values where primary keys can't.
    2. Primary key is fundamentally those keys which do not change. I mean updating a primary key is not a good idea.
    SQL> drop table test;
    Table dropped.
    SQL> create table test ( a number(2));
    Table created.
    SQL> ed
    Wrote file afiedt.buf
      1* create unique index test_idx on test(a)
    SQL> /
    Index created.
    SQL> ed
    Wrote file afiedt.buf
      1* insert into test values(NULL)
    SQL> /
    1 row created.
    SQL> drop table test;
    Table dropped.
    SQL>
    SQL> create table test ( a number(2) primary key);
    Table created.
    SQL> insert into test values(NULL);
    insert into test values(NULL)
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("HR"."TEST"."A")
    SQL>Cheers,
    Edited by: Avinash Tripathi on Nov 24, 2009 11:17 AM

  • How to use a key file in the FTP Task using and SSL connection

    In the past I have used this code to set the FTP pass word in an FTP component task in SSIS.
    Does anyone know how to use a Key file in an SSL connection to download a file from an FTP site?  If not can you tell me where I can get the C# code examples to learn how to create a script task or if there is another way in SSIS to download large files
    from an SSL FTP site?  Thank you for any help offered.
    public void Main()
    ConnectionManager FTPConn;
    FTPConn = Dts.Connections["FTPServer"];
    FTPConn.Properties["ServerPassword"].SetValue(FTPConn, Dts.Variables["FTPPassword"].Value);
    Dts.TaskResult = (int)ScriptResults.Success;
    Antonio

    You can use SFTP for this.
    This is a way of implementing SFTP in SSIS using standard tasks 
    http://visakhm.blogspot.in/2012/12/implementing-dynamic-secure-ftp-process.html
    also see
    http://blog.goanywheremft.com/2011/10/20/sftp-ftps-secure-ftp-transfers/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to use OEM to moniter sql server 2000

    Hi,
    I need to learn How to use OEM to moniter sql server 2000.
    Can anyone help me and give me some website or documents
    to read?
    So I can learn to do this job.
    Thanks.

    See Note 115302.1 in Metalink.oracle.com
    in how to use OEM Diagnostic pack addon for SQL Server
    Or search for
    oem "user events"
    to build your own monitor script.

  • How we use Surrogate Keys for snowflake dimension

    Hi All,
    my question is - How we use  Surrogate Keys for  snowflake dimension
    i heard from some body Surrogate Keys only work with star schema.
    please correct me if i wrong.
    Regards,
    Manish

    Hi manishcal16PPS,
    According to your description, you can only create natural key in your dimension. But it's not working when using surrogate key. Right?
    In Analysis Services, the snowflake schema of the dimensions are represented by more than one dimension table in other words its takes multiple dimension tables to define a dimension. Surrogate key are just some extra, redundant, unique key based on the
    natural key. So there's no direct relationship or some limitations between surrogate keys and snowflake schema.
    In this scenario, since there's relationship between the two dimensions, you should create natural key. For using natural key or surrogate key. Please refer to an article below:
    Surrogate Key vs. Natural Key
    For understanding star/snowflake schema, please see:
    Understanding Star and Snowflake Schemas 
    Regards,
    Simon Hou
    TechNet Community Support

  • How to set primary key of the VO.

    I have a problem with the master detail search. The search works fine on the first search, all details can be seen fine, but in the second search I get this error.
    The number of displayed records, 1, exceeds the actual number of records, 0, in view object EgoItemAdvancedSearchAM.MYACCESSOR001_MYLINK001_DetailsOrderLinesVO. Some of the displayed records may have been deleted.
    Somwhere in another thread, someone had the same problem and the soultion was to set primary key of the master VO. I am not sure how to set primary key of a VO. In my case the master VO is dynamic. Is there a way I can set PK of a dynamic VO.
    Any help greatly appreciated.

    Hi
    Thanks for your reply...
    am seting the primary key to VO attribute in my controller(PR)...but its not mapping to the VO attribute..
    OAAttachmentImageBean Ibean = (OAAttachmentImageBean)webBean.findChildRecursive("OpAttachments");
    String[] pkvaule = {"ResAttribute15"};
    Ibean.setPkColumns(pkvaule);
    Regards
    Harrrry

  • How to Use "Hot Key" in the Search help

    Hi,
    Please explain how to use hot key with some example.

    TYPE-POOLS SLIS. DATA: BEGIN OF itab OCCURS 0,
            BUKRS LIKE T001-BUKRS,
            BUTXT LIKE T001-BUTXT,
          END   OF itab.
    PARAMETERS: P_BUKRS TYPE BUKRS.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_BUKRS. 
    PERFORM F4_FOR_BUKRS.
    FORM F4_FOR_BUKRS.   DATA: IT_FIELDCAT TYPE  SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
            ES_SELFIELD TYPE  SLIS_SELFIELD. * Get data
      SELECT BUKRS
             BUTXT
             FROM T001
             INTO TABLE itab
             up to 10 rows .
    Get field
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME     = SY-REPID
                I_INTERNAL_TABNAME = 'ITAB'
           CHANGING
                CT_FIELDCAT        = IT_FIELDCAT[].   LOOP AT IT_FIELDCAT.
        IT_FIELDCAT-KEY = SPACE.
        IF IT_FIELDCAT-FIELDNAME = 'BUTXT'.
          IT_FIELDCAT-EMPHASIZE  = 'C710'.
          IT_FIELDCAT-HOTSPOT = X.
        ENDIF.
        IF IT_FIELDCAT-FIELDNAME = 'BUKRS'.
          IT_FIELDCAT-EMPHASIZE  = 'C610'.
        ENDIF.     MODIFY IT_FIELDCAT.
      ENDLOOP.   CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
        EXPORTING
    I_TITLE                       = 'THIS IS FOR F4 IN COLOR'
          I_TABNAME                     = 'ITAB'
          IT_FIELDCAT                   = IT_FIELDCAT[]
        IMPORTING
          ES_SELFIELD                   = ES_SELFIELD
        TABLES
          T_OUTTAB                      = ITAB . ENDFORM.                    " F4_FOR_BUKRS

  • Documentation How to use Virtual Key fig.

    Hi all ,
    Can u please send me Documentation How to use Virtual Key fig. to [email protected]
    Nice weekend.

    check this doc to get a headsup on Virtual objects - though the doc talks abt the virtual char, the procedure is pretty much similar to KF too.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/how%20to%20use%20variable%20time%20references%20in%20currency%20conversion
    How to implement Virtual Characteristics or Virtual key figures

  • Primary key violation exception in auto increment column

    Hi All,
    I am facing one issue in Multi threaded environment.
    I am getting Primary key violation exception in auto increment column. I have a table and the primary key is the auto increment column, and I have a trigger which is populating this column.
    5 threads are running and inserting the data in the table and throwing Primary key violation exception randomly.
    create table example (
    id number not null,
    name varchar2(30)
    alter table example
    add constraint PK1example primary key (id);
    create sequence example_id_seq start with 1 increment by 1;
    create or replace trigger example_insert
    before insert on example
    for each row
    begin
    select example_id_seq.nextval into :new.id from dual;
    end;
    Any idea how to handle auto increment column(trigger) in Multi threaded environment??
    Thanks,

    user13566109 wrote:
    Thanks All,
    Problem was in approach; removed the trigger and placed a seq.nextval in insert query. It has resolved the issue.I very much suspect that that was not the issue.
    The trigger would execute for each insertion and the nextval would have been unique for each insertion (that's how sequences work in oracle), so that wouldn't have been causing duplicates.
    I suspect, more likely, that you had some other code somewhere that was using another sequence or some other method of generating the keys that was also inserting into the same table, so there was a conflict in the sources of the sequences being generated.
    The way you showed you had coded above, was a perfectly normal way to assign primary keys from a sequence, and is not a problem in a multi user/threaded environment.

  • QuestionJust purchased a USB Super Drive but unsure how to use it - o instructions provided apart from how to eject a cd.  Each time I put in a cd it just ejects it again.

    Just purchased a USB Super Drive but unsure how to use it - o instructions provided apart from how to eject a cd.  Each time I put in a cd it just ejects it again.Can anyone help.

    USB is rarely bootable under Mac OS X and PowerPC Macs.   Get a Firewire Superdrive from http://www.macsales.com/ if your intent is to boot the machine.   PPC, which is PowerPC, indicates the Mac predates 2006.

  • Help me!    How to use it as a web service from third party application?

    After using JDeveloper to develop BSSV object e.g. JP550010, how to use it as a web service from third party application?
    TKS!

    Obviously the OP is working on a project for the Bead Society of Southeastern Virginia http://www.bssv.org. Oh, wait, maybe he's researching the Blueberry Shoestring Plant Virus http://abbreviations.yourdictionary.com/bssv
    :D
    John

  • How to use utl_ftp package to transfer files from one system to another

    Hi all,
    How to use utl_ftp package to transfer files from one system to another using plsql procedure .
    I failed to find the appropriate document ,kindly help me .
    Thanks,
    P Prakash

    prakash wrote:
    I am sorry tell you, this blog is not enough to for me.It's not a blog, it's Chris' website where you download the package from. Once you download the package and unrar it, then the package spec gives instructions (and I think there's instructions on how to install it too).
    Kindly let me know if there is any oracle documentation for this .It's not an Oracle created package, it was created by Chris. It's based around the UTL_TCP package if you really want to get into the nitty gritty of how it works, but I don't think you do.

Maybe you are looking for

  • Query performance.

    Hi I have created a procedure that accepts two bind variables from a report. The user will select one or the other, both or neither of the variables. To return the appropriate results i have created a view with the entire result set and in the proced

  • How can I find and remove viruses from my mac

    I fear that I might have a virus on my beloved macbook pro. i message was spassing out and not sending my messages, my folders continue to dissapear from my desktop causing me to restart finder (not a big deal just annoying) and some other out-of-pla

  • Linkage of employee field P0000-STAT2 in vendor master

    Hello, I want to know linkage of employment status field to vendor master in case employee is linked to vendor. Field of employment status in HR master record is P0000-STAT2. We have vendor master against each HR master record. In case employee is se

  • How to drop mobr5 sehema in mobiliser 5.1 sp02

    Hi Experts, I want to recreate the database schema mobr5. So how can I delete the mobr5 schema completely? Thanks and Regards, Sagar M Patil

  • How could I install a plug in for Aperture?

    how could I install a plug in for Aperture?