an array's dimension must be an integer between 1 and 1000 - crystal-reports

Does anyone has any clue about the above error i get when I've tried to create sub report in crystal report?
Shared Stringvar array store;
store:= store + {table.A};
1

Try below, you are again selecting the values that are their in both tables but you need to select that are not in second table, I have updated the query
Select concat(REFNO_PFIX,'00',REFNO_SERL) as EventName,CROSS_REF from tizone1.baseevent where concat(REFNO_PFIX,'00',REFNO_SERL) not in ( SELECT baseevent.CROSS_REF from tizone1.baseevent as ta left join tizone1.baseevent as lta on ta.EventName = lta.CROSS_REF group by master_key );

Related

How to convert maximo SQL for Crystal Reporting

How do I change this to work in crystal?
SELECT jpnum in (select jpnum from jobplan minus select jpnum from jobtask where jptask = '1')
There are a few ways to structure this query and I'm not completely sure of the structure of your tables, but this query should get you on the way to a command.
SELECT
JOBPLAN.JPNUM,
MIN(ISNULL(JOBTASK.JPTASK,0))
FROM
JOBPLAN
LEFT OUTER JOIN
JOBTASK
ON JOBPLAN.JPNUM = JOBTASK.JPNUM
GROUP BY
JOBPLAN.JPNUM
HAVING
MIN(ISNULL(JOBTASK.JPTASK,0)) <> 1

Temporary Table Value into a Table-Value UDF

