Report Builder ORA 24333 Zero iteration count

The following query works fine in SQL environment
Break on team_name;
select substr(st.team_name, 1, 20) team_name, sst.team_id, sst.staff_sso
from
ssa_staff_team sst, ssa_teams st
where st.team_id = sst.team_id(+)
order by team_name;
But when I cut and paste it into "SQL Query Statement" of Oracle Report it does not work. the error message is ORA-24333 - zero iteration count ==> Break on TEAM_Name
What did I do wrong"
How do I fix this?

Just follow the report wizard and it will ask you on which column(s) to break.
Don't try to do it afterwards, because that is a pain in the .... You will have to modify your data and layout model yourself if you don't use the wizard.

Similar Messages

  • ORA-24333: zero iteration count  Cause: An iteration count of zero was specified for the statement Action: Specify the number of times this statement must be executed

    Get the following error from Oracle 
    ORA-24333: zero iteration count
    Cause: An iteration count of zero was specified for the statement
    Action: Specify the number of times this statement must be executed
    Any suggestions on whether is this a Oracle bug or if not what should be set to avoid this failure.

    Hello get this from executing the following.
    Occurs intermitently.
    select MAX(LENGTH(lxVal)) from lxString_74501fb6 where lxType=910231053
    Find the MaxLenght(LxVal) returned is null for this query.
    Did google it but says the iterator not initialized. But not the case here
    Thanks

  • ORA-24333 An iteration count of zero was specified for the statement

    Hi all,
    in example below oracle generate error ORA-24333,
    Cause: An iteration count of zero was specified for the statement
    Action: Specify the number of times this statement must be executed
    On Error GoTo errHandler:
    Dim pOraStmt As OraSqlStmt 'obiekt OO4O
    Dim stat As Long
    aWystapilBlad = False
    gOraDatabase.LastServerErrReset
    gOraDatabase.BeginTrans
    Set pOraStmt = gOraDatabase.CreateSql("begin " & _
    NAZWA_PAKIETU & "." & NAZWA_PROCEDURY & _
    "; END;", ORASQL_NONBLK)
    stat = pOraStmt.NonBlockingState
    While stat = ORASQL_STILL_EXECUTING
    DoEvents
    stat = pOraStmt.NonBlockingState
    Wend
    '>>>>>>>>>>>>>>>>>ERROR ORA-24333 zero iteration count!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
    If gOraDatabase.LastServerErr > 0 Then
    aWystapilBlad = True
    GenerujKomunikaty BLAD_SYSTEMOWY_NR & Err.Number & vbNewLine & BLAD_OPIS_BLEDU & gOraDatabase.LastServerErrText, WyswietlNaEkran, blad, TYTUL_APLIKACJA
    PrzeniesDanychCODGiK = False
    End If
    gOraDatabase.CommitTrans
    PrzeniesDanych = True
    Exit Function
    errHandler:
    aWystapilBlad = True
    gOraDatabase.Rollback
    PrzeniesDanych = False
    Can anybody help me?
    Regards
    Zbyszek

    Hello get this from executing the following.
    Occurs intermitently.
    select MAX(LENGTH(lxVal)) from lxString_74501fb6 where lxType=910231053
    Find the MaxLenght(LxVal) returned is null for this query.
    Did google it but says the iterator not initialized. But not the case here
    Thanks

  • ORA-19202: Error occurred in XML processing  ORA-24333: zero iteration coun

    Hi,
    I have a procedure which craetes a sql v_sql dynamically
    IF v_cnt > 0 THEN
    For c1 in v_curr
    LOOP
    v_sql := ''''||'SELECT * from '|| c1.msg_rcrd_src_tbl_nm||' where rowid = '||''''||''''||c1.msg_rcrd_src_tbl_id||''''||''''||'''';
    select DBMS_XMLGEN.getXMLtype(v_sql) into v_xml from dual ;
    gives me a error
    ORA-19202: Error occurred in XML processing
    ORA-24333: zero iteration count
    ORA-06512: at "SYS.DBMS_XMLGEN", line 288
    ORA-06512: at line 1
    Any help greatly appreciated.
    Thanks,
    Raj

    Answered
    Re: Zero iteration error - when processing dynamic sql in dbms_xmlgen

  • Use of procedure in Report Builder

    Hello all,
    i am using Oracle 10gR2 Report Builder it is working properly with sql queries but i want to try it with procedures
    so is it possible to use procedures in Report Builder as the same way we import query. i used a procedure but got an error :- ORA-24333 zero iteration count
    Thanks & Regards
    Pratik Lakhpatwala
    Jr Oracle DBA
    Edited by: Pratik.L on Oct 9, 2009 2:11 AM
    Edited by: Pratik.L on Oct 9, 2009 2:12 AM

    Does this procedure return the resultset as a REF CURSOR?
    Having not worked on Report builder, I am not sure if this error is related to calling of procedure itself.

  • ORA-24333 on Select Statement

    Last night I attempted to roll a Crystal Reports .NET project to my production web server. This app has 3 new Crystal Reports. The Reports are all based upon the same Oracle Views on the same Oracle Database. Two of the reports work while the third report returns an ORA-24333 error. The exact reports and .NET code, connecting to the same Oracle database work fine in Preview mode and when published to my development IIS web server. The ONLY thing that is different is that the report is now being run on the production IIS web server. (But it is still the same Oracle Database we are connecting to in all environments.)
    Here is the Command used for the Crystal Report that fails. Sorry it is so long. Basically, it is 4 Select statements joined together with Unions. Stuff in {} are parameters that are passed to it.
    SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.PROJECTNAME as ProjectName, A.INVOICENO as InvoiceNO, A.INVDATE, A.PAYDATE, A.ORDERNO as OrderNo, A.TOTALAMT as TotalAmt, A.ELIGIBLEAMT as EligibleAmt, A.SALESPOINTERD as SalesPointErd, 0 as FORFEIT, 0 as BONUSPOINTERD, 0 as PAYPTSEARNED, P.POINTPERCD as POINTPERCD, case when A.PAYDATE is null and A.INVDATE>SYSDATE-30 then round(P.POINTPERCD*A.ELIGIBLEAMT/100,0) else 0 end as PAYPTSELIG, case when A.PAYDATE is null and A.INVDATE>SYSDATE-30 then TO_CHAR(A.INVDATE+30,'MM/DD/YYYY') else '' end as PAYBYforPAYPTS
    FROM VW_TRIPPOINTS A
    left join VW_POINTS P on A.COMPANY=P.COMPANY and substr(A.FISCALPRD,1,4)=to_char(P.FISCALYEAR) and P.CODE='P'
    join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
    join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
    where A.POINTCODE='S' and A.COMPANY='30' and A.ELIGIBLEAMT<>0 and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
    Union --Bonus Points
    SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.Notes as ProjectName, Cast((Row_Number() over (Order By CustNo, OrderNo, InvoiceNo, IDKey)) as varchar(10)) as InvoiceNO, A.INVDATE, Null as PAYDATE, Cast((Row_Number() over (Order By IDKey)) as varchar(10)) as ORDERNO, Coalesce(A.TOTALAMT,0) as TotalAmt, Coalesce(A.ELIGIBLEAMT,0) as EligibleAmt, Coalesce(A.SALESPOINTERD,0) as SalesPointErd, 0 as FORFEIT, A.BONUSPOINTERD as BonusPointErd, 0 as PAYPTSEARNED, 0 as POINTPERCD, 0 as PAYPTSELIG, '' as PAYBYforPAYPTS
    FROM VW_TRIPPOINTS A
    join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
    join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
    where A.POINTCODE='B' and A.COMPANY='30' and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
    Union --Pay Points
    SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.PROJECTNAME as ProjectName, A.INVOICENO as InvoiceNO, A.INVDATE, A.PAYDATE, A.ORDERNO as OrderNo, 0 as TotalAmt, 0 as EligibleAmt, 0 as SALESPOINTERD, 0 as FORFEIT, 0 as BONUSPOINTERD, coalesce(A.PAYPOINTERD,0) as PAYPTSEARNED, 0 as POINTPERCD, 0 as PAYPTSELIG, '' as PAYBYforPAYPTS
    FROM VW_TRIPPOINTS A
    join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
    join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
    where (A.POINTCODE='P' or A.POINTCODE='C') and A.COMPANY='30' and A.PAYPOINTERD<>0 and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
    Union --Sales Points Forfeited
    SELECT A.Custno as Custno, C.CUST_NAME as Cust_Name, D.CONTACT_NAME as Contact_Name, A.FISCALPRD as FiscalPrd, A.PROJECTNAME as ProjectName, A.INVOICENO as InvoiceNO, A.INVDATE, A.PAYDATE, A.ORDERNO as OrderNo, 0 as TotalAmt, 0 as EligibleAmt, 0 as SalesPointErd, Coalesce(A.SalesPointErd,0) as FORFEIT, 0 as BONUSPOINTERD, 0 as PAYPTSEARNED, 0 as POINTPERCD, 0 as PAYPTSELIG, '' as PAYBYforPAYPTS
    FROM VW_TRIPPOINTS A
    join VW_CUSTOMERS C on (C.COMPANY=A.COMPANY or A.custno='313243') and C.CUST_NUMB=A.custno
    join VW_SALESMEN D on C.DIST_MGR=D.CONTACT_NUMBER
    where A.POINTCODE='R' and A.COMPANY='30' and A.SalesPointErd<>0 and A.custno='{?@Cust_ID}' and A.FISCALPRD>={?@BegPeriod} and A.FISCALPRD<={?@EndPeriod}
    order by custno, OrderNo, InvoiceNo

    Because we don't all have the Oracle error numbers and messages memorized:
    ORA-24333: zero iteration count
    Cause: An iteration count of zero was specified for the statement
    Action: Specify the number of times this statement must be executed

  • Report Builder 6i returns ORA-01483 in after parameter form trigger ?

    Can anybody help me ?
    I've been working on a report with report builder 6.0.8.11.3,
    and whenever i run the report the after parameter form trigger
    returns REP-1401 and following ORA-01483.
    I've been trying to change the values of some user parameters
    from within the trigger code, none of them is a date or a number
    parameter, these are character variables who would be referenced
    lexically to change a table name dynamically when the trigger
    fires. Aditionally I'm using a cursor to obtain data and then
    modify the parameters.
    How can i get this thing to work ?
    Thanks in advance for your reply...

    hello,
    this might be related to the usage of number(1) as type/length
    of your parameter. this is a known problem. it should be solved
    by using e.g. number(2) as the type/length of your parameter.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to hide a report builder field if it is zero

    I am using Coldfusion Report Builder. If the value of a feild is zero, how can I hide it or show a blank. Keep in mind this field is a DollarFormat() field.

    scottnweber wrote:
    I am using Coldfusion Report Builder. If the value of a feild is zero, how can I hide it or show a blank. Keep in mind this field is a DollarFormat() field.
    When you click on the field in Report Builder, look near the bottom of the Properties window, in the "Print Control" section.
    You will see an entry labelled "Print When Condition". Put an expression next to it that returns true or false.
    For example, in your case, you would put something like the following:
    MyField neq 0
    Where "MyField" is the name of your field. This expression will only allow the field to be printed when its value is not zero.
    Since you're targeting the value of the field you don't have to worry about the formatting that you used next to "Expression" in the "Data" section of the Properties window.

  • Report Builder: output to Excel removes leading zeros

    I'm trying to use the Report Builder to output a numeric
    field to EXCEL , but on numbers that start with zero EXCEL removes
    the leading zero's. ex. 00123 becomes 123.
    Is there something that I can put in the expression builder
    on the field to overcome this.
    I've tried concatonating a single quote on the front of the
    field but the single quote shows up on the output. I've tried this
    on both the SQL and on the expression builder.
    I've read on some of the posts where people have tried using
    'mso-number-format:"\@'" within a TD tag but I can't seem to get
    the syntax right inside the Expression Builder.
    Has anybody got any suggestions?

    Excel will remove leading zeros in a numeric field because it is treating the column as numeric. Putting a ' in front of the number forces Excel to treat the column as text.

  • WITH clause unexpectedly causes ORA-00942 in Reports Builder

    I'm posting this in the hope that:
    a) My workaround might help someone if they ever run into the same problem, and/or,
    b) Someone might have a better workaround.
    The problem is that I get unexpected ORA-00942 (table or view does not exist) errors when I try to set the SQL Query Statement property of a Query object in Reports Builder to certain SELECT statements that contain a WITH clause (aka subquery factoring clause).
    For example, the following SELECT statement executes as expected in SQL*Plus...
    SQL> WITH
      2      SUB_QUERY AS
      3      (
      4          SELECT
      5              1 AS X
      6          FROM
      7              DUAL
      8      )
      9  SELECT
    10      INLINE_VIEW.X
    11  FROM   
    12      (
    13          SELECT
    14              NESTED_INLINE_VIEW.X
    15          FROM
    16              (
    17                  SELECT
    18                      SUB_QUERY.X
    19                  FROM
    20                      SUB_QUERY
    21              ) NESTED_INLINE_VIEW
    22      ) INLINE_VIEW;
             X
             1...but when I try to use it as the SQL Query Statement for a Query object in Reports Builder, I get the following error:
    ORA-00942: table or view does not exist
    ==>SUB_QUERY
    My Reports Builder version is 10.1.2.0.2 version and my database version is 10.2.0.3.0.
    The "real" query I have been trying to use is much more complex than this -- this is just the simplest statement I have been able to come up with that causes the problem. In fact, I have some queries that have a similar structure (a WITH clause subquery referenced inside a nested inline view, along with some other things), but strangely do not cause the problem.
    I spent some time researching the problem on Google and Metalink but did not come up with any satisfactory answers. The problem sounds similar to bug 3896963, but bug 3896963 involved UNION ALL, and is supposedly fixed in my version(s).
    I tried various ways of restructuring my "real" query, but with no success -- it's going to be hard to get rid of the WITH clauses. As a "wild guess", I tried various hints (MATERIALIZE, NO_PUSH_PRED, NO_MERGE), again with no success.
    I ended up working around the problem by creating a database package with a function that returns a REF CURSOR based on the query, and then used that in a REF CURSOR query in Reports Builder. It might not be a very elegant workaround, but it works. I just wish I had "given up" and tried it sooner -- I might have saved myself some grief.

    Well, for what it's worth, I didn't end up using a REF CURSOR query after all because...
    If I ran a REP file based on a REF CURSOR query against a different database, or if I ran the REP file after the database package had been dropped and re-created, it failed with the following error:
    REP-8: Run time error in the PL/SQL development environment (DE).
    PDE-PSD001 Could not resolve reference to <Unknown Program Unit> while loading <Unknown> <Unknown>.
    REP-0008: Unexpected memory error while initializing preferences.
    It seems that Reports "binds" the REP file to the timestamp of the database package that defines the REF CURSOR type in order to validate the package at run time. If the timestamp is different, running the REP file will fail with this error. This is apparently bug 1275333 and is described in Metalink Note 272936.1.
    The bug reference and Metalink Note offerred the following workarounds:
    1. Export the database schema that contains the package from one database and import it into the other.
    In some versions, import and export preserve the timestamp, so this would avoid the problem. I didn't try this because it would not be a practical workaround in my situation (upgrade vs. new install).
    2. Recompile the package and manually set the timestamp using the seemingly undocumented ALTER PACKAGE...COMPILE BODY REUSE SETTINGS TIMESTAMP... syntax.
    I didn't try this because I didn't like the idea of having to: a) rely on an undocumented feature, and, b) manually keep track and maintain the timestamps of all the affected packages across several databases (e.g., development, test, and production).
    3. Put the package into a Reports library or into the report itself.
    This didn't work for me because Reports does not understand WITH clauses in PL/SQL. For example, with the example query in my previous post, I get an error like this:
    Error 103 at line {line defining name of factored subquery}, column {first column in line defining name of factored subquery}
    Encountered the symbol "SUB_QUERY" when expecting one of the following:
    &lt;a SQL statement&gt;
    4. Use an RDF file instead of a REP file.
    I didn't use this workaround because I wanted to protect the design of the report by using a REP file instead of an RDF file.
    So instead, I:
    1. Created a database package containing a pipelined function that returned the results of the WITH clause query that Reports did not "understand".
    2. Used an SQL query in my report of the form
    SELECT * FROM TABLE(MY_PACKAGE.MY_PIPELINED_FUNCTION(arg1, arg2, ...))
    I can drop and re-create the package and run the REP file against another database both without leading to the REP-8 error.

  • Report builder in BO - Removing trailling zeros

    I have a field that can have up to 5 deciaml value like 0.12345..  But if the amount is 0.12300 i want to remove the trailling zeros so i would get 0.123 on my report. I have a formula for crystal report but i cant put the 'if' condition in BO Report builder.
    Help please
    Thanks to all

    > I have a field that can have up to 5 deciaml value
    > like 0.12345..  But if the amount is 0.12300 i want
    > to remove the trailling zeros so i would get 0.123 on
    > my report. I have a formula for crystal report but i
    > cant put the 'if' condition in BO Report builder.
    Hi Alain,
    In Print Layout Designer, the Round function allows you to round decimal values to a selected (fixed) amount of decimals. However, this is not exactly what you are looking for. As far as I know, there is no way you could do the removal of trailing zeros in PLD. A common workaround (although a really ugly one) to this problem as well as to many other PLD problems is to do the processing with formatted search in a UDF and just print whatever you have in the UDF.
    IMHO, the Print Layout Designer is by far the most frustrating component of B1. I don't mind that it's got a clumsy user interface, but the limited availability of fields&functions is just outrageous. To make things worse, it seems there are practically no significant improvements in the PLD for B1 2006.
    Henry

  • Record Count In report Builder

    Hi Folks,
    In Report Builder I want serial number with each record being fectched from the database in such a way that on each page of the report, the count should always start from 1. Any ideas?
    TIA
    Hassan

    Hi Hassan
    You may have a placeholder column or something and increment its value inside of a repeating frame format trigger.
    You may then reset its value to 1 in BETWEEN_PAGES trigger.
    Hope this helps.
    Regards
    Sripathy

  • Report Builder Count Column

    How can I build a count column with a where clause based on a query defined in the report builder query screen? From what I can tell the built in count column does not allow the addition or definition of a where clause.
    Thanks

    Hi Ruth,
    Not exactly sure if this will answer your question, but here goes. It sounds like you want to count values based on certain conditions? If the where clause is already in your query, you can use the count function that's available in SQL and allow the database to perform the count for you. Otherwise you can use a formula column in combination with a placeholder column or a summary column to get the conditional count. In the formula column you can use plsql to determine if you want to increment your count or not. Depending on how you do it, you can either just return '1' or '0' from your formula column and create a summary column based on your formula column. Or you can increment a placeholder column from your formula column. If you decide to go with placeholders, I'd suggest reading the online help examples for placeholders as there are a few rules you'll have to go by.
    Hope that helps,
    Toby

  • What happens to the while loop iteration counter if it runs unchecked?

    I want to use the iteration counter to initialise a value on the first loop of a while statement. ie i = 0, x = 100. Fine. The application I am building will be left to run for weeks or months on end without stopping (hopefully :¬)). What happens to the iteration counter in this situation? Does it reset to 0 or what? I don't want it reinitialising any values while the loop is running other than when it starts.
    I set up a while loop to try to figure out what happens and the iteration counter stops at 2147483648 which is 2^31 - 1.
    Any help would be appreciated,
    Thanks,
    Niel.

    It might be something you already looked at, but perhaps it's an option to perform the initialization outside (before) the while loop. That way it will be initialized correctly only once, no matter what the iteration counter does.
    Of course if you need the counter for other purposes than initialization you might have the same problem...
    Note that a lot of the timer functions also overflow after a certain time (I believe 24 or 48 days?) so be careful running very long loops (but you already knew that probably).

  • SQL Server 2008 R2 - Report Builder 3.0 - timeout using shared data source and stored procedure

    I select the shared datasource from the data source propeties dialog, test the connection and everything is good.
    I add a dataset by selecting "use a dataset embedded in my report" option within the Dataset properties dialog.
    I select the newly added data source, click the "Stored procedure" query type and drop down the list box and select my intended stored procedure.
    the timeout for the dataset is "0" seconds.
    I click the "OK" button and I'm presented with the parameters to the stored procedure.
    I enter valid data for the parameters and click the "OK" button.
    I then get the following error message after 30 seconds:
    The problem is, all of the timeouts, that I'm aware of, have values of zero (no timeout) or high enough values that 30 seconds isn't even close to the timeout.
    I think the smallest timeout we have is 120 seconds.
    I have searched this site and many others and the solutions all involve altering the stored procedure to get the fields into report builder and then revert the stored procedure back to its original form.
    To me, this is NOT a solution.  
    I have too many stored procedures that need to be brought into Report Builder.
    I need a real solution.
    Thank you for you time, Tim Caldwell.
    Timothy E Caldwell

    I don't mean to be rude, but really, check to see if the stored procedure can return data rows???
    Maybe I'm not being clear enough.
    The stored procedure runs perfectly fine.
    it runs perfectly fine in the production environment and the test environment.
    I can access the stored procedure in several ways and have it return correct data.
    I can even trick report builder into creating a dataset with parameters and run the stored procedure that way.
    What I cannot do, is to get report builder to not timeout after 30 seconds on the initial creation of a dataset with a Query type of stored procedure.
    I have seen this issues posted again and again and again on may different sites and the "solution" is to simplifiy the stored procedure by creating a stored procedure that has a create table and a select in the stored procedure and that's it.  After
    report builder creates the dataset the developer then has to replace the simplified stored procedure with the actual stored procedure and everything works fine after that.
    HOWEVER, having to go through this process for 70 or more stored procedures is ridiculous.
    It would appear that there is something within report builder itself that is causing this issue.
    The SQL Script included is an example of a stored procedure that will not create fields create a dataset with fields and parameters in Report Builder 3.0:
    USE [CRUM_IT]
    GO
    /****** Object: StoredProcedure [dbo].[COGNOS_Level5ScriptSP] Script Date: 11/17/2014 08:02:26 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER procedure [dbo].[COGNOS_Level5ScriptSP]
    @CompanyCode varchar(8) = null,
    @GetSiblings varchar(1) = 'N'
    as
    Begin
    -- get emergency contact info
    select *
    into #tmp_Contacts
    from
    (select
    ConEEID,
    con.connamelast as [Emer Contact Last Name],
    con.connamefirst as [Emer Contact First Name],
    con.connamemiddle as [Emer Contact Middle Initial/Name]--,
    ,ROW_NUMBER() over (Partition by ConEEID order by ConNameLast)as rn
    ,ISNULL(
    case when con.conphonepreferred = 'H'
    then '(' + substring(con.conphonehomenumber, 1, 3) + ')' + substring(con.conphonehomenumber, 4, 3) + '-' + substring(con.conphonehomenumber, 7, 4)
    else '(' + substring(con.conphoneothernumber , 1, 3) + ')' + substring(con.conphoneothernumber , 4, 3) + '-' + substring(con.conphoneothernumber , 7, 4)
    end,
    ) as [Emergency Phone]
    from [ultiprosqlprod1].[ultipro_crum].dbo.Contacts con
    where con.ConIsEmergencyContact='y'
    and con.ConIsActive='y'
    ) A
    where A.rn = 1
    CREATE TABLE #tmp_CompanyCodes (CompanyCode varchar(8))
    If @GetSiblings = 'Y'
    Begin
    INSERT INTO #tmp_CompanyCodes (CompanyCode)
    EXEC [z_GetClientNumbers_For_ParentOrg_By_ClientNumber] @CompanyCode
    End
    INSERT INTO #tmp_CompanyCodes
    values (@CompanyCode)
    select *
    into #tmp_Company
    from [ultiprosqlprod1].[ultipro_crum].dbo.Company
    where cmpcompanycode in (select CompanyCode from #tmp_CompanyCodes)
    select distinct
    cmpcompanycode as [Client ID],
    CmpCompanyDBAName as [Client Name],
    eec.eecEmplStatus AS [Employment Status],
    eec.eecEmpNo AS [Employee Num],
    rtrim(eep.eepNameLast) AS [Last Name],
    rtrim(eep.eepNameFirst) AS [First Name],
    isnull(rtrim(ltrim(eep.eepNameMiddle)), '') AS [Middle Initial/Name],
    rtrim(eep.eepAddressLine1) AS [Address Line 1],
    isnull(rtrim(eep.eepAddressLine2), '') AS [Address Line 2],
    eep.eepAddressCity AS [City],
    eep.eepAddressState AS [State],
    CASE
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) = 0
    THEN substring(eep.eepAddressZipCode, 1, 5)
    ELSE rtrim(eep.eepAddressZipCode)
    END AS [Zip code],
    CASE
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) = 0
    THEN substring(eep.eepAddressZipCode, 6, 4)
    WHEN len(eep.eepAddressZipCode) > 5 and charindex(eep.eepAddressZipCode, '-', 1) > 0
    THEN substring(eep.eepAddressZipCode, charindex(eep.eepAddressZipCode, '-', 1) + 1, 4)
    WHEN len(eep.eepAddressZipCode) <= 5
    THEN ''
    END AS [ZIP + 4],
    substring(eep.eepSSN, 1, 3) + '-' + substring(eep.eepSSN, 4, 2) + '-' + substring(eep.eepSSN, 6, 4) AS [SSN],
    isnull(convert(VARCHAR(10), eep.eepDateOfBirth, 101), '') AS [Date Of Birth],
    eetFED.TAXCODE AS [FED Tax Code],
    eetFED.FILINGSTATUS AS [Fed Filing Status],
    eetFED.EXEMPTIONS AS [Fed Exemption Allowance],
    eetFED.ADDITIONAL AS [Additional Fed Withholding],
    eetSIT.TAXCODE AS [SIT Tax Code],
    eetSIT.FILINGSTATUS AS [State Filing Status],
    eetSIT.EXEMPTIONS AS [State Exemption Allowance],
    eetSIT.ADDITIONAL AS [Additional State Withholding],
    isnull('(' + substring(eep.eepPhoneHomeNumber, 1, 3) + ')' + substring(eep.eepPhoneHomeNumber, 4, 3) + '-' + substring(eep.eepPhoneHomeNumber, 7, 4), '') AS [Home Phone],
    isnull((SELECT cod.codDesc
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.Codes cod WITH (NOLOCK)
    WHERE cod.codCode = eep.eepEthnicID
    AND cod.codDosTable = 'ETHNICCODE'), '') AS [Race-Origin], --eep.eepEthnicID AS [Race-Origin],
    eep.eepGender AS [Gender],
    isnull(convert(VARCHAR(10), eec.eecDateOfOriginalHire, 101), '') AS [Original Hire Date],
    isnull(convert(VARCHAR(10), eec.eecDateOfSeniority, 101), '') AS [Seniority Date],
    isnull(convert(VARCHAR(10), eec.eecDateOfTermination, 101), '') AS [Termination Date],
    isnull(eecTermType,'') as [Termination Type],
    isnull(TchDesc, '') as [Termination Reason],
    rtrim(eec.eecJobCode) AS [WC Code],
    isnull(eec.eecJobTitle, '') AS [Job Title],
    pgr.pgrPayFrequency AS [Pay Frequency],
    eec.eecFullTimeOrPartTime AS [Full/Part Time],
    eec.eecSalaryOrHourly AS [Pay Type],
    isnull(convert(MONEY, eec.eecHourlyPayRate), 0.00) AS [Hourly Rate],
    isnull(eec.eecAnnSalary, 0.00) AS [Annual Salary],
    [YTD Hours],
    isnull(eep.eepNameFormer, '') AS [Maiden Name],
    eec.eecLocation AS [Location ID],
    rtrim(eec.eecOrgLvl1) AS [Department ID],
    eec.eecorglvl2 AS [Cost Item],
    eec.eecorglvl3 as [Client Project],
    eec.eecPayGroup as [Pay Group],
    isnull(eepAddressEMail,' ') as [Email Address],
    isNull(BankName1,' ') as PrimaryBank,
    isNull(BankRoute1,' ') as PrimaryRouteNum,
    isNull(Account1,' ') as PrimaryAccount,
    isNull(AcctType1,' ') as PrimaryAcctType,
    isNull(DepositRule1,' ') as PrimaryDepositRule,
    isNull(BankName2,' ') as SecondaryBank,
    isNull(BankRoute2,' ') as SecondaryRouteNum,
    isNull(Account2,' ') as SecondaryAccount,
    isNull(AcctType2,' ') as SecondaryAcctType,
    isNull(DepositRule2,' ') as SecondaryDepositRule,
    isNull(
    CASE
    WHEN DepositRule2 = 'D'
    THEN '$' + convert(varchar, cast(EddAmtOrPct2 AS decimal(10,2)))
    WHEN DepositRule2 = 'P'
    THEN convert(varchar, cast((EddAmtOrPct2*100) AS decimal(10,0))) + '%'
    ELSE null
    END,' ') as SecondaryDepositAmount,
    isNull(BankName3,' ') as ThirdBank,
    isNull(BankRoute3,' ') as ThirdRouteNum,
    isNull(Account3,' ') as ThirdAccount,
    isNull(AcctType3,' ') as ThirdAcctType,
    isNull(DepositRule3,' ') as ThirdDepositRule,
    isNull(
    CASE
    WHEN DepositRule3 = 'D'
    THEN '$' + convert(varchar, cast(EddAmtOrPct3 AS decimal(10,2)))
    WHEN DepositRule3 = 'P'
    THEN convert(varchar, cast((EddAmtOrPct3*100) AS decimal(10,0))) + '%'
    ELSE null
    END,' ') as ThirdDepositAmount,
    Supervisor,
    eec.eecEEID AS [Employee EEID],
    eec.EecJobCode As [Job Code],
    isnull(eec.EecTimeclockID,' ') As [Time Clock ID],
    con.[Emer Contact Last Name],
    con.[Emer Contact First Name],
    con.[Emer Contact Middle Initial/Name],
    con.[Emergency Phone]
    from [ultiprosqlprod1].[ultipro_crum].dbo.empPers eep WITH (NOLOCK)
    inner join [ultiprosqlprod1].[ultipro_crum].dbo.empComp eec WITH (NOLOCK)
    ON eep.eepEEID = eec.eecEEID
    inner join #tmp_Company cmp WITH (NOLOCK)
    ON eec.eecCOID = cmp.cmpCOID
    inner join [ultiprosqlprod1].[ultipro_crum].dbo.PayGroup pgr WITH (NOLOCK)
    ON eec.eecPayGroup = pgr.pgrPayGroup
    left outer join [ultiprosqlprod1].[ultipro_crum].dbo.TrmReasn
    on tchCode = eecTermReason
    left join (select CAST(sum(isnull(eee.eeeYTDHrs,0.00))AS DECIMAL(18,2)) as [YTD Hours],
    eeeEEID,
    eeeCOID
    from [ultiprosqlprod1].[ultipro_crum].dbo.EmpEarn eee with (NOLOCK)
    group by eeeCOID,eeeEEID)eee
    on eec.eecEEID = eee.eeeEEID
    and eec.eecCOID = eee.eeeCOID
    left join (SELECT eetCOID AS COID,
    eetEEID AS EEID,
    eetTaxCode AS TAXCODE,
    eetFilingStatus AS FILINGSTATUS,
    eetExemptions AS EXEMPTIONS,
    eetExtraTaxDollars AS ADDITIONAL
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.empTax WITH (NOLOCK)
    WHERE eetTaxCode = 'USFIT'
    )eetFED
    ON eec.eecCOID = eetFED.COID
    and eec.eecEEID = eetFED.EEID
    left join (SELECT eetCOID AS COID,
    eetEEID AS EEID,
    eetTaxCode AS TAXCODE,
    eetFilingStatus AS FILINGSTATUS,
    eetExemptions AS EXEMPTIONS,
    eetExtraTaxDollars AS ADDITIONAL
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.empTax WITH (NOLOCK)
    WHERE eetTaxCode like '%SIT'
    AND eetIsWorkInTaxCode = 'Y'
    )eetSIT
    ON eec.eecCOID = eetSIT.COID
    and eec.eecEEID = eetSIT.EEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName1,
    eddEEBankRoute BankRoute1,
    eddAcct Account1,
    EddAcctType AcctType1,
    EddDepositRule DepositRule1,
    EddAmtOrPct EddAmtOrPct1
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '99')edd
    ON eec.eecCOID = edd.eddCOID
    and eec.eecEEID = edd.eddEEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName2,
    eddEEBankRoute BankRoute2,
    eddAcct Account2,
    EddAcctType AcctType2,
    EddDepositRule DepositRule2,
    EddAmtOrPct EddAmtOrPct2
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '01')edd2
    ON eec.eecCOID = edd2.eddCOID
    and eec.eecEEID = edd2.eddEEID
    left outer join (SELECT eddCOID,
    eddEEID,
    eddEEBankName BankName3,
    eddEEBankRoute BankRoute3,
    eddAcct Account3,
    EddAcctType AcctType3,
    EddDepositRule DepositRule3,
    EddAmtOrPct EddAmtOrPct3
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpDirDp WITH (NOLOCK)
    WHERE eddSequence = '02')edd3
    ON eec.eecCOID = edd3.eddCOID
    and eec.eecEEID = edd3.eddEEID
    left outer join (SELECT eecCOID,
    eecEEID,
    rtrim(eepNameLast) + ', ' +
    rtrim(eepNameFirst) + ' ' +
    isnull(rtrim(ltrim(eepNameMiddle)), '') AS [Supervisor]
    FROM [ultiprosqlprod1].[ultipro_crum].dbo.EmpComp WITH (NOLOCK)
    join [ultiprosqlprod1].[ultipro_crum].dbo.EmpPers with (NoLock)
    on eeceeid = eepeeid)eec2
    ON eec.eecSupervisorID = eec2.eecEEID
    left outer join #tmp_Contacts con
    on eep.eepEEID = con.ConEEID
    order by [Client ID],
    [Last Name],
    [First Name]
    drop table #tmp_Contacts
    END
    Timothy E Caldwell

Maybe you are looking for

  • Report Performance - Summary Fields Setting

    I have a report data model with 3 groupings. Summary fields are needed for each group. There are 2 approaches for me to have the summary values : 1. i can set the data source of each summary field to be the corresponding column of my based Q_1 select

  • Web Service, SSL and Client Authentication

    I tried to enable SSL with client authentication over a web service. I am using App Server 10.1.3.4. The test page requires my certificate (firefox asks me to choose the certificate) the response page of the web service returns this error: java.secur

  • Division isn't coming at  the time of Material Creation

    Hi Guys, While creating a Material Master Division isn't coimg . Only Sales Org & Distribution Channel is coming,What is the Reason?? Am I missing something??

  • Delete SO after deleing PO line item in Individual Purchase order

    "Individual Purchase order" if i create SO with individual PO then PR is created automatically and i convert this PR to PO if i want to delete So line item i can't because it's linked to PO. I deleted this PO line item and i tried again to delete SO

  • XML Parsing in Weblogic

    Hi all, Am releatively new to weblogic and am migrating my web app from the tomcat container to weblogic 9.2 I use a XerxesImpl jar to parse my XML using a DOMParser and I dont want to use any libraries provided by weblogic atleast now!! It always gi