Sql gurus help needed.. simple but awkward

Im trying to use dates stored in a char field...field called segment1
2006/09/11 00:00:00 This is the format they are being stored as
When i select this data im converting to date format to make it look good to_date(tppc.segment1,'YYYY-MM-dd:HH24:MI:SS')
The problem is in the where clause, when i goto put a condition in its like it does not recognise the date format.....
so where to_date(tppc.segment1,'YYYY-MM-dd:HH24:MI:SS') = '31-OCT-2008' ..... error - ORA-01841: (full) year must be between -4713 and +9999
so where to_date(to_date(tppc.segment1,'YYYY-MM-dd:HH24:MI:SS'),'DD-MON-YYYY') = '31-OCT-2008' again error ORA-01841
I have checked all the data and the format 2006/09/11 00:00:00 is the same in all records...
Does someone know what to do ....
Data Output ---- TO_CHAR(to_date(tppc.segment1,'YYYY-MM-dd:HH24:MI:SS'),'DD-MON-YYYY') - 11-SEP-2006

Hi Sharky,
Are you completely sure that all of the records in your table contain properly formated date strings in segment1?
you can check it with a simple function:
create or replace FUNCTION "VALIDATE_DATE"
    (   date_String VARCHAR2,
        format      VARCHAR2 := 'dd-mon-yyyy' )
    RETURN VARCHAR2
    DETERMINISTIC
IS
    dt DATE;
BEGIN
    dt := to_date( date_string, format );
    RETURN 'Y';
EXCEPTION
    WHEN OTHERS THEN
        RETURN 'N';
END;
/which you use to select records which have invalid dates like so:
select *
  from your_table
where validate_date(segment1, 'YYYY-MM-dd:HH24:MI:SS')='N';The next thing to consider is that when you use a to_date function on segment1 you are converting it to a date data type, but in your comparisson you are comparing that data data type to a string constant. To perform the equality test Oracle needs to change the data type of one side of the equality to match the data type on the other side of the equality. Generally speaking you should explicitly convert one of them to match the other. For example you should wrap your string constant in a to_date function so you end up comparing two dates, or since the segment1 value is already in a canonical date format, you could change your string constant to the same canonical date format removing the to_date off of segement1 so you are just doing a string comparison.

