Help in building Toplink query with Date

Hi,
Can any anybody help me on how to build the toplink expression for the date.
We are passing the date object and I'm getting the date as (Eg:"Sat May 31 16:34:35 EDT 2008").
When I passing in like this I'm not able to det the data although I got data in the database.
Expression dateExp = builder.get(testDate").equal("zzzzz.getDate()");
Any help is appreciated.
Thanks,
Basil

Hello Basil,
Can you turn on logging and post the sql that gets generated? Also, what is the database/driver version being used, and what is the database column type for the date? This could be a problem with the precision of the date object being passed in not matching the date objects used in the database. If you read an object by its primary key, is the date infomation populated correctly?
Best Regards,
Chris

Similar Messages

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • Building a table with data from a query

    Hello group,
    Is it possible to build a table with the output from a query. We would like to build queries on precalculated data, and want to use other queries for the precalculation.
    Regards, Léon Hoeneveld

    Hi Léon,
    use transaction RSANWB.
    It should be available from 3.0.
    regards
    Siggi
    Message was edited by: Siegfried Szameitat

  • Need help in building search query

    Guys ..
    Problem Description:
    I have a huge table that is indexed using CONTEXT.
    I want to write a search query that considers the following:
    1. number of keywords match
    2. takes care of spelling mistakes, synonyms and acronyms
    3. proximity - the keywords should not be too far of each other.
    e.g. I have this phrase: "Horizontal Stabilizer Trim Brake"
    I was thinking of writing a query like:
    SELECT SCORE(1) SCORE,
    TEXT text
    FROM MY_TABLE
    WHERE CONTAINS(TEXT, '(Horz | Horizontal) ACCUM (Stab | Stabilier) ACCUM Trim ACCUM (Brk | Break)', 1) >= 0
    ORDER BY SCORE DESC
    The results doesnt look satisfactory. I have not used "near" operator as i dont know how to use it.
    Please help me as I am very much new to Oracle Text.
    -G

    Well, I'm not going to write the function for you, but we can at least talk through a general strategy.
    A lot depends on how you help your users on the front end -- for example, if they're searching a technical document, you may want to return results that aren't perfect matches but you do want to make sure the user picks 'mandatory' and 'useful' keywords in a way that lets you figure out which ones are really important. On the other hand, if you're google and have to handle queries like 'horizontal stabilizer trim brake' and 'were Pete and Jenny in the break room' then you run the risk of spending too much time looking for interesting words, almost doing a full-text search on the query trying to derive meaning.
    So I'm going to presume that you have some control over what/how the users generate their searches so that finding keywords isn't the issue.
    The plan will be to parse the query a bit to find the interesting words, clean them up, and weigh their importance, then use transformed data to build the query template to score various combinations.
    So here's some pseudocode for the function:
    function parse_query(pQueryWords in clob) returns clob as
    begin
        generate_token_list (); -- split the query into a set of individual tokens/words
        for each token in token_list
            if it's a mandatory word then accumtokenlist := accumtokenlist || ' ' || token ||'*10' -- weigh the presence of the token strongly
            if it's a useful word then accumtokenlist := accumtokenlist || ' ' || token ||'*5' -- domain-specific words are also important
            if it's a stopword or reserved word, then do not add it to the list
            if it's not on my lists, then accumtokenlist := accumtokenlist || ' ' || token
                                         and normaltokenlist := normaltokenlist ||' ' || token
        end;
        --so now, we have two lists, one for NEAR and one for ACCUM
        now build the guts of the template
            querytemplate := querytemplate || '<seq> || normaltokenlist || '</seq>';
            querytemplate := querytemplate || '<seq> || replace (accumtokenlist, ' ',' ACCUM ') || '</seq>';
            querytemplate := querytemplate || '<seq>$' || replace(normaltokenlist,' ','$') || '</seq>';
            querytemplate := querytemplate || '<seq>? || replace(replace(accumtokenlist,' ',' ?'),' ', ' accum ') || </seq>';  -- first fuzzy the words, then accum
            querytemplate := querytemplate || '<seq>? || replace(replace(normaltokenlist,' ',' ?'),' ', ' near ') || </seq>';  -- first fuzzy the words, then near
        return querytemplate
    end;So, with a 'cooked' query text that is template-friendly, all we need to do is apply a template that is aware of your inputs:
    query_Template_string := '
    <query>
       <textquery lang="ENGLISH" grammar="CONTEXT"> horizontal stabilizer*5 trim brake*10
         <progression> '
    || parse_query('horizontal stabilizer trim brake')  ||
    '     </progression>
       </textquery>
      <score datatype="INTEGER" algorithm="COUNT"/>'
    </query>So that's an example of one approach.

  • Query with date in where clause

    hi,
    i have build a view with join conditions from 8 tables. the data from this view is more then 100,000
    when i run the query with different clause its work with some seconds. but when i put date column in where cluase it sleeps.
    eg..
    where unit_id = 4 and t_id = 's09' and vb like '%amb%'
    works fine.
    where unit_id = 4 and t_id = 's09' and vb like '%amb%' and date between dt1 and dt2
    now sleep
    please ......give me some suggestions

    hi i have done the explain plan
    the result is
    Operation Object
    SELECT STATEMENT ()
    NESTED LOOPS ()
    NESTED LOOPS ()
    HASH JOIN ()
    HASH JOIN ()
    TABLE ACCESS (FULL) PR_PO_MST
    TABLE ACCESS (FULL) PR_SUPPLIER
    TABLE ACCESS (FULL) PR_PO_DTL
    TABLE ACCESS (BY INDEX ROWID) INDENT_MST
    INDEX (RANGE SCAN) ST_IND_MST_IDX
    TABLE ACCESS (BY INDEX ROWID) ST_ITEM
    Operation Object
    INDEX (UNIQUE SCAN) PK_ST_ITEM
    now wot do do????

  • Need help in optimizing the query with joins and group by clause

    I am having problem in executing the query below.. it is taking lot of time. To simplify, I have added the two tables FILE_STATUS = stores the file load details and COMM table that is actual business commission table showing records successfully processed and which records were transmitted to other system. Records with status = T is trasnmitted to other system and traansactions with P is pending.
    CREATE TABLE FILE_STATUS
    (FILE_ID VARCHAR2(14),
    FILE_NAME VARCHAR2(20),
    CARR_CD VARCHAR2(5),
    TOT_REC NUMBER,
    TOT_SUCC NUMBER);
    CREATE TABLE COMM
    (SRC_FILE_ID VARCHAR2(14),
    REC_ID NUMBER,
    STATUS CHAR(1));
    INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
    INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
    INSERT INTO COMM VALUES ('12345678', 1, 'T');
    INSERT INTO COMM VALUES ('12345678', 3, 'T');
    INSERT INTO COMM VALUES ('12345678', 4, 'P');
    INSERT INTO COMM VALUES ('12345678', 5, 'P');
    COMMIT;Here is the query that I wrote to give me the details of the file that has been loaded into the system. It reads the file status and commission table to show file name, total records loaded, total records successfully loaded to the commission table and number of records that has been finally transmitted (status=T) to other systems.
    SELECT
        FS.CARR_CD
        ,FS.FILE_NAME
        ,FS.FILE_ID
        ,FS.TOT_REC
        ,FS.TOT_SUCC
        ,NVL(C.TOT_TRANS, 0) TOT_TRANS
    FROM FILE_STATUS FS
    LEFT JOIN
        SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
        FROM COMM
        WHERE STATUS = 'T'
        GROUP BY SRC_FILE_ID
    ) C ON C.SRC_FILE_ID = FS.FILE_ID
    WHERE FILE_ID = '12345678';In production this query has more joins and is taking lot of time to process.. the main culprit for me is the join on COMM table to get the count of number of transactions transmitted. Please can you give me tips to optimize this query to get results faster? Do I need to remove group and use partition or something else. Please help!

    I get 2 rows if I use my query with your new criteria. Did you commit the record if you are using a second connection to query? Did you remove the criteria for file_id?
    select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
      from (select fs.carr_cd,
                   fs.file_name,
                   fs.file_id,
                   fs.tot_rec,
                   fs.tot_succ,
                   count(case
                            when c.status = 'T' then
                             1
                            else
                             null
                          end) over(partition by c.src_file_id) tot_trans,
                   row_number() over(partition by c.src_file_id order by null) rn
              from file_status fs
              left join comm c
                on c.src_file_id = fs.file_id
             where carr_cd = 'LIBM')
    where rn = 1;
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
    LIBM    CM_LIBM.TXT          12345678                5          4          2
    LIBM    CM_LIBM.TXT          12345677               10          0          0Using RANK can potentially produce multiple rows to be returned though your data may prevent this. ROW_NUMBER will always prevent duplicates. The ordering of the analytical function is irrelevant in your query if you use ROW_NUMBER. You can remove the outermost query and inspect the data returned by the inner query;
    select fs.carr_cd,
           fs.file_name,
           fs.file_id,
           fs.tot_rec,
           fs.tot_succ,
           count(case
                    when c.status = 'T' then
                     1
                    else
                     null
                  end) over(partition by c.src_file_id) tot_trans,
           row_number() over(partition by c.src_file_id order by null) rn
    from file_status fs
    left join comm c
    on c.src_file_id = fs.file_id
    where carr_cd = 'LIBM';
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS         RN
    LIBM    CM_LIBM.TXT          12345678                5          4          2          1
    LIBM    CM_LIBM.TXT          12345678                5          4          2          2
    LIBM    CM_LIBM.TXT          12345678                5          4          2          3
    LIBM    CM_LIBM.TXT          12345678                5          4          2          4
    LIBM    CM_LIBM.TXT          12345677               10          0          0          1

  • Doubt querying with dates

    Hi all,i have a doubt querying an sql statement which involves date.
      1  SELECT rsh.shipment_num "File#"
      2        ,mmt.transaction_date "Transaction Date"
      3  FROM rcv_shipment_headers rsh,
      4       ap_suppliers aps,
      5    po_headers_all pha,
      6    po_lines_all pla,
      7    mtl_system_items_kfv msi,
      8    rcv_shipment_lines rsl,
      9    rcv_transactions rcv,
    10    mtl_material_transactions mmt,
    11    mtl_transaction_types mtt
    12  WHERE rsh.vendor_id = aps.vendor_id
    13  AND pha.po_header_id = pla.po_header_id
    14  AND pla.item_id = msi.inventory_item_id
    15  AND pha.po_header_id = rsl.po_header_id
    16  and pla.po_line_id = rsl.po_line_id
    17  AND rsl.shipment_header_id = rsh.shipment_header_id
    18  AND rsl.item_id = msi.inventory_item_id
    19  AND rsl.to_organization_id = msi.organization_id
    20  AND rcv.shipment_header_id = rsh.shipment_header_id
    21  AND rcv.organization_id = msi.organization_id
    22  AND rcv.po_header_id = pha.po_header_id
    23  AND rcv.po_line_id = pla.po_line_id
    24  --and pla.org_id = msi.organization_id
    25  AND rsh.SHIPMENT_NUM = 'AP1005'
    26  --AND mmt.transaction_date = TO_CHAR(TO_DATE('14-SEP-2012','DD-MON-YYYY'))
    27  AND rcv.transaction_type = 'DELIVER'
    28  AND rcv.source_document_code = 'PO'
    29  --AND rcv.subinventory = 'Vessel'
    30  AND mmt.rcv_transaction_id = rcv.transaction_id
    31  AND mmt.transaction_type_id = mtt.transaction_type_id
    32* AND rcv.organization_id = 81
    SQL> /
    File#                          Transacti
    AP1005                         14-SEP-12
    AP1005                         14-SEP-12Now passing date
      1  SELECT rsh.shipment_num "File#"
      2        ,mmt.transaction_date "Transaction Date"
      3  FROM rcv_shipment_headers rsh,
      4       ap_suppliers aps,
      5    po_headers_all pha,
      6    po_lines_all pla,
      7    mtl_system_items_kfv msi,
      8    rcv_shipment_lines rsl,
      9    rcv_transactions rcv,
    10    mtl_material_transactions mmt,
    11    mtl_transaction_types mtt
    12  WHERE rsh.vendor_id = aps.vendor_id
    13  AND pha.po_header_id = pla.po_header_id
    14  AND pla.item_id = msi.inventory_item_id
    15  AND pha.po_header_id = rsl.po_header_id
    16  and pla.po_line_id = rsl.po_line_id
    17  AND rsl.shipment_header_id = rsh.shipment_header_id
    18  AND rsl.item_id = msi.inventory_item_id
    19  AND rsl.to_organization_id = msi.organization_id
    20  AND rcv.shipment_header_id = rsh.shipment_header_id
    21  AND rcv.organization_id = msi.organization_id
    22  AND rcv.po_header_id = pha.po_header_id
    23  AND rcv.po_line_id = pla.po_line_id
    24  --and pla.org_id = msi.organization_id
    25  --AND rsh.SHIPMENT_NUM = 'AP1005'
    26  AND mmt.transaction_date = TO_CHAR(TO_DATE('14-SEP-2012','DD-MON-YYYY'))
    27  AND rcv.transaction_type = 'DELIVER'
    28  AND rcv.source_document_code = 'PO'
    29  --AND rcv.subinventory = 'Vessel'
    30  AND mmt.rcv_transaction_id = rcv.transaction_id
    31  AND mmt.transaction_type_id = mtt.transaction_type_id
    32* AND rcv.organization_id = 81
    SQL> /
    no rows selectedCan anyone pls suggest me where i am doing wrong.
    Any help is appreciated,
    Thanks in advance

    You have already got your answer.
    >
    yes works out,thanks very much.May i know the reason why it didn't worked out earlier?
    Thanks
    >
    Hope, the below example will make things more clear to you.
    SQL> CREATE TABLE m003 AS
      2    (SELECT 1                                                       id,
      3            To_date('14/09/2012 23:00:00', 'dd/mm/yyyy hh24:mi:ss') dt
      4     FROM   dual
      5     UNION ALL
      6     SELECT 2,
      7            To_date('14/09/2012 00:00:00', 'dd/mm/yyyy hh24:mi:ss')
      8     FROM   dual
      9     UNION ALL
    10     SELECT 3,
    11            To_date('14/09/2012 01:00:00', 'dd/mm/yyyy hh24:mi:ss')
    12     FROM   dual
    13     UNION ALL
    14     SELECT 4,
    15            To_date('02/03/2012 23:00:00', 'dd/mm/yyyy hh24:mi:ss')
    16     FROM   dual);
    Table created.
    SQL> select * from m003;
            ID DT
             1 14-SEP-12
             2 14-SEP-12
             3 14-SEP-12
             4 02-MAR-12
    SQL> SELECT *
      2  FROM   m003
      3  WHERE  dt = To_char(To_date('14-SEP-2012', 'DD-MON-YYYY'));
            ID DT                                                                  
             2 14-SEP-12   Here, 14-SEP-2012 is a string. You are converting a string to date to compare with a column data which is a date. It does not make sense to convert to string again!
    SQL> select to_char(TO_DATE('14-SEP-2012','DD-MON-YYYY'),'DD-MON-YYYY HH24:MI:SS
    ')  from dual;
    TO_CHAR(TO_DATE('14-
    14-SEP-2012 00:00:00As you can see, TO_DATE('14-SEP-2012','DD-MON-YYYY') returns 14-SEP-2012 00:00:00.
    SQL> select * from m003
      2  where dt= TO_DATE('14-SEP-2012','DD-MON-YYYY');
            ID DT                                                                  
             2 14-SEP-12   In the above sql, it searches for the data that matches with date 14-SEP-2012 00:00:00 and hence 1 row.
    if your objective is to get the records where date is 14-SEP-2012 irrespective of the time associated with it,then write..
    SQL> select * from m003
      2  where dt >= TO_DATE('14-SEP-2012','DD-MON-YYYY')
      3  and dt < TO_DATE('14-SEP-2012','DD-MON-YYYY')+1
      4  ;
            ID DT                                                                  
             1 14-SEP-12                                                           
             2 14-SEP-12                                                           
             3 14-SEP-12     Now, what is the problem in below sql
    SQL> select * from m003
      2  where trunc(dt)= TO_DATE('14-SEP-2012','DD-MON-YYYY');
            ID DT                                                                  
             1 14-SEP-12                                                           
             2 14-SEP-12                                                           
             3 14-SEP-12   The SQL above will return same result as above BUT..
    In this case you are truncating the time for all the rows (ie time associated with the date will be 00:00:00) applying function trunc() which would be a bit slower. Moreover,
    if there is any index on this column then use of function on the column will ignore the index (if it is not a function based index).
    Hope it helps.
    Regards
    Biju

  • *Urgent* Query with dates

    Hi Gurus,
    I am having problem in developing such a query which has calculations with dates. The problem is:
    I have
    base date for example 26-feb-2006
    statring day: 4
    interval: 5
    input date: 15-mar-2006
    Now the problem is I want to get the results from the query which will start 26-feb-2006+4 which is 02-mar-2006 and calculate the interval which is 5 days from '02-mar-2006' and run it every 5 (interval) days
    02-mar-2006
    07-mar-2006
    12-mar-2006
    I hope I have cleared everything.
    Please let me know as soon as possible.
    Thanks in advance.
    Aqil

    Where is the base_date coming from?
    declare
    v_jobno number;
    dbms_job.submit(v_jobno, 'SCHEMA_NAME.sp_my_proc();',
    -- first time running I schedule for 11 pm staring in 4 days
                              trunc(sysdate+4)+23/24,
    -- here the interval
                              'trunc(sysdate+5)+23/24' );
    end;

  • ZSearch Help: Unable to attach it with Data Element XBLNR1

    Hi,
    I made a ZSearch help, which will show the contents of one field of a Ztable.
    There is a field XBLNR(Reference) with data element XBLNR1 in transaction FB50.
    I want to attach Zsearch help with it.
    I have the access key also, but when I am unable to attach Zsearch help with the data element XBLNR1 because it is not in editable mode.
    Can anyone tell me the solution?
    Or is there any other method with which I can attach Zsearch help with the screen field?
    Regards,
    Priyanka.

    Hi Priyanka,
    you can attach search help to the XBLNR element direclty.
    GO to the program SAPMF05A screen number 1010  in SE51.go to layout and double click on doc.ref field. You can assign searhelp in attributes.
    ofcourse , u need access key for this.
    hope that helps.
    regards,
    sap fan.

  • Query help on Goods Receipt Query with AP Invoice

    Looking for a little help on a query.  I would like to list all the goods receipts for a given date range and then display the AP Invoice information (if its been copied to an AP Invoice).  I think my problem is in my where clause, I plagerized an SAP query to show GR and AP from a PO as a start.  SBO 2005 SP01.  Any help would be great appreciated.  Thanks
    SELECT distinct 'GR',
    D0.DocStatus,
    D0.DocNum ,
    D0.DocDate,
    D0.DocDueDate,
    D0.DocTotal,
    'AP',
    I0.DocStatus,
    I0.DocNum ,
    I0.DocDate,
    I0.DocDueDate,
    I0.DocTotal,
    I0.PaidToDate
    FROM
    ((OPDN  D0 inner Join PDN1 D1 on D0.DocEntry = D1.DocEntry)
    full outer join
    (OPCH I0 inner join PCH1 I1 on I0.DocEntry = I1.DocEntry)
    on (I1.BaseType=20 AND D1.DocEntry = I1.BaseEntry AND D1.LineNum=I1.BaseLine))
    WHERE
    (D1.BaseType=22 AND D1.DocDate>='[%0]' AND D1.DocDate<='[%1]')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry
    FROM PDN1 WHERE BaseType=22 AND DocDate>='[%0]' AND DocDate<='[%1]'))

    Hi Dalen ,
    I  believe it is because of the condition
    (D1.BaseType=22 AND D1.DocDate>='%0' AND D1.DocDate<='%1')
    OR (I1.BaseType=20 AND I1.BaseEntry IN
    (SELECT Distinct DocEntry FROM PDN1 WHERE PDN1.BaseType=22 AND DocDate>='%0' AND DocDate<='%1'))
    Try changing
    D1.BaseType=22 OR D1.DocDate>='%0' AND D1.DocDate<='%1
    PDN1.BaseType=22 OR DocDate>='%0' AND DocDate<='%1'))
    Lets see what would be the result . Lets have some fun with troubleshooting
    See what would be the difference in the result .
    Thank you
    Bishal

  • Need help in building a Query in AR -Daywise Report wih separate outstandin

    Hi,
    I need to build a report in AR (AR-Daywise Report with separte outstanding)
    How to proceeed with sql query for getting the AR-Daywise Report with separte outstanding?
    Any help will be needful for me
    Thanks and Regards

    Post your question in the the Financials forum, you may get a better/faster response.
    Financials
    Financials
    Thanks,
    Hussein

  • Need Help in Building a Query

    Hi,
    I have a requirment where the table data looks like as below:
    COL_NAME      COL_NAME1
    RAW_SDP     FCT_SDP
    FILENAME     FILENAME
    SDPID     SDPID
    CDRID     CDRID
    ORIGINALCDRNODEID     ORIGINALCDRNODEID
    ORIGINALCDRID     ORIGINALCDRID
    SUBSCRIBERNUMBER     SUBSCRIBERNUMBER
    COL_NAME and COL_NAME1 are the 2 columns in the table
    RAW_SDP and FCT_SDP data is stored asTable Names.
    I want a scenario where i want to pick the data(shown below) as condition as COL_NAME='RAW_SDP'
    FILENAME
    SDPID
    CDRID
    ORIGINALCDRNODEID
    ORIGINALCDRID
    SUBSCRIBERNUMBER
    Any help will be benefitial
    Thanks and Regards

    Ok, first you need to be clear what you are referring to...
    By "excel file" are you referring to a CSV file (i.e. a flat file you can load in notepad and look at the data) or are you referring to a ".xls" file that is a MS Excel workbook?
    If it's a CSV/flat file then you should use external tables to read the data...
    http://www.psoug.org/reference/externaltab.html
    If it's a .xls workbook file then you will need to set up an ODBC connection and create it as an external database...
    e.g.
    1- Go to Control Panel>Administrative Tools>Data Sources (ODBC)>System DSN and create a data source with appropriate driver. Name it EXCL.
    2- In %ORACLE_HOME%\Network\Admin\Tnsnames.ora fie add entry:
    EXCL =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.0.24)(PORT = 1521))
    (CONNECT_DATA =
    (SID = EXCL)
    (HS = OK)
    Here SID is the name of data source that you have just created.
    3- In %ORACLE_HOME%\Network\Admin\Listener.ora file add:
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = <hs_sid>)
    (ORACLE_HOME = <oracle home>)
    under SID_LIST_LISTENER like:
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = d:\ORA9DB)
    (PROGRAM = extproc)
    (SID_DESC =
    (GLOBAL_DBNAME = ORA9DB)
    (ORACLE_HOME = d:\ORA9DB)
    (SID_NAME = ORA9DB)
    (SID_DESC =
    (PROGRAM = hsodbc)
    (SID_NAME = EXCL)
    (ORACLE_HOME = D:\ora9db)
    Dont forget to reload the listener
    c:\> lsnrctl reload
    4- In %ORACLE_HOME%\hs\admin create init<HS_SID>.ora. For our sid EXCL we create file initexcl.ora.
    In this file set following two parameters:
    HS_FDS_CONNECT_INFO = excl
    HS_FDS_TRACE_LEVEL = 0
    5- Now connect to Oracle database and create database link with following command:
    SQL> CREATE DATABASE LINK excl
    2 USING 'excl'
    3 /
    Database link created.
    Now you can perform query against this database like you would for any remote database.
    SQL> SELECT table_name FROM all_tables@excl;
    TABLE_NAME
    DEPT
    EMP

  • Query with date variable selection

    Greetings,
    I am having problems with a SQL Query and wondering if someone could help me out.  I have the following query and want to specify a WHERE clause and have the user select the date range they want to work with.  If I specify a date the query runs fine.  If I enter in the [%0] I get an error message saying: "incorrect syntax near '<'.
    Any help would be appreciated.
    select
    'W' as prefix,
    empid as [Employee Number] ,
    U_PayrollCat as [Payroll Category Code],
    '' as [Cost Center Code],
    ContractID as     [Job Center Code],
    Segment_0 + isnull( ActSep + Segment_1, '') + isnull(ActSep  + Segment_2, '') 
                          + isnull(ActSep + Segment_3, '') + isnull(ActSep + Segment_4, '') 
                          + isnull( ActSep  + Segment_5, '') + isnull(ActSep + Segment_6, '')
                          + isnull(ActSep + Segment_7, '') + isnull(ActSep  + Segment_8, '')
                          + isnull( ActSep + Segment_9, '') as [GL Account Code],
    quantity as Units,
    U_NBS_ITEMCOST/quantity as Rate,
    U_NBS_ITEMCOST as Amount,
    oclg.notes as Comments,
    oclg.recontact as [WorkDate],
    '' as[Department code]
    from
    oclg inner join
    dln1 on dln1.docentry =oclg.docentry inner join 
    odln on odln.docentry = dln1.docentry inner join
    ohem on ohem.userid = oclg.attenduser
    inner join oitm on oitm.itemcode = dln1.itemcode
    inner join oscl on oscl.callid = odln.U_NBS_S1Link
    inner join OACT on  OACT.AcctCode = dln1.cogsAcct
    inner join oadm on 1=1
    WHERE
    oclg.recontact >= [%0] AND oclg.recontact <= [%1]

    Gordon,
    That worked with a few modifications.  Removed comma on line before FROM clause and my UDF for Payroll Category is on my OITM table.  Complete Query looked like this:
    SELECT 'W' as prefix, t3.empid as 'Employee Number',
    t4.U_PayCat as 'Payroll Category Code',
    t5.ContractID as 'Job Center Code',
    t6.Segment_0 + isnull( ActSep + t6.Segment_1, '') + isnull(ActSep + t6.Segment_2, '')
    + isnull(ActSep + t6.Segment_3, '') + isnull(ActSep + t6.Segment_4, '')
    + isnull( ActSep + t6.Segment_5, '') + isnull(ActSep + t6.Segment_6, '')
    + isnull(ActSep + t6.Segment_7, '') + isnull(ActSep + t6.Segment_8, '')
    + isnull( ActSep + t6.Segment_9, '') as 'GL Account Code',
    t1.quantity as Units,
    t1.U_NBS_ITEMCOST/t1.quantity as Rate,
    t1.U_NBS_ITEMCOST as Amount,
    t0.notes as Comments,
    t0.recontact as WorkDate
    from dbo.oclg t0
    inner join dbo.dln1 t1 on t1.docentry =t0.docentry
    inner join dbo.odln t2 on t2.docentry = t1.docentry
    inner join dbo.ohem t3 on t3.userid = t0.attenduser
    inner join dbo.oitm t4 on t4.itemcode = t1.itemcode
    inner join dbo.oscl t5 on t5.callid = t2.U_NBS_S1Link
    inner join dbo.OACT t6 on T6.AcctCode = t1.cogsAcct
    inner join dbo.oadm t7 on 1=1
    WHERE t0.recontact >= '[%0]' AND t0.recontact <= '[%1]'
    Thanks for the help,
    Aaron

  • Oracle OCI: Problem in Query with Date field

    Client compiled with OCI: 10.2.0.4.0
    Server: Oracle9i Enterprise Edition Release 9.2.0.4.0
    The problematic query is:
    SELECT CODIGO FROM LOG WHERE TEL = :telnumber AND DATE_PROC = '05-JUL-08'Table description:
    SQL>describe LOG;
    TEL NOT NULL VARCHAR2(15)
    CODIGO NOT NULL VARCHAR2(20)
    DATE_PROC NOT NULL DATEAs simple as it might look, when executed directly on the server with SQLPlus, it returns a result, but when executed from the app that uses OCI, this query returns OCI_NO_DATA always. In the beginning, the date value was also a placeholder, but I found out that even giving a literal like '05-JUL-08' didn't work. I have tried the following:
    <ul>
    <li>I've tried the basics: querying the DB from the client does work. It's this one that gives me trouble</li>
    <li>The query: SELECT CODIGO FROM LOG WHERE TEL = :telnumber does work</li>
    <li>Executing: ALTER SESSION SET NLS_DATE_FORMAT="DD-MM-YYYY"; before the query in both the server and the client. Same result: server returns data, client OCI_NO_DATA</li>
    <li>Tried changing DATE_PROC format, combining this with the use of TO_DATE(). Same result.</li>
    <li>Searched, searched, searched. No answer</li>
    </ul>
    I'm a bit desperate to find an answer, would appreciate any help and can provide as many further details as needed. Thanks.
    Edited by: user12455729 on Jan 15, 2010 5:59 AM. -Formatting-

    Hi,
    I've recreated your table and populated with your data.
    I've run your select using OCILIB on a 10gR2 (client and server) and the codes runs fine and give expected results.
    So the problem must resides in your code.... (i don't think it can be a OCI bug)
    Here is the ocilib code :
    #include "ocilib.h"
    int main(void)
        OCI_Connection *cn;
        OCI_Statement *st;
        OCI_Resultset *rs;
        char msisdn[100] = "11223344";
        char datetime[100] = "";
        if (!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
            return EXIT_FAILURE;
        cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
        st = OCI_StatementCreate(cn);
        OCI_Prepare(st, "SELECT "
                        "  CODIGO_BANCO "
                        "FROM "
                        "  VTA_LOG "
                        "WHERE "
                        "  TELEFONO = :msisdn AND "
                        "  FECHA_PROCESO = TO_DATE(:datetime, 'YYYYMMDDHH24MISS')");
        OCI_BindString(st, "msisdn", msisdn, sizeof(msisdn)-1);
        OCI_BindString(st, "datetime", datetime, sizeof(datetime)-1);
        strcpy(datetime, "20080705162918");
        OCI_Execute(st); 
        rs = OCI_GetResultset(st);
        OCI_FetchNext(rs);
        printf("%s\n", OCI_GetString(rs, 1));
        strcpy(datetime, "20080705062918");
        OCI_Execute(st); 
        rs = OCI_GetResultset(st);
        OCI_FetchNext(rs);
        printf("%s\n", OCI_GetString(rs, 1));
        OCI_Cleanup();
        return EXIT_SUCCESS;
    }Output is :
    BancoOne
    BancoTwoi recreated your data with
    create table VTA_LOG
         TELEFONO          VARCHAR2(15) NOT NULL ,
         CODIGO_BANCO     VARCHAR2(20) NOT NULL ,
         FECHA_PROCESO     DATE NOT NULL
    insert into VTA_LOG values ('11223344', 'BancoOne',  to_date('20080705162918', 'YYYYMMDDHH24MISS'));
    insert into VTA_LOG values ('11223344', 'BancoTwo', to_date('20080705062918', 'YYYYMMDDHH24MISS'));
    commit;Regards,
    Vincent

  • Query with dates

    hi every body
    i want to select date from today_date(column) from patients(table)
    select today_date from patients where today_date = 17||''||12||80 ;
    the problem is that i tried this in sql (example) 17||''||12||80 and it worked
    but
    when i changed the (12) to (02) refer to (february not december) there was an error
    ( literal does not match format string) -- error
    why that happened
    thanks a lot

    Hi,
    semsem wrote:
    i am sorry for u all but non of u got me
    i said that i did that in sql because we are in sql forum
    but clearly i need that in forms builder , if u know about that It may be clear to you, but if you don't say you're using Forms Builder, why would anyone guess that? If you want help with your problem, then say what your problem is.
    i have 3 list items in my form (1,2,3)
    1- hold the value for days
    2- the value for months
    3- for years
    and i wanna choose the date from the database from today_date(column) from patients(table) where
    today_date = :list1||:list2||list3 In case it's not clear from the earlier replies, the different data types are not all the same. It may matter what kind of data type you're using in any given expression.
    What are the data types of :list1, :list2 and :lsit3?
    If they are all strings (e.g. VARCHAR2 or CHAR), then this example from my previous message applies:
    Frank Kulash wrote:
    WHERE      today_date = TO_DATE ( '17' || '02' || '80'
                             , 'DDMMRR'
                        ) but instead of the string literals '17', '02' amd '80', use your variables :lsit1, :lsit2 and :list3. You many want to do this:
    WHERE      today_date = TO_DATE ( :list1 || :list2 || :list3
                             , 'DDMMRR'           -- 2-digt years are a very bad idea
                        ) assuming that
    :list1 represents the day, :list2 represents the month, and :lsit3 represents the year. A lot of folks would use variable names that mean something, like
    :day, :month and :year, or
    :target_day, :target_month and :target_year.
    If the data type of all 3 variables is NUMBER, then this example from my previous message appplies:
    WHERE      today_date = TO_DATE ( TO_CHAR (17, 'FM00') ||
                               TO_CHAR (02, 'FM00') ||
                          TO_CHAR (80, 'FM00')
                             , 'DDMMRR'
                        )Again, you have to use your variables in place of the literals, so you'd do something like:
    WHERE      today_date = TO_DATE ( TO_CHAR (:list1, 'FM00') ||
                               TO_CHAR (:list2, 'FM00') ||
                          TO_CHAR (:list3, 'FM00')
                             , 'DDMMRR'          -- 2-digit years are simply asking for trouble
                        )

Maybe you are looking for

  • Ctrl Alt Del and Task manager not working

    Hi, Ive been having a problem getting task manager to run at all. On a fresh reboot, if I use the ctrl alt del function the according screen will come up like normal, and I will click on task manager. It bring me back to my desktop and nothing pops u

  • Classic App wizard page errors out from workspace

    I am trying to launch the classsic application wizard page(under Navigate->Administer) from Worspace and it keeps erroring out. I dont get any detailed message , but it says" An error occurred while processing the page.Check the log for details". And

  • Window priority -- opens behind current application -- help

    Hi. I've had a mac for a few months now, but I think I've broken something. I have a vague recollection of changing some sort of windows compositor thing by following instructions on a site somewhere. The problem that I'm having now is that windows a

  • Simple Led Display

    Hello, I am new in labview iam learning only 2 weeks. If someone have little time to help i will be realy thankful. I need help with simple led display. Display should have maximum 20columns and 40rows, user should choose the size of display. After r

  • 2k classpath limitation workaround not working

    Hello I am aware of the 2k limitation in installing weblogic as win2k service. The suggested workaround for that as per the documentation is to provide a '@filename' paramater. But looks like it is not picking up the ''myclasspath.txt' This file is i