I was having some trouble with an SQL 2k sproc and which we moved to SQL 2k5 so we could used Table Value UDF's instead of Scalar UDF's.
This is simplified, but this is my problem.
I have a temporary table that I fill up with product information. I then pass that product information into a UDF and return the information back to my main results set. It doesn't seem to work.
Am I not allowed to pass a Temporary Table value into an CROSS APPLY'd Table Value UDF?
--CREATE AND FILL #brandInfo
SELECT sku, upc, prd_id, cp.customerPrice
FROM products p
JOIN #brandInfo b ON p.brd_id=b.brd_id
CROSS APPLY f_GetCustomerPrice(b.priceAdjustmentValue, b.priceAdjustmentAmount, p.Price) cp
--f_GetCUstomerPrice uses the AdjValue, AdjAmount, and Price to calculate users actual price
When I put dummy values in for b.priceAdjustmentValue and b.priceAdjustmentAmount it works great. But as soon as I try to load the temp table values in it bombs.
Msg 207, Level 16, State 1, Line 140
Invalid column name 'b.priceAdjustmentValue'.
Msg 207, Level 16, State 1, Line 140
Invalid column name 'b.priceAdjustmentAmount'.
Have you tried:
--CREATE AND FILL #brandInfo
SELECT sku, upc, prd_id, cp.customerPrice
FROM products p
JOIN #brandInfo b ON p.brd_id=b.brd_id
CROSS APPLY (
SELECT *
FROM f_GetCustomerPrice(b.priceAdjustmentValue, b.priceAdjustmentAmount, p.Price) cp
)
--f_GetCUstomerPrice uses the AdjValue, AdjAmount, and Price to calculate users actual price
Giving the UDF the proper context in order to resolve the column references?
EDIT:
I have built the following UDF in my local Northwind 2005 database:
CREATE FUNCTION dbo.f_GetCustomerPrice(#adjVal DECIMAL(28,9), #adjAmt DECIMAL(28,9), #price DECIMAL(28,9))
RETURNS TABLE
AS RETURN
(
SELECT Level = 'One', AdjustValue = #adjVal, AdjustAmount = #adjAmt, Price = #price
UNION
SELECT Level = 'Two', AdjustValue = 2 * #adjVal, AdjustAmount = 2 * #adjAmt, Price = 2 * #price
)
GO
And referenced it in the following query without issue:
SELECT p.ProductID,
p.ProductName,
b.CompanyName,
f.Level
FROM Products p
JOIN Suppliers b
ON p.SupplierID = b.SupplierID
CROSS APPLY dbo.f_GetCustomerPrice(p.UnitsInStock, p.ReorderLevel, p.UnitPrice) f
Are you certain that your definition of #brandInfo has the priceAdjustmentValue and priceAdjustmentAmount columns defined on it? More importantly, if you are putting this in a stored procedure as you mentioned, does there exist a #brandInfo table already without those columns defined? I know #brandInfo is a temporary table, but if it exists at the time you attempt to create the stored procedure and it lacks the columns, the parsing engine may be getting tripped up. Oddly, if the table doesn't exist at all, the parsing engine simply glides past the missing table and creates the SP for you.

t sql query returns duplicate values

I know this is an often asked question, but I've tried to resolve this myself and could not.
I've got 2 tables to join and now it's returning a duplicate value from the right table.
select am.Journal
,am.EntryNumber
,am.PayInvoice
,am.PayDiscAllowed
,am.PayTaxAmtDisc
,am.PayGrossPayment
,tm.*
from CshJnlPay am right join
(select
Invoice
,SUM(NetSalesValue) as NetSalesValue
,SUM(DiscValue) as DiscValue
,SUM(TaxValue) as TaxValue
,SUM(QtyInvoiced) as QtyInvoiced
from Salesdetail
group by Invoice) tm
on am.PayInvoice = tm.Invoice
where Invoice = 'C90831'
If the query returns 2 rows with the same data from the right table then you have 2 rows in the left table with the same invoice number...
You should check the left table with this query
Select * from CshJnlPay where PayInvoice = 'C90831'
You should get two rows.

This field cannot be summarized crystal report error

I've got the problem about crystal report. I've created one formula field called PAT_DEP and formula is as follow.
Local NUMBERVAR PAT_DEP_AMT := 0;
IF NextIsNull({MYOBJ.PAT_DEPOSIT}) = TRUE THEN
(
IF {MYOBJ.PAT_DEPOSIT} = PREVIOUS({MYOBJ.PAT_DEPOSIT}) THEN
(
PAT_DEP_AMT := 0;
)
ELSE
(
PAT_DEP_AMT := {MYOBJ.PAT_DEPOSIT};
);
)
ELSE
(
IF PREVIOUS({MYOBJ.PAT_DEPOSIT}) = NEXT({MYOBJ.PAT_DEPOSIT}) THEN
(
PAT_DEP_AMT := ToNumber(0);
)
ELSE
(
PAT_DEP_AMT := {MYOBJ.PAT_DEPOSIT};
);
)
Then I've created another formula field called TOT_PAT_DEP and formula is as follow like summarized above formula field.
TOTAL_PAT_DEP := SUM(#PAT_DEP)
But got crystal report error This field cannot be summarized crystal report error. Please help me how come I got this error.
Based on your explanation and formula, it looks like you have a one-to-many relationship which is causing you some difficulty. Let's take an example:
Order Table
Order #, Total, Paid
Order Items Table
Order #, Line #, Description
When you join the two tables you can no longer sum the total/paid columns because they will be multiplied by the number of order lines.
The way to overcome this is to create a group using the key. In my example you would group on Order #. You can then create a running total to sum the total/paid columns but will only evaluate on the change of your Order # group.
Does that make sense?

Crystal Report with multiple datasources, one is empty

I have a Crystal report with a table as a datasource and I want to include another table with details for the report footer.
I have two data sources in the report which are not linked, but when the selection criteria returns no rows from the main table, the results from the non-empty non-linked source are also empty.
I suspect it's doing a cross join between the two datasources, so if one is empty, that joined with another is also empty. The problem is I need my rows from the non-empty table to show in the report footer section, and they're getting suppressed by the other, empty datasource.
How can I get rows from an independent table to show in the report footer when the selection criteria and their parameter choices return an empty result set in the main table?
Thanks for your help,
-Beth
Also, I tried using a command as a datasource with sql like this:
select * from waitlist
union all
select distinct null as reportID, null as ..., lastupdated
from waitlist
but it still returns null for lastupdated and suppresses the subreport in the report footer.
I ended up setting my report datasource to a view which unioned another row to the table. I also needed to change my selection criteria so it allows this row to pass through.
Here's my datasource:
CREATE VIEW [dbo].[vw_rpt_waitlist] AS
select * from waitlist
union all
select distinct
reportID,
null as (fields...),
lastupdated,
'reserved' as countyName
from
waitlist
and here's my record selection formula:
({vw_rpt_waitlist.countyName} = {?County} or
{vw_rpt_waitlist.countyName} = "reserved") and
{vw_rpt_waitlist.reportID} = 14
I'm also suppressing the detail section if there were real rows returned:
formula = {vw_rpt_waitlist.countyName} = "reserved"
and to get the parameterized county name they selected in the page header of the report, I'm using:
dim t as string
dim c as string
if {vw_rpt_waitlist.countyName}="reserved" then
c = {?County}(1)
else
c = {vw_rpt_waitlist.countyName}
end if
t = "Waitlist by " + {#serviceTitle} + " and Waiver Need Index as of "
+ cstr({vw_rpt_waitlist.lastUpdated},"MM/dd/yyyy")
formula = t
Since the 'reserved' county always comes through, the subreports are not suppressed.