Similar Messages

  • SQL Server2008 help needed

    Having trouble with SQLServer 2008 (not MySQL) and my database connection in Dreamweaver CS6.  My document type is set as .asp using VBScript.  I can list the table information  but cannot use the insert wizard to add new records.  I don't get any errors after creating the insert form, but no records get inserted.  I'm not a VBScript expert, but do I have to manually write some code to insert records?  How do I attach it to a button?

    Thanks for the quick reply.  I won't be back in the office for a few days, but I'll try to post it when I get back in.  It's pretty much the code generated from the Dreamweaver Insert Record wizard.  I see where the submit button is created and the value is set but the action on the form is set to MM_insert, so I don't see where the submit code is actually called.
    Date: Wed, 3 Oct 2012 12:06:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: SQL Server2008 help needed
        Re: SQL Server2008 help needed
        created by bregent in Dreamweaver General - View the full discussion
    This post should be moved to the app dev forum.  Please post the code from your form and the insert script pages.
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/4746757#4746757
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4746757#4746757
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4746757#4746757. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver General by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Simple SQl statement help needed!!!

    New to SQL..Please can you advice where is the problem..
    select file_id, a.file_name, a.sum(bytes/1024/1024) Used_space, b.sum(bytes/1024
    /1024) Free_space from dba_data_files a, dba_free_space b where tablespace_name
    ='DATA_TS' OR tablespace_name='INDEX_TS' OR tablespace_name='LOB_TS' group by fi
    le_id
    ERROR at line 1:
    ORA-00918: column ambiguously defined
    Thanks!

    Hi,
    Should you chose to format your SQL the problem is easily seen:
    SQL>select file_id
      2          ,a.file_name
      3          ,a.sum(bytes / 1024 / 1024) used_space
      4          ,b.sum(bytes / 1024 / 1024) free_space
      5      from dba_data_files a, dba_free_space b
      6     where tablespace_name = 'DATA_TS'
      7        or tablespace_name = 'INDEX_TS'
      8        or tablespace_name = 'LOB_TS'
      9  group by file_id;
    group by file_id
    ERROR at line 9:
    ORA-00918: column ambiguously defined
    SQL>So, which file_id do you want - a or b?
    Regards
    Peter

  • Sql loader help needed  urgent

    Hi,
    I normally get a csv having data as
    column1 ;columnb;columnc;
    13 ; 12 ; 13 ;
    11 ;13 ;33;
    as the table where it needs to go is say table
    xys( a number, b number , c number).
    so the control file is fairly simple ...
    But from now I need to restrict data entry if the change in format happens in the csv
    say if it is like
    column2;column1;column3,
    12,13;12;
    11;13;14;
    or say the csv like
    column1;column2;column3;column4;
    11;13;14;15;
    111;134;14;12;
    in both cases sql loader should not run and throw the error saying the reason in the log.
    how do i manage it in the control file `???
    any ideas???
    regards
    Message was edited by:
    SHUBH

    Hello,
    do you only need to check the first line of the file if it contains a line like
    column1;column2;column3 ?
    If yes, maybe a small script like this could be a starting point:
    You have to replace "column1;column2;column3" with the header information that's valid and instead of file1 in the CURRENTSTRING=... Line write the name of your input file.
    I hope this helps. (But maybe some of the experts here knows a way to do the verification checks with SQLLDR, so maybe its worth to wait a little bit :)
    #!/bin/ksh
    VALIDSTRING="column1;column2;column3"
    CURRENTSTRING=`head -n 1 file1`
    if [[ $VALIDSTRING == $CURRENTSTRING ]]
    then
    echo "They match."
    else
    echo "They dont match."
    fi
    --

  • Help, need simple instructions on how to use numbers with keyboard.

    I just got Numbers for IPAD 2 and I am new to Spreadsheets in general.  I simply cannot understand how to use this program with my mini external keyboard (gotten from Apple)  to make it do what I need it to do.  I am trying to set up a spreadsheet for my Jewelry Design Business.  It's an inventory Spreadsheet, listing each item, the number of the item, the title, description, price and final sold price and type of Jewelry.  I need the two price columns to add the sum of all the jewelry in each row, which by some miracle I was actually able to do.  What I am having trouble with is getting it to automatically change to dollars for the two price columns without having to touch the dollar sign on the formula bar each time I enter a new item, and getting it to jump from the last cell in the last column to the first cell of the first column when I am finished with a row and need to go to the next item.  What it does do is either jump to the cell right beneath it, or go backwards, or sometimes it does go to the first cell of the next line, but I don't know what I am doing to make that happen.  Anyway being new to this all, it is obvious I need specific simple instructins on how to use this program. Does anybody know where I can find some help?

    IMHO, forget about doing any meaningful Excel work an iPad unless you want to be a slave and spend 3-4 times the amount of time it would take to do inputs on a normal computer.  Now, IF there was mouse support, then it might be worth the effort.  I tried it and gave up.

  • SQL statement help needed

    I am sure some of you will laugh lol, but I am drawing a blank and need some assistance if anyone is willing to help:
    I have this query:
    SELECT DISTINCT ID
    FROM (SELECT productcode
    FROM sforce_product2
    WHERE productcode NOT LIKE 'DSXXX%'
    AND productcode NOT LIKE 'DO NOT USE%'
    AND productcode NOT LIKE 'MAXXXX%'
    AND isactive = 'true'
    MINUS
    SELECT productcode
    FROM vew_product_export) a,
    sforce_product2
    WHERE a.productcode = sforce_product2.productcode
    which returns 112 ID's (which is wrong)
    The inner SELECT statement:
    SELECT productcode
    FROM sforce_product2
    WHERE productcode NOT LIKE 'DSXXX%'
    AND productcode NOT LIKE 'DO NOT USE%'
    AND productcode NOT LIKE 'MAXXXX%'
    AND isactive = 'true'
    MINUS
    SELECT productcode
    FROM vew_product_export
    returns 106.
    Am I doing something simple wrong or is my query just mangled!
    TIA,
    Mike

      SELECT DISTINCT ID
        FROM (SELECT productcode
                FROM sforce_product2
               WHERE productcode NOT LIKE 'DSXXX%'
                 AND productcode NOT LIKE 'DO NOT USE%'
                 AND productcode NOT LIKE 'MAXXXX%'
                 AND isactive = 'true'
              MINUS
              SELECT productcode
                FROM vew_product_export) a,
              sforce_product2
       WHERE a.productcode = sforce_product2.productcodethe above code is returning an ID column which i think most probable from the sforce_product2 table
    while this query below returns the 106 value that is coming from the column productcode.
      SELECT productcode
        FROM sforce_product2
       WHERE productcode NOT LIKE 'DSXXX%'
         AND productcode NOT LIKE 'DO NOT USE%'
         AND productcode NOT LIKE 'MAXXXX%'
         AND isactive = 'true'
      MINUS
      SELECT productcode
        FROM vew_product_exportso i think there is nothing wrong because if you will review the 112 is from the column ID while the 106 is from the column productcode.

  • SQL Syntax - help needed

    Guys,
    Help me understand the syntax please!! With PL/SQL I have achieved a task quite easily, with a branch of code to include or exclude some part of the query - no problem. But to use SQL ......
    If i have a variable on a page, say :p10_open_or_closed
    .. and I set the value of this to the text "Is Not Null"
    How can I incorporate this into an SQL query, say
    Select ID, Date1, Date2, Comment
    From Table1
    where Date1 Is Not Null
    Is there a way of substituting the ":p10_open_or_closed" variable into this query?
    ie
    Select ID, Date1, Date2, Comment
    From Table1
    where Date1 ":p10_open_or_closed"
    Thanks.

    Thanks for your help gents.
    Originally, I had a PL/SQL Statement constructing the code as needed, as Rekha
    suggested.
    if :P1_OPEN_OR_CLOSED = 1 then
    q:=q||' and ';
    q:=q||' p.ACTUAL_INSTALL_DATE is null ';
    end if;
    if :P1_OPEN_OR_CLOSED = 2 then
    q:=q||' and ';
    q:=q||' p.ACTUAL_INSTALL_DATE is not null ';
    end if;
    But, to use a Tabular form, where users can update fields of multiple records on screen then submit for a MRU, the option of PL/SQL code is not allowed, only SQL. So Phil UK, no it's not an elegant way of doing things, but I'm forced to use SQL, yeah?
    There are definitely ways that I can filter for the solution I am after, but they all involve more in depth solutions (that are not that great). Thus, I asked at this forum.
    Andy, your solution works :~) which makes me very happy. I'm not sure how just now but I'll learn from it.
    Thanks again.

  • SQL queries help need-urgent

    Based on your inputs-I studied and created the below objects.I apologise for asking lengthy questions,but i
    need your help very much now to proceed next.
    There is a COMPANY WHICH has many divisions/departments in it.
    These divisions has employees.
    *{color:#0000ff}--Created employee table which employee_id and Salary.*
    **employees (*empid,salary){color}*
    *{color:#0000ff}***DO i need to put the DEPT_ID and Manager_id in the EMPLOYEES table? {color}*
    *{color:#0000ff}--Presently,iCreated a relationship table to have EMPLOYEE"S MANAGER information.a manager is an employee itself.{color}*
    *{color:#0000ff}--Created a table for EMPLOyee and department---RELATIONSHIP ---> empl_id and dept_id{color}*
    The COMPANY has numerous Products(also we can say projects) and these project work is done by the various depts.
    *{color:#0000ff}Projects /Job table*
    *--job_id*
    *--Project_name*
    *--Budget Amount{color}*
    *{color:#0000ff}--Created a table for Project and department---RELATIONSHIP ---> proj_id and dept_id*
    *--Also,Created a table for Project and Employee---RELATIONSHIP ---> proj_id and employee_id{color}*
    Also,here scenario (1)Employees can work or be a part of many or multiple departments and work for multiple projects/products at a time (2)As usual-each Department has a manager.**EVery dept can handle or work only on one project.
    *{color:#0000ff}--Created a table for Project and department---RELATIONSHIP ---> proj_id and dept_id*
    *--Also,Created a table for Project and Employee---RELATIONSHIP ---> proj_id and employee_id*
    *{color}*
    _*{color:#000000}***(1)Are the tables and the relationships defined above enough or have i created too much tables?Please advise me.{color}*_
    Queries:-Need to write SQLs for below items.Please help me.Could you all have a look
    bq. h5. {color:#0000ff} \\ _     (2)SQL for a person see all his manager?***A person can have 2,3 managers._ \\ _     (3)need a person--->manager-->and their manager's MANAGER_ \\ _     (4)How will managers to view all employees reporting to him._ \\ {color} \\ h5. \\ {color:#0000ff}_(5)feasibility (SQL) to support the increase of salaries of employees in a department by percentage or amount wise._ \\ _     (6)SQL to update or change manager of a department/employee._ \\ {color} \\ h5. \\ {color:#0000ff}_(7)If a employee is removed-then all related details should also be removed._ \\ _     (8)to remove person and department,terminate a person from organisation_ \\ _     SHIFTING a person to different department,assign a person to a department_{color} \\ h5. {color:#0000ff}_SQL to collect all info of a person, his managers , departments and project this employee works._ \\ _     find Department which dont have managers._{color} \\ h5. \\ {color:#0000ff}_****find expenditure all projects together in terms of salary_{color}

    Sorry for all the confusion with the questions.So let me clear myself,i am doing this not as assignment or homework,but something
    which interests me and trying to leran.Earlier as I stated that its a part of my school(** well frnakly speaking, it was my plan if i could
    put this as an item of the school as the scope is very huge.
    *(1)one employee can be in many departments(1 TO MANY) and and each department has one manager.(1 to 1)*
    Created a table for EMPLOyee and department-RELATIONSHIP ---> empl_id and dept_id*
    (2)Also,an employee can work in multiple items/projects(1-MANY) at a time. And a project HAS only one department.(1 to 1)
    **Projects table created has codes,the Project name ,Planned budget cost/amount, start_date and end_date AND DEPART_ID
    Also,Created a table for Project and Employee-RELATIONSHIP ---> proj_id and employee_id*
    This is the full scenario has put above.So,i needed help as I am very confused if i have done the correct relationships.
    And,these below items are my plans to allow the schema nd tables support it.
    (2)how will a person see all his manager?***A person can have 2,3 managers.(EMP->MANAGER relationship TABLE)
    (3)SQL to be able to show a person--->manager-->and their manager's MANAGER
    (4)How will managers to view all employees reporting to him.
    (5)SQL to support the increase of salaries of employees in a department by percentage or amount wise.
    (6)SQL to update or change manager of a department/employee.
    (7)If a employee is removed-then all related details should also be removed.
    (8)to remove person and department,terminate a person from organisation
    SHIFTING a person to different department,assign a person to a department
    Projects /Job table EMPLOYEES TABLE-> SALARY info
    --job_id
    --Project_name
    --Budget Amount

  • SQL Query Help Needed

    I'm having trouble with an SQL query. I've created a simple logon page wherein a user will enter their user name and password. The program will look in an Access database for the user name, sort it by Date/Time modified, and check to see if their password matches the most recent password. Unfortunately, the query returns no results. I'm absolutely certain that I'm doing the query correctly (I've imported it directly from my old VB6 code). Something simple is eluding me. Any help would be appreciated.
    private void LogOn() {
    //make sure that the user name/password is valid, then load the main menu
    try {
    //open the database connection
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:LawOffice2000", "", "");
    Statement select = con.createStatement();
    String strTemp = "Select * From EMPLOYEES Where INITIALS = '" + txtUserName.getText() + "' Order By DATE Desc, TIME Desc";
    ResultSet result = select.executeQuery(strTemp);
    while(result.next()) {
    if (txtPassword.getPassword().toString() == result.getString("Password")) {
    MenuMain.main();
    else {
    System.out.println("Password Bad");
    System.out.println(txtUserName.getText());
    System.out.println(result.getString("Password"));
    break; //exit loop
    //close the connection
    con.close(); }
    catch (Exception e) {
    System.out.println("LawOfficeSuite_LogOn: " + e);
    return; }
    }

    The problem is here: "txtPassword.getPassword().toString() == result.getString("Password"))"
    Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same characters), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus ==

  • SQL Report help needed

    Hi All,
    I am creating a report which is having 2 sql queries ,1 for the main columns that i need to show and 2 from total sum and count.
    Report is something as given below
    SET TAB OFF;
    set linesize 1500;
    set pagesize 50;
    SET FEEDBACK OFF;
    SET WRAP OFF
    COLUMN today NEW_VALUE VAR1 NOPRINT;
    TTITLE LEFT 'ABC Inc.' SKIP 1 -
    LEFT 'Daily Report' SKIP 1 -
    LEFT 'As Of ' VAR1 SKIP 2
    BTITLE LEFT SKIP 'Page No : ' FORMAT 9999999999 SQL.PNO SKIP 3;
    COL SR_NO HEADING 'Seq'               FORMAT 999999;
    COL REFNO HEADING 'Ref No'                FORMAT A20;
    COL ORIG_NAME HEADING ' Branch Name'      
         FORMAT A50;
    SELECT      ROWNUM                SR_NO,
         REF_NO                REFNO,
         ORIGIN_NAME               BRNAME
    FROM BANK
    WHERE PASS_CD=101
    SELECT      ' Failure Count : '|| NVL(COUNT(DECODE(CODE,1,CODE,NULL)),0) ||
         ' Failure Total Amt : '|| NVL(SUM(DECODE(CODE,799,AMT,NULL)),0)
         || CHR(10) ||     
         ' Successful Count : '|| NVL(COUNT(DECODE(CODE,000,CODE,NULL)),0) ||
    ' Successful Total Amt: '|| NVL(SUM(DECODE(CODE,000,AMT,NULL)),0)
    FROM BANK;
    CLEAR BREAKS;
    CLEAR COLUMN;
    TTITLE OFF;
    When i am running this second query output is going to secong page and title is repeated again and same as 1rst page is showing page no-1
    Kindly help me,i want the output on the same page at bottom.
    Thanks

    i think its only work in ISQL* PLUS enivironment iam
    not sure.It does work in SQL*Plus
    is that i can use in the package??http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12048.htm

  • Oracle 11G Install on Win 7 With PL/SQL Developer Help Needed

    Today is my first day with Oracle. I have tried to Install Ora11g from our network drive.I think the installation went fine. I also installated PL/SQL Developer when i try to log in i got the following error see below.
    PL/SQL Developer - (Not logged on)
    Initialization error
    SQL*Net not properly installed
    OracleHomeKey: SOFTWARE\ORACLE
    OracleHomeDir:
    OK
    After i did some research online i found this solution "go to Tools > Preferences > options set manually "Oracle Home" to the folder of ORACLE_HOME and "OCI Library" to the oci.dll file located in ORACLE_HOME/bin/oci.dll"
    C:\app\user\product\11.2.0\client_1\bin.dll <=== I believe this is my Oracle_Home
    C:\app\user\product\11.2.0\client_1\bin\oci.dll <==== Is my OCI Library.
    When i apply thse 2 paths i get the following error.
    Initialization error
    COuld not load " C:\app\user\product\11.2.0\client_1\bin.dll
    OCIDLL forced to C:\app\user\product\11.2.0\client_1\bin.dll
    LoadLibrary(C:\app\user\product\11.2.0\client_1\bin\.dll)returned 0
    Can someone help me with this ???????????????/

    Pl indicate which version of Win 7 - you will need Professional or higher - Home versions are not supported/certified, so things may or may not work as expected.
    http://download.oracle.com/docs/cd/E11882_01/install.112/e16773/reqs.htm#CHDHGGFE
    HTH
    Srini

  • How to optimize this SQL. Help needed.

    Hi All,
    Can you please help with this SQL:
    SELECT /*+ INDEX(zl1 zipcode_lat1) */
    zl2.zipcode as zipcode,l.location_id as location_id,
    sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2)) as distance
    FROM location_atao l, zipcode_atao zl1, client c, zipcode_atao zl2
    WHERE zl1.zipcode = l.zipcode
    AND l.client_id = c.client_id
    AND c.client_id = 306363
    And l.appType = 'HOURLY'
    and c.milessearchzipcode >= sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2))
    I tried to optimize it by adding country column in zipcode_atao table. So that we can limit the search in zipcode_atao table based on country.
    Any other suggestions.
    Thanks

    Welcome to the forum.
    Please follow the instructions given in this thread:
    How to post a SQL statement tuning request
    HOW TO: Post a SQL statement tuning request - template posting
    and add the nessecary details we need to your thread.
    Depending on your database version (the result of: select * from v$version; ):
    Have you tried running the query without the index-hint?
    Are your table (and index) statatistics up-to-date?

  • Discoverer Gurus Help needed

    I should say I got strange problem. I dont know if it is the limitation of Discoverer 4.1.48. I've created a custom folder in my admin and when i validate it, it says Valid SQL infact it gives me the results in TOAD and SQL plus. When I try to make a worksheet of this folder I get an error saying "000907-missing right paranthesis".
    I would appreciate if someone can look at this query and tell me whats wrong in it. Its a Aging Query should work on any Apps Database. I would get bunch of tickets if I dont get this going.
    SELECT distinct ra.customer_name,
    ra.customer_number,
    lc_sc.meaning,
    ra.attribute1 division,
    pap.full_name rsm,
    rsa.name AS broker_name,
    arc.name AS Collector_Name,
    arps.trx_date AS invoice_date,
    arps.trx_number AS invoice_number,
    rt.NAME payment_terms,
    rct.type AS "TYPE",
    rct.NAME AS "class",
    rah.interface_header_attribute1 AS order_number,
    oh.cust_po_number,
    arps.due_date,
    arps.amount_due_original,
    arps.amount_due_remaining,
    ROUND((SYSDATE - arps.due_date)) AS days_out
    FROM ar_payment_schedules_all arps,
    ra_customers ra,
    per_all_people_f pap,
    ra_terms rt,
    ra_customer_trx_all rah,
    ra_cust_trx_types_all rct,
    oe_order_headers_all oh,
    RA_SALESREPS_ALL RSA,
    AR_CUSTOMER_PROFILES acp,
    ar_collectors arc,
    so_lookups lc_sc
    WHERE ra.customer_id = arps.customer_id
    AND rah.customer_trx_id = arps.customer_trx_id
    AND arps.status ='OP'
    AND arps.customer_id IS NOT NULL
    AND ra.attribute11 = pap.person_id(+)
    AND rah.term_id = rt.term_id
    AND lc_sc.lookup_type(+) = 'SALES_CHANNEL'
    AND lc_sc.lookup_code = ra.sales_channel_code --'EMAIL_CENTER'
    AND arps.cust_trx_type_id = rct.cust_trx_type_id
    AND TO_CHAR(oh.order_number) = rah.interface_header_attribute1(+)
    AND rah.PRIMARY_SALESREP_ID = RSA.salesrep_id
    and acp.CUSTOMER_ID = ra.CUSTOMER_ID
    and acp.COLLECTOR_ID = arc.COLLECTOR_ID
    UNION ALL
    SELECT distinct ra.customer_name,
    ra.customer_number,
    lc_sc.meaning,
    ra.attribute1 division,
    NULL rsm,
    NULL Broker_Name,
    NULL Collector_Name,
    arps.trx_date AS invoice_date,
    arps.trx_number AS invoice_number,
    NULL Payment_Terms,
    arps.class AS "TYPE",
    NULL AS "class",
    NULL AS order_number,
    NULL AS cust_po_number,
    arps.due_date,
    arps.amount_due_original ,
    arps.amount_due_remaining,
    ROUND((SYSDATE - arps.due_date)) AS days_out
    FROM ar_payment_schedules_all arps,
    ra_customers ra,
    per_all_people_f pap,
    so_lookups lc_sc
    WHERE ra.customer_id = arps.customer_id
    AND arps.status = 'OP'
    AND arps.class LIKE 'PMT'
    AND arps.customer_id IS NOT NULL
    AND lc_sc.lookup_type(+) = 'SALES_CHANNEL'
    AND lc_sc.lookup_code = ra.sales_channel_code
    Thanks
    Bobby

    Hi Bobby
    Looking at the two pieces of code you have not defined the broker name the same in both sections. In the top half it is named "broker_name" while in the second half it is named "Broker_Name". This needs to be fixed before you can continue otherwise Discoverer cannot correctly assign a unique name to that item in the folder.
    You should also cross check all of the other names to make sure that the names are identical, with no extra spaces, correct formatting and so on.
    I am not sure this is the cause but its worth a shot.
    Best wishes
    Michael

  • SQL problem - help needed ASAP!!

    Hey guys,
    Doing a college project... would really appreciate some help. I am trying to use a variable in the where clause of a select cursor in PL/SQL. The code is this:
    procedure results(p_search_entry varchar2, p_search_field varchar2) is
    cursor c_results is
    select * from physics_b where p_search_field = p_search_entry;
    begin
    for cv_results in c_results
    loop
    -- loop through actions
    end loop;
    The problem is that I don't know how to get the where clause to accept the variable passed into the procedure as the field name. Does anyone know the syntax for this?
    Thanks very much!
    Niall

    This isn't the correct forum for this kind of question. The SQL and PL/SQL forum PL/SQL is probably best.
    That said, you can't do what you want that way.
    You can do
    procedure results (p_search_entry in varchar2)
    cursor c_result is
    select * fro physics_b where subject=p_search_entry;(assuming subject is a column in physics_b)
    You can't use a variable to represent a column directly. You need to build the statement as a string and then use execute immediate.
    statement:='select * fro physics_b where '||p_search_field||' = :1';
    -- this bit is probably bad syntax.
    execute immediate statement using p_search_entry;Look up execute immediate and bind variables

  • SQL Filter Help Needed

    Hello,
    I am in need of some SQL help as I am not sure how to do it.  I want to only return rows of data that meet the following criteria:
    1) in tableA columnA it could have a value shown as such:  A,B,1,2,3,5,8
    2) in tableA columnB it shows one of the following four variables (Test1, Test2, Test3, Test4)
    3) in tableA columnC it will show a date.
    4) in tableB there is a row for each day of the year. 
    5) in tableB there is a column that matches each of the four variables in #2 above. 
    First it should match the date in tableA ColumnC to the row in tableB that matches.  Then it should then find the column in tableB that matches to the value in tableA columnB.  in that cell it will have a single value from A-D or 1-9.  If it is an A for example, it will need to check against tableA columnA.  if it has an A in it, it will return it.  If it does not, it will not.  
    Does anyone have any idea how to write this?  Is this possible?
    Thank you,
    Jeff

    Check the query using hardcoded values first - values taken from your explication
    select x.idfield
      from tablea x,
           (select datedefinefield,
                   'VARIABLE4' the_variable,
                   case 'VARIABLE4' when 'VARIABLE1'
                                      then variable1
                                      when 'VARIABLE2'
                                      then variable2
                                      when 'VARIABLE3'
                                      then variable3
                                      when 'VARIABLE4'
                                      then variable4
                   end the_value
              from tableb
             where datedefinefield = date '2013-01-01'
           ) y
    where x.datefield = y.datedefinefield
       and x.variablefield = y.the_variable
       and instr(','||x.codefield||',',','||y.the_value||',') > 0
    then replace the hardcoded values with bind variables
    select x.idfield
      from tablea x,
           (select datedefinefield,
                   :the_variable the_variable,
                   case :the_variable when 'VARIABLE1'
                                      then variable1
                                      when 'VARIABLE2'
                                      then variable2
                                      when 'VARIABLE3'
                                      then variable3
                                      when 'VARIABLE4'
                                      then variable4
                   end the_value
              from tableb
             where datedefinefield = to_date(:the_date,'yyyymmdd')
           ) y
    where x.datefield = y.datedefinefield
       and x.variablefield = y.the_variable
       and instr(','||x.codefield||',',','||y.the_value||',') > 0
    type the values in the window SQL Developer displays before execution to prompt you for bind variable values
    VARIABLE4 for the_variable
    20130101 for the_date
    no quotes this time then hit the Apply ( not very sure that's the caption) button to start execution and you should get the same result as with hardcoded values.
    If that works, you can start playing with (submitting values of your choice)
    Regards
    Etbin

Maybe you are looking for

  • Updated iPhone 4s to ios8 but screen is stuck on white screen with apple logo and progress bar

    I updated my phone last night and my iPhone screen is white and has a gray apple logo and a progress bar which has been the same for 12 hours. The bar looks almost completel but it hasn't moved at all. my phone was also unplugged accidentally during

  • I just restored my Iphone. How do i get my apps back from backup?

    How do i back up my iphone after i restored it to get my apps back?

  • How to show result in bold text and zebra-printing

    Hi, I'm trying to create a ABAP class in SE24 defining the report-results in bold text. Looked around SDN, but not found the help I need. Plus need some help on how to print a report in "Zebra"-layout. I've already created a report with background co

  • ReferenceError: Error #1056:

    Getting this error when instantiating this class. It's set up in my FLA as the document class: ReferenceError: Error #1056: Cannot create property tab0 on classes.tagwidget.TagWidget. at classes.tagwidget::TagWidget/::addTabs() at classes.tagwidget::

  • Database copy on same server

    Hi guys, I want to copy the existing 6.40 system TBW to a new instance TBX on the same server. I've created all filesystems, copied the content, changed SIDs and paths in environment scripts and profiles and restored the database TBW to TBX with brdb