Prepared XmlQueryExpression with variables vs String query
John,
I have ran into another performance problem. This time it is the same xpath expression. The difference is one is a prepared one with variables that are being reset for each execution thread where as the other one is alway a new string query with each execution thread.
dbxml> info
Version: Oracle: Berkeley DB XML 2.3.10: (January 30, 2007)
Berkeley DB 4.5.20: (September 20, 2006)
Default container name: en-US
Type of default container: NodeContainer
Index Nodes: on
Shell and XmlManager state:
Verbose: on
Query context state: LiveValues,Eager
declare default element namespace "http://dto.destination.dbxml.valhalla.starwood.com";
collection("en-US")/City[CityDetail/PropertyIds/PropertyId=100]/CityItems/CityItem[@CityItemId=(actual collection of 500 double values)]
Time: 498 ms
vs
declare default element namespace "http://dto.destination.dbxml.valhalla.starwood.com"; collection("en-US")/City[CityDetail/PropertyIds/PropertyId=$PropertyId]/CityItems/CityItem[@CityItemId=$Ids]
Time: 104291 ms
A snippet of query plans is following:
dbxml> queryplan 'declare default element namespace "http://dto.destination.dbxml.valhalla.starwood.com";
collection("en-US")/City[CityDetail/PropertyIds/PropertyId=100]/CityItems/CityItem[@CityItemId=(196970,339036)]'
<XQuery>
<DbXmlNav>
<LookupIndex container="en-US">
<ValueQP index="node-element-equality-double" operation="eq" child="PropertyId:http://dto.destination.dbxml.valhalla.starwood.com"
value="100"/>
</LookupIndex>
<DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="PropertyIds" nodeType="element"/>
<DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityDetail" nodeType="element">
<OQPlan>P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
</DbXmlStep>
<Join type="parent-of-child" return="argument">
<DbXmlNav>
<QueryPlanFunction result="collection" container="en-US">
<OQPlan>n(P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com),V(node-element-equality-double,P
ropertyId:http://dto.destination.dbxml.valhalla.starwood.com,=,'100'),u(n(P(node-element-presence-none,=,CityItem:http://dto.destination
.dbxml.valhalla.starwood.com),V(node-attribute-equality-double,@CityItemId,=,'196970')),n(V(node-attribute-equality-double,@CityItemId,=
,'339036'),P(node-element-presence-none,=,CityItem:http://dto.destination.dbxml.valhalla.starwood.com))))</OQPlan>
</QueryPlanFunction>
<DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="City" nodeType="element"/>
</DbXmlNav>
</Join>
<DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItems" nodeType="element"/>
<DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItem" nodeType="element">
<OQPlan>P(node-element-presence-none,=,CityItem:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
</DbXmlStep>
<Join type="attribute" return="context_item">
<LookupIndex container="en-US">
<UnionQP>
<ValueQP index="node-attribute-equality-double" operation="eq" child="CityItemId" value="196970"/>
<ValueQP index="node-attribute-equality-double" operation="eq" child="CityItemId" value="339036"/>
</UnionQP>
</LookupIndex>
</Join>
</DbXmlNav>
</XQuery>
<XQuery>
<DbXmlNav>
<LookupIndex container="en-US">
<ValueQP index="node-element-equality-double" operation="eq"
child="PropertyId:http://dto.destination.dbxml.valhalla.starwood.com">
<Variable name="PropertyId"/>
</ValueQP>
</LookupIndex>
<DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="PropertyIds" nodeType="element"/>
<DbXmlStep axis="parent-of-child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityDetail" nodeType="element">
<OQPlan>P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
</DbXmlStep>
<Join type="parent-of-child" return="argument">
<DbXmlNav>
<QueryPlanFunction result="collection" container="en-US">
<OQPlan>n(P(node-element-presence-none,=,CityDetail:http://dto.destination.dbxml.valhalla.starwood.com),P(node-element-presence-none,=,C
ityItem:http://dto.destination.dbxml.valhalla.starwood.com),P(node-attribute-equality-double,prefix,@CityItemId),P(node-element-presence
-none,=,PropertyId:http://dto.destination.dbxml.valhalla.starwood.com))</OQPlan>
</QueryPlanFunction>
<DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="City" nodeType="element"/>
</DbXmlNav>
</Join>
<DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItems" nodeType="element"/>
<DbXmlStep axis="child" uri="http://dto.destination.dbxml.valhalla.starwood.com" name="CityItem" nodeType="element">
<OQPlan>P(node-element-presence-none,=,CityItem:http://dto.destination.dbxml.valhalla.starwood.com)</OQPlan>
</DbXmlStep>
<Join type="attribute" return="context_item">
<DbXmlNav>
<LookupIndex container="en-US">
<PresenceQP index="node-attribute-equality-double" operation="prefix" child="CityItemId"/>
</LookupIndex>
<DbXmlCompare name="equal" join="self">
<Variable name="Ids"/>
</DbXmlCompare>
</DbXmlNav>
</Join>
</DbXmlNav>
</XQuery>
Any ideas of what is going on?
Thanks,
Dmitriy
Dmitriy,
Do you have patch #4 for 2.3.10 applied?
http://www.oracle.com/technology/products/berkeley-db/xml/update/2.3.10/patch.2.3.10.html
Regards,
George
Similar Messages
-
Executiong prepared statement with Like% in SQL Query?
Hi,
We are developing GUI project.In which we need to retrieve the contract details based on the Name which we enter in eVision page.Here we will not enter the whole name,we will enter only the part of the name,for example if the actual name is Sun Seebeyond,I will enter only Su.So if there are five records in data base which starts the name with Su.Then it should return the five names..
For this I am using the prepared statement as
select name,contractid from table1 where name Like '?%'.
Here my runtime input value will set to this parameter ?.When I execute this qry in my project I am getting error as "Unable to set parameters on the Object: Invalid parameter index 1".
If I replace the ? with Su in query itself ,then it works fine..
Please let me know is there any effective way,using which I can solve..
Thanks,
Renga.S.Hi,
This option I already tried and it work fine too.
I am looking for an option ,where we can handle with in the Query,so we dont need to write any code appending % into the actual valus.
Thanks,
Renga.S. -
How to tokenize a column with variable length string
I have a question regarding tokenizing string in a column I have table like
id list
1 i love dogs
2 i like cats and dogs
and so on
it should be converted to
id list
1 i
1 love
1 dogs
2 i
2 like
2 cates
2 and
2 dogs
How do I tokenize this? I tried using this code inside cursor and procedure
SELECT id, regexp_substr(str, '[^ ]+', 1, level) TOKEN from test CONNECT by level <= length(regexp_replace (str, '[^ ]+')) + 1;
but this is very slow when called from java. Is there any other alternative?
Thanks69edfef1-01fd-49c3-b83d-ece76195d26c wrote:
I have a question regarding tokenizing string in a column I have table like
id list
1 i love dogs
2 i like cats and dogs
and so on
it should be converted to
id list
1 i
1 love
1 dogs
2 i
2 like
2 cates
2 and
2 dogs
How do I tokenize this? I tried using this code inside cursor and procedure
SELECT id, regexp_substr(str, '[^ ]+', 1, level) TOKEN from test CONNECT by level <= length(regexp_replace (str, '[^ ]+')) + 1;
but this is very slow when called from java. Is there any other alternative?
Thanks
The reason yours is slow is because you don't have sufficient connect by conditions to restrict the iterations properly...
e.g. What you are doing...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 1 as id, 'i love dogs' list from dual union all
2 select 2, 'i like cats and dogs' from dual union all
3 select 3,'precipitevolissimevolmente' from dual)
4 --
5 --
6 --
7 SELECT id
8 ,regexp_substr(list, '[^ ]+', 1, level) TOKEN
9 from t
10* CONNECT by level <= length(regexp_replace (list, '[^ ]+')) + 1
SQL> /
ID TOKEN
1 i
1 love
1 dogs
2 and
2 dogs
2 cats
2 and
2 dogs
2 like
1 dogs
2 and
2 dogs
2 cats
2 and
2 dogs
2 i
1 love
1 dogs
2 and
2 dogs
2 cats
2 and
2 dogs
2 like
1 dogs
2 and
2 dogs
2 cats
2 and
2 dogs
3 precipitevolissimevolmente
1 love
1 dogs
2 and
2 dogs
2 cats
2 and
2 dogs
2 like
1 dogs
2 and
2 dogs
2 cats
2 and
2 dogs
45 rows selected.
And with additional connect by criteria...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 1 as id, 'i love dogs' list from dual union all
2 select 2, 'i like cats and dogs' from dual union all
3 select 3,'precipitevolissimevolmente' from dual)
4 --
5 --
6 --
7 SELECT id
8 ,regexp_substr(list, '[^ ]+', 1, level) TOKEN
9 from t
10 CONNECT by level <= length(regexp_replace (list, '[^ ]+')) + 1
11 and id = prior id
12* and prior sys_guid() is not null
SQL> /
ID TOKEN
1 i
1 love
1 dogs
2 i
2 like
2 cats
2 and
2 dogs
3 precipitevolissimevolmente
9 rows selected. -
How to create dynamic connection string with variables using ssis.
Hello,
Can anyone let me know on how to create dynamic connection string with variables using ssis?
Any help would be appreciated.Hi vinay9738,
According to your description, you want to connect multiple database from multiple servers using dynamic connection.
If in this case, we can create a Table in our local database (whatever DB we want) and load all the connection strings. We can use Execute SQL Task to query all the connection strings and store the result-set in a variable of object type in SSIS package.
Then use ForEach Loop container to shred the content of the object variable and iterate through each of the connection strings. And then Place an Execute SQL task inside ForEach Loop container with the SQL statements we have to run in all the DB instances.
For more details, please refer to the following blog:
http://sql-developers.blogspot.kr/2010/07/dynamic-database-connection-using-ssis.html
If there are any other questions, please feel free to let me know.
Regards,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Hi
I want to give range to a user to enter in a variable through sql query . If there are 200 records , if user wants to display from 5-45 , 75-110 , 130-145. how it can be done through SQl Query
Thanks
Edited by: Matt on Aug 31, 2010 6:23 PM - modified title - please use a meaningful title in futureDear Saini,
This query will allow you to choose the values only when you know them.
SELECT T0.[DocEntry], T0.[ItemCode] FROM INV1 T0 WHERE T0.[LineNum] >[%0] and T0.[LineNum] <[%1]
If you run it in the query Generator in SAP Business One a little window will pop up and will ask you to choose the 2 variables.
You can choose different variables every time you run it. At least you won't have to save many queries with different values.
If you want 2 different groups, e.g. from 10 to 20 and from 30 to 40, then you can add another part in the where clause:
SELECT T0.[LineNum], T0.[ItemCode], T0.[DocEntry] FROM INV1 T0 WHERE T0.[LineNum] >= [%0] and T0.[LineNum] <= [%2] and T0.[LineNum] >= [%4] or T0.[LineNum] <= [%6]
Please, let me know if this query helps.
Regards,
Marcella Rivi
SAP Business One Forums Team -
Problem with Variable in Query Designer.
hi all,
we have a variable ZAMREG on characteristic AM Region, where AM region is attribute for two different master data objects mastobj1 and mastobj2, we have different infosets build on these two master data objects along with some other ODS.
now this variable ZAMREG is visible in one of the infosets only in query designer, whereas it is not visible in the other infoset.
what could be the problem??
thanks,
RkHi,
Please check if that variable is created locally or globally. If it is a local variable in any query, it will not appear in any other query.
In anyways, you can always create one more variable if the older one is not available. This will not make much of difference. I would suggest go ahead with creating a new variable.
Regards,
Yogesh -
Problem with customer exit variable in BeX Query
Hi All,
We have created a customer exit variable in a query and populated with few patterns in customer exit.
My query has to bring all the records where the address line is containg the patterns passed through customer exit. Here the query is not working as expected.
It is bringing the values where the address line is exactly same as the pattern and not bringing the records where the pattern is part of the address line.
For example: Pattern passed in customer exit = 'HOSPITAL'
The record where address line = 'HOSPITAL' is shown in the rpeort, where the record with address line = 'HOSPITAL ROAD' is not shown in the report.
I would appreciate your help on this.
Regards,
RakeshHi Diogo,
Below is the code I am using in the customer exit.
SELECT * FROM zae_tt_pbuild INTO TABLE gt_pbuild.
IF sy-subrc = 0.
LOOP AT gt_pbuild INTO gs_pbuild.
CONCATENATE '*' gs_pbuild-pbuild '*' into lv_pattern.
ls_range-low = lv_pattern.
ls_range-sign = lc_sign_i.
ls_range-opt = 'CP'.
APPEND ls_range TO e_t_range.
CLEAR: ls_range,
lv_pattern.
ENDLOOP.
ENDIF.
ENDIF.
I have tried using '%' instead of '*' aswell but the result is same.
Thanks,
Rakesh -
hello world,
i have a problem, i have implemented a query that is using in different schema. These schemas have same structure, therefore to extract information i must use the same query but I must specify the different schemas to select the table. The question is: " how can i use a variable in the query? "
Example: "Select * from aa.zz ", "Select * from bb.zz"
I want to use the same query but to replace the name schema with a variable
Example: "Select * from aa.zz ", "Select * from bb.zz" =>>> "Select * from x.zz " where "x" is the variable name.
I am using this query to build a report by oracle BI publisher.
Thanks very much.
Regards
VincenzoYou should post your question on [Sql/PLSql |http://forums.oracle.com/forums/forum.jspa?forumID=75] topic
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com -
Report Designer - Query with variable
Hi!
When testing the report designer, we have found an issue - its not possible to embedding queries with variables.
We have found note https://websmp107.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=012006153200000232982006
that suggest a solution to the issue.
My question is simply, does anyone know if this is a temporary fix, or is this a constraint that is not planned to be fixed by SAP? The note is a bit ambiguous.
BR
bjørnHello,
Queries with variables are still in restrictions for Report Designer.
You can use this work-arond creating Query View and fill up the variables. This allows you to define a Report in RD. Then, use Web Appication Designer to include your Report into Web Application and replace the Query View with your initial Query.
For the integration do following:
1. Create new Web Template in WAD
2. Drag-and-drop Web Item "Report"
3. Go to Property Window in WAD and search for "REPORT" (description Report Design) parameter in Web Items Parameters
4. Use the button on the right side of the parameter to open Report Designer and choose your Report in it.
5. You should see that new Data Provider was created in WAD -> Open it and set it to your initial Query.
5. Save you Web Template and execute in the browser.
Regards, Karol
Development BI -
How to create sql query for item master with operator LIKE with variables?
hi all,
How to create sql query for item master with
operator LIKE(Contains,Start With,End With) with variables using query generator in SAP B1 ?
JeyakanthanHi Jeyakanthan,
here is an example (put the like statement into the where field)
SELECT T0.CardCode, T0.CardName FROM OITM T0 WHERE T0.CardName Like '%%test%%'
The %% sign is a wildcard. If you need start with write 'test%%' and otherwise ends with '%%test'. For contains you need '%%test%%'. You also could combinate this statements like 'test%%abc%%'. This means starts with test and contains abc.
Regards Steffen -
How to convert a "text variable" to String with plugin
Hello,
I am currently developing a InDesign (CS5) plugin, where I need to manipulate text variable.
From the plugin I want to convert the "text variable" to string (in principle I should use the method "VariableToString (..)" of "ITextVariable")"
My problem is, how to find the text varial from its name (I think I should use the method "FindLocationsUsed(..)" of "ITextVariableSuite") and then convert it to String
I don't know how to use interfaces ITextVariable and ITextVariableSuite
Plugin implemented in C++ language
thank youInputStreamReader in=new InputStreamReader(fis);
StringWriter out=new StringWriter();
char[] buffer=new char[8192];
int sizeRead;
while ( ( sizeRead=in.read(buffer, 0, 8192) ) != -1 )
out.write(buffer, 0, sizeRead);
String content=out.toString(); -
Problems with variables in query
I need add variable to my query, made in query generator. My query is long...doesn't work.
I read a possible solution for this: declare variable and then use it. For example:
Declare @FromDate as DateTime
Declare @ToDate as DateTime
set FromDate = '[%0]'
set ToDate = '[%1]'
and then implements it: select * from [table] where Date between @FromDate and @ToDate
...but doesn't work.
Any suggestions?
Roberto.
PD: I left my query:
declare @fdesde as datetime
declare @fhasta as datetime
set @fdesde = '[%0]'
set @fhasta = '[%1]'
select * from (SELECT
A.DOCENTRY as NroDocumento,
max(A.DOCDATE) AS FECHA,
max(CASE WHEN A.U_TGV_FLETTER = 'A' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '1'
WHEN A.U_TGV_FLETTER = 'B' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '6'
WHEN A.U_TGV_FLETTER = 'C' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '11'
WHEN A.U_TGV_FLETTER = 'E' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '19'
WHEN A.U_TGV_FLETTER = 'M' AND A.U_TGV_ACC_ORD_FLAC <> 1 THEN '51'
WHEN A.U_TGV_FLETTER = 'A' AND A.U_TGV_ACC_ORD_FLAC = 1 THEN '60'
WHEN A.U_TGV_FLETTER = 'B' AND A.U_TGV_ACC_ORD_FLAC = 1 THEN '61'
WHEN A.U_TGV_FLETTER = 'C' AND A.U_TGV_ACC_ORD_FLAC = 1 THEN '62' ELSE 'NA'
END) AS TIPOCOMP,
max(isnull(Convert(varchar,isnull(A.U_TGV_FOLIO_PREFIX,'0')) + '-' + Convert(varchar,A.folionum),'')) AS NUMCOMP,
max(isnull(A.CARDNAME, '')) AS RAZONSOCIAL,
max(Replace(LICTRADNUM,'-','')) AS CUIT,
round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then 0 else case when b.vatprcnt = 0 then b.linetotal else 0 end end), 4) as NOGRAVEXCENTO,
round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
max(b.vatprcnt) as ALICUOTA,
round(sum(b.vatsum),4) as IVA,
round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
'1' AS CONSULTA
FROM [dbo].[OPCH] A
INNER JOIN [dbo].[PCH1] B ON A.DOCENTRY = B.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
INNER JOIN [dbo].[OITM] I on b.ItemCode = I.ItemCode
Where I.U_TGV_PERCEP_FLAG = 0
group by a.DOCENTRY, b.taxcode
UNION ALL
SELECT
A.DOCENTRY as NroDocumento,
max(A.DOCDATE) AS FECHA,
max(CASE WHEN A.U_TGV_FLETTER = 'A' THEN '3'
WHEN A.U_TGV_FLETTER = 'B' THEN '8'
WHEN A.U_TGV_FLETTER = 'C' THEN '13'
WHEN A.U_TGV_FLETTER = 'M' THEN '53'
ELSE 'NA'
END) AS TIPOCOMP,
max(isnull(Convert(varchar,isnull(A.U_TGV_FOLIO_PREFIX,'0')) + '-' + Convert(varchar,A.folionum),'')) AS NUMCOMP,
max(isnull(A.CARDNAME, '')) AS RAZONSOCIAL,
max(Replace(LICTRADNUM,'-','')) AS CUIT,
round(sum(case when b.vatprcnt = 0 then b.linetotal else 0 end), 4) as NOGRAVEXCENTO,
round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
max(b.vatprcnt) as ALICUOTA,
round(sum(b.vatsum),4) as IVA,
round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
'1' AS CONSULTA
FROM [dbo].[ORPC] A
INNER JOIN [dbo].[RPC1] B ON A.DOCENTRY = B.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
INNER JOIN [dbo].[OITM] I on b.ItemCode = I.ItemCode
Where I.U_TGV_PERCEP_FLAG = 0
group by a.DOCENTRY, b.taxcode
UNION ALL
SELECT max(TOT.C1) as NroDocumento,max(TOT.C2) as Fecha, max(TOT.C3), max(TOT.C4), max(TOT.C5),max(TOT.C6),sum(TOT.NOGRAVEXCENTO),sum(TOT.IMPGRAVADO),max(TOT.ALICUOTA),sum(TOT.IVA),sum(TOT.OPEXENTA),max(TOT.PERCIVA),max(TOT.PERCIIBB),max(TOT.CONSULTA) FROM
SELECT
'' AS C1,
'' AS C2,
'' AS C3,
'' AS C4,
'' AS C5,
'' AS C6,
round(sum(case when b.vatprcnt = 0 then b.linetotal else 0 end), 4) as NOGRAVEXCENTO,
round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
max(b.vatprcnt) as ALICUOTA,
round(sum(b.vatsum),4) as IVA,
round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
'2' AS CONSULTA
FROM [dbo].[OPCH] A
INNER JOIN [dbo].[PCH1] B ON A.DOCENTRY = B.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
INNER JOIN [dbo].[OITM] I on b.ItemCode = I.ItemCode
Where I.U_TGV_PERCEP_FLAG = 0
group by b.taxcode
UNION ALL
SELECT
'' AS C1,
'' AS C2,
'' AS C3,
'' AS C4,
'' AS C5,
'' AS C6,
round(sum(case when b.vatprcnt = 0 then b.linetotal else 0 end), 4) as NOGRAVEXCENTO,
round(sum(case when b.vatprcnt <> 0 then b.linetotal else 0 end),4) as IMPGRAVADO,
max(b.vatprcnt) as ALICUOTA,
round(sum(b.vatsum),4) as IVA,
round(sum(case when a.U_TGV_TVAT_POS_BP = 'EX' then b.linetotal else 0 end),4) as OPEXENTA,
max(round(ISNULL(AA.TOTAL, 0),4)) AS PERCIVA,
max(round(ISNULL(BB.TOTAL, 0),4)) AS PERCIIBB,
'2' AS CONSULTA
FROM [dbo].[ORPC] A
INNER JOIN RPC1 AS B ON A.DOCENTRY = B.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 1
group by A.DOCENTRY) AA ON AA.DOCENTRY = A.DOCENTRY
LEFT JOIN (SELECT A.DOCENTRY, SUM(A.LINETOTAL) AS TOTAL FROM [dbo].[PCH1] A
INNER JOIN [dbo].[OITM] B ON A.ITEMCODE = B.ITEMCODE
INNER JOIN [dbo].[OWHT] C ON B.ITEMCODE = C.U_TGV_CODE_ITEM
WHERE U_TGV_PERCEP_FLAG = 1 AND U_TGV_PERC_TYPE = 2
group by A.DOCENTRY) BB ON BB.DOCENTRY = A.DOCENTRY
INNER JOIN [dbo].[OITM] I on b.ItemCode = I.ItemCode
Where I.U_TGV_PERCEP_FLAG = 0
group by b.taxcode
) TOT
group by TOT.ALICUOTA) TOTGEN
where TOTGEN.FECHA between @fdesde and @fhasta
order by TOTGEN.fechaHi Roberto,
Try the following:
DECLARE @cnt AS SMALLINT, @DateFrom AS DATETIME , @DateTo AS DATETIME
SELECT @cnt = count(*) FROM [dbo].[OINV] T0 WHERE T0.DocDate = '[%0]'
SELECT @cnt = count(*) FROM [dbo].[OINV] T1 WHERE T1.DocDate = '[%1]'
SET @DateFrom = '[%0]'
SET @DateTo = '[%1]'
IF @DateTo = '1900-01-01'
BEGIN
SET @DateTo = '2999-12-31'
END
SELECT DocNum, DocDate, CardCode, DocTotal
FROM dbo.[OINV]
WHERE DocDate >= @DateFrom AND DocDate <= @DateTo
ORDER BY DocNum
FOR BROWSE
The @cnt variable is only used as a mechanism to get the user values into the SAP parameter variables, which are then assigned to @DateFrom and @DateTo.
If the user does not enter any parameter values then SAP automatically assigns a value of '1900-01-01', which is fine for DateFrom but not DateTo - so if @DateTo equals this then I assign some future date so all transactions should be returned.
Hope this helps.
Regards,
Andrew. -
Performance issue doing a prepare statement with LIKE
Hi
I'm doing a preparestatement like this
select foo
from bar
where des like ?
and then do the prepare with the string 'foo%'
If I do the prepare of this variable, the query is very slow. If I don't do the prepare, the query is very fast. Can anyone help me out on this? DBA's will kill me if I don't use prepare statements but users will kill be if the query is slow...
Thank you!
HappyGuyAs indicated in the last reply this probably has to do with use of string literals over bound variables
With a prepared statement the optimiser dosen't get the chance to use histograms against your data... so whilst it might be more efficent to drive off an index for some of the searches it looses access to the data (histograms) that enable it to make this decission...
Hints are probably the way to go... if your sure that driving off a index is always going to be the most efficent...
Using explain (inside of JDeveloper9i or turning on the autotrace functionality inside of sqlplus) will give you some idea of how Oracle would drive the query if you use a string literal
Dom -
Problem with variables in formulas when using CrystalReportViewer
Post Author: Aksu
CA Forum: Formula
Hi! I have a problem with variables in Crystal Reports formulas, when using CrystalDecisions.Windows.Forms.CrystalReportViewer class from VS2005-project. ReportViewer always gives error:*************Crystal Report Windows Forms ViewerThis field name is not known.Details: errorKindError in File C:\{dir]}\{file}.rpt:Error in formula <mCustomerAttributes>.'Dim result As String'This field name is not known.Details: errorKind ************* Report without variables works fine with Viewer and in Crystal Reports Designer report with variables works also fine. I have tried with both "formula-syntaxes" - basic and crystal. But Viewer always gives error when trying to define new variable.I think the problem might be with CR -versions, because VS-project has formerly been designed to VS2003 and CR9 or 10. Now I'm using VS2005 and CR11. Though I have changed all references to new CrystalDecisions-asseblies (Ver.11.0.3300.0), when I debug the project and checkout the Viewers ReportSources FormatEngine Shows version CR9_2.... I have no idea where it gets this version...***************DEBUG-view when Viewer is created *******************CrystalReportViewer |_ ReportSourceClassFactoryName ... , Version=11.0.3300.0 , ... |_ ReportSource |_ FormatEngine {CrystalDecisions.CrystalReports.Engine.FormatEngine} |_ ClientVersionHeader {CrystalDecisions.Shared.ReportServiceVersionHeader} |_ | version = 920 (int) |_ Static members |_ VER_CR9 = 920 (int)**************************************** Could anyone have any answers or tips for this problem? I'd really appreciate it... ---AksuHas anyone been able to answer this question?
I am having the same problem:
I am designing a report in Crystal Reports XI Developer that contains parameters, which are passed to a stored procedure and are also used within formulas ( in Crystal Syntax ie. {?FORMAT_ID} ) in the report itself.
I can run the report successfully in CRXI Developer. The formulas use the correct values from the parameters entered during execution and everything looks good.
I then deploy the report to Business Objects Enterprise XI. I do all of the things necessary to manage the report including setting up the proper database connection information and default parameter values.
When I run the report using the Crystal Report Viewer, I get the following error message:
Error in File Forecasting.rpt:
Error in formula <Report Format>.
'if (not isNull({?FORMAT_ID} ) ) then
This field name is not known.
Details: errorKind
This happens when I press the "Preview" button in the Manage Object dialog from Crystal or when I run the report using InfoView.
I have changed the formulas and it doesn't seem to matter what the specific content of the formula is; other than the existence of a parameter reference in the formula. If I comment out the parameter and replace it with a hard-coded value, it gets through the formula fine.
Does Business Objects Enterprise XI support crystal reports with parameter references in the formulas?
Thanks,
Tim H.
Edited by: Tim Haley on Nov 25, 2008 11:11 PM
Edited by: Tim Haley on Nov 25, 2008 11:12 PM -
Need some clarification on Replacement Path with Variable
Hello Experts,
Need some clarification on Replacement Path with Variable.
We have 2 options with replacement path for characteristic variables i.e.
1) Replace with query
2) Replace with variable.
Now, when we use "Replace with variable" we give the variable name. Then we get a list for "Replace with" as follows:
1) Key
2) External Characteristic Value Key
3)Label
4)Attribute value.
I need detailed explanation for the above mentioned 4 options with scenarios.
Thanks in advance.
Regards
LavanyaHi Lavanya,
Please go through the below link.
http://help.sap.com/saphelp_nw70/helpdata/EN/a4/1be541f321c717e10000000a155106/frameset.htm
Hope this gives you complete and detailed explaination.
Regards,
Reddy
Maybe you are looking for
-
When I assign new Item created to single org it is not shown on PO.
One item is created and assigned to single org but not able to view on PO. While I do assign all it is seen on PO. Setup>Organization>finantial option>supplier purchesing>inv org --> is NOT item master but other org. Is this problem is becoz of this.
-
My document set-up is two columns. I want to insert images with captions in the left column and text-only in the right column. I would like to have right column text contain itself within the right column. Ditto for the left column. I do not want con
-
Urgent: How to bring the workspace launcher window back in Eclipse
Hi all, I accidently checked the "Use this as the default and do not ask again" checkbox appeared in the workspace launcher window in eclipse. Now I want to create a new workspace. But don't know how to do it. I guess if I can see the workspace launc
-
Hi, I have made a JSP report using barcode javabean provided by the Oracle. Appropriate codes were inserted in the web source of report. When I preview in paper layout I don't see any barcode image, and in web layout mode it is working fine and barco
-
Text tool in Photoshop CS3 missing default resource files.
when I try to use the text tool in my Photoshop CS3 I always get a message that says that I am missing the default resource files for the tool. How do I solve this..? And if possible, where can I get said files..?