How to assign an xpath query result to a variable
I have a problem that I'm having trouble solving. I need to conditionally run a query based on the results of another query. Both are XPATH queries using extract. I can't seem to get it work as an IF...THEN; so I tried to assign a variable to the value of the query - lots of errors in SQL-Plus.
Here is a capsule of the queries:
This one validates the value of a state field from a table of the abbreviations. It works.
select 'Valid' from states where state =
(select extract(msg, '//RateRequest/*/SurveyAddress/StateCounty/text()').getStringVal()
from omnitest where mssgid = '300')
This one will check to see if the form is for a US address and is the one that needs to be conditional this doesn't work and I just left the If..Then statements in there for illustration. The query works fine by itself.
IF (select extract(msg, '//RateRequest/*/SurveyAddress/Country/text()').getStringVal()
from omnitest where mssgid = '300') = 'US' THEN
any help would be greatly appreciated.
Rick Price
Aanchal,
You said:
nothing happens and niether any error comesVery funny :-) Of-course no error comes -- because you "swallow" and ignore it in your code:
catch (SQLException sqlex) { }D'OH! (As Homer Simpson would say -- while slapping himself on the forehead!)
Try this instead:
catch (SQLException sqlex) {
sqlex.printStackTrace();
}Good Luck,
Avi.
Similar Messages
-
How to insert the select query result into table?
How to insert the select query result into table?
SELECT top 20 creation_time
,last_execution_time
,total_physical_reads
,total_logical_reads
,total_logical_writes
, execution_count
, total_worker_time
, total_elapsed_time
, total_elapsed_time / execution_count avg_elapsed_time
,SUBSTRING(st.text, (qs.statement_start_offset/2) + 1,
((CASE statement_end_offset
WHEN -1 THEN DATALENGTH(st.text)
ELSE qs.statement_end_offset END
- qs.statement_start_offset)/2) + 1) AS statement_text
FROM sys.dm_exec_query_stats AS qs
CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st
ORDER BY total_elapsed_time / execution_count DESC;
Thanks,
Tirumala1. SELECT INTO
Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
Use AdventureWorks2008R2;
Go
---Insert data using SELECT INTO
SELECT AddressLine1, City
INTO BothellAddresses
FROM Person.Address
where City = 'Bothell';
GO
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
2. INSERT INTO SELECT
Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
another table.
Use AdventureWorks2008R2;
Go
---Create Table
CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
---Insert into above table using SELECT
INSERT INTO BothellAddresses(AddressLine1, City)
SELECT AddressLine1, City
FROM Person.Address
where City = 'Bothell';
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
How to assign current date/time to a formula variable in Query Designer
How do I assign the current date to a formula variable in Query Designer? I need to use current data in a calculation and just need the date the report was run.
ThanksHi Philip,
There is an SAP formula variable to supply the current date in a formula. I think it is 0F_ADAY...install it from business content if you cannot see it in the query designer (formula box, under formula variables) and try using it.
Hope this helps... -
How to upload the web query result to CSV/Text file
Hi,
Kindly help me on the following.
1) I have info-provider (IP), which has info-objects "company code" and "supplier".
2) I built a query by putting company-code with a variable in free-charateristics and supplier-code in row.
3) When I run this query, it will ask company-code as input and the result will be filtered using company-code.
4) For this query, I created a web-template and assigned data-provider to display the data on the web.
5) The user wants to enter input company-code='1000' and write the data in a CSV file in a specific directory. i.e, by clicking the execute button (after entering company code) , the result should go to the CSV or text file. i.e. the application should automatically generate the file with query results.
Note: The user should not use context menu to EXPORT TO CSV OR EXCEL file.
Please let me know, if there is any tutorial. Thanks a lot advance help.
Regards
Kandasamy1. SELECT INTO
Below method will create table when data is inserted from one table to another table. Its useful when you need exactly same datatype as source table.
Use AdventureWorks2008R2;
Go
---Insert data using SELECT INTO
SELECT AddressLine1, City
INTO BothellAddresses
FROM Person.Address
where City = 'Bothell';
GO
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
2. INSERT INTO SELECT
Below method will need table to be created prior to inserting data. Its really useful when table is already created and you want insert data from
another table.
Use AdventureWorks2008R2;
Go
---Create Table
CREATE TABLE BothellAddresses (AddressLine1 NVARCHAR(60), City NVARCHAR(30))
---Insert into above table using SELECT
INSERT INTO BothellAddresses(AddressLine1, City)
SELECT AddressLine1, City
FROM Person.Address
where City = 'Bothell';
---VERIFY DATA
Select AddressLine1, City
FROM BothellAddresses
---DROP TABLE
DROP TABLE BothellAddresses
GO
Regards,
Vishal Patel
Blog: http://vspatel.co.uk
Site: http://lehrity.com -
How to get the dynamic query result
If in one query, there is the amount range dimension, based on different dimension value combination, the customer revenue should be refreshed into different range, how to make it by cube?
eg.
Customer Store Material Month Amount
C001 M & S Tennis 2005/01 "10"
C001 Douglas Tennis 2005/02 "60"
C002 M & S Soccer 2005/01 "1"
C002 M & S Soccer 2005/02 "50"
C002 M & S Tennis 2005/02 "50"
C003 Douglas Tennis 2005/01 20
Query condition:
Time Customer Amount Range Amount
2005 C001 0~50_____________0
2005 C001 51~100___________70
2005 C001 100 +____________0
2005 C002 0~50_____________0
2005 C002 51~100___________0
2005 C002 100+_____________101
2005 C003 0~50_____________20
2005 C003 51~100___________0
2005 C003 100+_____________0
However, if I drill down Time into month, the result is total different, I only list the result related to customer C001
Time Customer Amount Range Amount
2005/01 C001 0~50____________10
2005/01 C001 51~100__________0
2005/01 C001 100 +___________0
2005/02 C001 0~50____________0
2005/02 C001 51~100__________60
2005/02 C001 100 +___________0
Any good solution on that? Thanks for any input.
Message was edited by: Lei ShaoHi, Sen,
I used your solution in my infocube and query, where I created a structure with 'between'. However, it is still the simple summation in different amount range.
Just like the following:
Sales ORG / Sales Office / Sales Rep / Amount
East / Atlanta / 1001 / 3
East / Atlanta / 1002 / 4
So the query result is the same:
S-ORG / S-Office / S-Rep / Amount Range / Amount
East / Atlanta / 1001 / 0~5 / 3
East / Atlanta / 1001 / 5+ / 0
East / Atlanta / 1002 / 0~5 / 4
East / Atlanta / 1002 / 5+ / 0
When I remove 'drill down' for Sales Rep, the result is:
S-ORG / S-Office / Amount Range / Amount
East / Atlanta / 0~5 / 7
East / Atlanta / 5+ / 0
However our expection for the result is different, because in business traction, if we remove sales rep, the sales org and sales office will get the sub-total like this: (we can image it with ABAP program sub-total)
Sales ORG / Sales Office / Amount
East / Atlanta / 7
So our expection for the result is:
S-ORG / S-Office / Amount Range / Amount
East / Atlanta / 0~5 / 0
East / Atlanta / 5+ / 7
Therefore, any good suggestion for this?
Thanks a lot
Regards,
LS -
Correct wat to determine if the XPath Query resulted in a match
What is the correct way to determine of the XPath Query
(using e4x syntax) returned matching nodes?
The result is never a null reference even if there are no
matches found, and I can't seem to find a way to determine if the
XMLList returned has any nodes except for a convoluted way like so:
var matchingRecords:XMLList =
xmlData.dataTable[0].dataRow.(@someAttribute == someVariable);
var record:XML = matchingRecords[0]; //This is the part I
don't like to have to do.
if (record == null)
//This means no matches were found.
else
//This means atleast one match was found."...they feel they've done it all too perfectly ..."
I've been working with Flex since it was beta, and I must
disagree with this. In my experience, the Adobe/MM folks are paying
very close attention to what we say.
You need to understand that you do not modify/release
commercial software casually. It will take months to years. Be
patient, or find a workaround, they exist.
Be sure to log your wishes/bugs on the wishform. I know for a
fact that they monitor that. I have been contacted for
clarifications on my posts there.
http://www.macromedia.com/support/email/wishform/
Tracy -
How to get the sql query result?
Hi,
Currently I am using LV2012 to connect a Oracle database server. After the installations/settings for Oracle Express and Oracle ODBC driver done.
I am sucessfully to use the SQL command to query the data through my window command prompt.
Now the problem is, how I do the same task in Labview by using the database connectivity toolkits?
I have build a VI for query as attached, but i have no idea what pallete to use to get the query result.
Please help me ~~
Solved!
Go to Solution.
Attachments:
Query.vi 9 KBHere is a piece of code I use to test SQL commands, you can use the part that retrieves sql results.
It is also possible to get the column headers back, but that is for next lesson!
Attachments:
RunSQLCommand.vi 30 KB -
How to open the TFS query results in Excel?
Hello Guys,
Question 1: Is there any way to export the query results from the TFS web browser?
Question 2: Is there any way to export the query results from Team Explorer 2013?
Here is the query results in TFS:
How do I export this result in excel for further analysis?
I have also connected to Team explorer 2013 and right clicked on the query, but there is no option to open the results in Excel, see below:Hello,
_Pls follow these guide lines for ensuring proper output in Microsoft Excel:
1.First compare the fields properties and the frames properties between the reports created with wizard and the reports created manually.
2. Do not leave any space between two adjacent objects.
Explanation: Because any space, including a few pixels, between two adjacent objects will result in an empty cell or column in Excel output
3.Make sure that the widths of all objects are vertically consistent.
Explanation: If the objects are not exactly aligned vertically, that is, have inconsistent widths, it is likely to result in insertion of unwanted cells/columns in Excel.
4. Pls. Make sure that the vertical elasticity of the frames and repeating frames is not fixed unless you are sure you have allocated enough space to accommodate all the records.
Explanation: If you set the Vertical Elasticity property of a frame to Fixed, the output in Excel will show only as many records as could appear on the first page of the paper output. Since Excel does not have a page concept, it is not able to overflow the remaining rows to the next page.
5. For reliable formatting of spreadsheet output, enclose the whole layout area in a frame.
Explanation: This action prevents the possibility of parallel objects displaying in different vertical positions, one following the other.
Hope this helps.
Regards,
Alex -
How can I export the query result into access(*.mdb) file?
Dear all:
I want to export the query result displayed in jsp into excel file
and access file. And I have exported the result into excel format successfully, only one line should be added in the head of Jsp:
<%@ page contentType="application/vnd.ms-excel; charset=gb2312" %>
But how can I export it in access(*.mdb) file? I have replaced "excel"
with "access". But it can't achive my goal.
What should I do to achieve my goal?
Thanks!The only reason your Excel export works is that Excel knows how to interpret comma separated values as an input file format. Access has no such beast.
If you absolutely must provide info in an mdb, one solution would be to create an ODBC datasource pointing to an empty mdb, then push data into it using the jdbc:odbc bridge, then make a copy of the file and stream it down to the browser. You may run into some ugly file locking items here - set the ODBC connection so it is not shared, and that might help.
This one is going to be ugly.
I suppose another approach would be to write a simple VB applicatin that uses automation to create an MDB, then stream that file down to the browser from your servlet. That would almost certainly be faster than the ODBC approach.
- K -
How to ensure that the query results are fetched from the BW acclerator.
Hi Experts,
Suppose if i want to execute the query with BIA option, I can achieve it in RSRT .
1)But is there some query settings or properties where we can make sure that whenever a query(say Q1) is executed, always the data should be fetched from the BIA index.
2)Suppose the BIA indexing has failed due to some reasons, will the data be fetched from the previously updated BIA index??
regards
akshayHi man,
1)But is there some query settings or properties where we can make sure that whenever a query(say Q1) is executed, always the data should be fetched from the BIA index.
If you have built up BIA index on a cube, then every query on the cube or MultiProvider will automatically use BIA index. No additional settings required. You can use the following way to test whether a query is using BIA or not:
Go to RSRT, input query name, click 'execute and debug' and check 'Display Statistics Data' and 'Do Not Use Cache'. Execute. After the query result press F3, now you should be able to see statistics. There's a tab 'BIA Access'. If you see something there then it means BIA index is used.
2)Suppose the BIA indexing has failed due to some reasons, will the data be fetched from the previously updated BIA index??
If BIA rollup is failed, then the last request(s) would not available in reporting and query will use BIA index for earlier requests. You can consider it like aggregate. But if initial fill of BIA failed then you would not be able to use BIA index.
Regards,
Frank
Edited by: Frank Lee on Jul 14, 2009 2:22 PM -
How to get an sql query result to a textbox?
i am working with jdk1.4 and office 2003.
i need to run the following SQL Query: "SELECT max(BookId) as BookId FROM Books" where BookId is an autonumeric generated number obtained from the field autonumber in access 2003 database.
now, the result of this must be placed in a textbox.
does anyone knows how to do this?
I ve tried this but nothing happens and niether any error comes
st = con.createStatement (); //Creating Statement Object.
long bookNo; //Use for Comparing the Book's Id.
try { //SELECT Query to Retrieved the Record.
String q = "SELECT max(BookId) as BookId FROM Books";
ResultSet rs = st.executeQuery (q); //Executing the Query.
bookNo = rs.getLong ("BookId"); //Storing the Record.
bookNo =(bookNo+1);
txtBookId.setText (""+bookNo);
catch (SQLException sqlex) { }
does anyone knows how to do this?????plz help me out.
Thanks
AanchalHi Aanchal,
If an SQL error occurs now, you cannot see it in your code. You should do something with the exception you catch, e.g. printing it: sqlex.printStackTrace(), so that you can see if something goes wrong.
For your number, you should move the cursor in the resultset to the first row - either by: calling first( ) or next ( ), then you can retrieve your booknumber.
Best Regards,
Martijn -
Hi BI Gurus,
Query has been created by user "A" and transport request also assigned and released in development system and it has moved to production system. Now the client came up with new requirement to that purticular query and user "B" need to do some changes as per the client requirement. The user "B" is trying to modify the query in development system but it cant allowing changes and giving some error message like query is not assigned to transport request. So user "B" created one transport request in development system and went in transportations option in modelling (Transaction RSA1) collected query and changed transport package and assigned new transport number. Now it was saved under user "B" TR and after doing this user "B" is trying to do changes but getting the same error message.
I hope you understand the problem. Can anybody tell me how to do the changes?
Thanks in advance,
venkatNOrmally this should work. Rsa1->transport connection.
select query element
give query name
transfer the query to right pane
right click on query and change package
it will prompt for request
create new request, if no prompt, change the user name and you will get the prompt
now open the query in query designer and save the changes -
How to Publish the ABAP query results as csv
Hi,
I have a scenario and need help for the same, I need to query a table in CRM which has the long text information and publish or save the result as a csv file, is it possible? if so please tell me the steps and code if available
Thanks
Akila.RHi,
Two formats of creating a CSV file:
report zrich_0001 .
data: it001 type table of t001 with header line.
data: iout type table of string .
data: xout type string.
field-symbols: <fs>.
select * into table it001 from t001.
loop at it001.
clear xout.
do.
assign component sy-index of structure it001 to <fs>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
xout = <fs>.
else.
concatenate xout <fs> into xout separated by ','.
endif.
enddo.
append xout to iout.
endloop.
call function 'GUI_DOWNLOAD'
exporting
filename = 'C:\test.csv'
tables
data_tab = iout.
report ztest.
type-pools:TRUXS.
data: begin of itab occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
end of itab.
data: itab1 type TRUXS_T_TEXT_DATA.
select vbeln
posnr
up to 10 rows
from vbap
into table itab.
CALL FUNCTION 'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ','
TABLES
I_TAB_SAP_DATA = itab
CHANGING
I_TAB_CONVERTED_DATA = itab1
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\TEMP\TEST.CSV'
TABLES
data_tab = itab1
EXCEPTIONS
OTHERS = 1.
Use SE38.
Regards
Subramanian -
How to speed up the query result time
While executing the following query the result comes after 22 secs.
How could i minimize this time ? Please suggest.
SELECT DISTINCT
PERIOD_NO,
ITEM_CODE,
ITEM_NAME,
SUM(CASE WHEN LEVEL_TYPE IN 'SUB ZONE' THEN WD_FORECAST_QTY_BU / CNV / ML ELSE 0 END)TOT_FRCST
FROM SHEET_HEAD, SHEET_DETAIL, ITEM_DETAIL
WHERE WH_SYS_ID = WD_WH_SYS_ID
AND ITEM_CODE = WD_ITEM_CODE(+)
AND PERIOD_NO BETWEEN :PERIOD1 AND :PERIOD2
AND WH_REVISION_NO = 0
AND WH_LEVEL_CODE NOT IN (SELECT WH_LEVEL_CODE FROM SHEET_HEAD WHERE WH_REVISION_NO = 1)
GROUP BY ITEM_CODE, ITEM_NAME, WH_PERIOD_NOSanjayHi,
with speed the suggest would always be expirement with indexing on the parameters, after first analysing what is currently happening in terms of full table scans etc that are 'most expensive'.
In terms of the specifics on your code the following sticks out as costly; -
AND WH_LEVEL_CODE NOT IN (SELECT WH_LEVEL_CODE FROM SHEET_HEAD WHERE WH_REVISION_NO = 1)Here I would see if you can rewrite it, perhaps with a left join / self join to achieve the same ends, compare the timings you may be surprised.
regards,
Robert. -
How can I use cfc query result to grid.dataprovider
In rich from ,I builder a button , when it click ,I want to
use cfc query some sql result ,and put it in grid.
I use flower code ,but it have error ,help me !!!
<CFSAVECONTENT variable="upd_query">
<cfinvoke
component="test.components.Getorder"
method="GetAllorder"
returnvariable="GetAllorderRet">
</cfinvoke>
<cfif Isstruct(GetAllorderRet)>
s_ghid1.visible= false;
abc.text = "The GetallorderRet is struct";
</cfif>
<cfoutput>
listorder.dataProvider = [#GetAllorderRet.];
</cfoutput>
</CFSAVECONTENT>
In form:
<cfinput type="button" name="s_search" style="
borderThickness:1;" onClick="#upd_query#"
value="Search"/>Can you expand on that? I'm sorry but I am new and a novice to the SSIS world and I want to do this as best I can and as efficiently as I can. Are you saying that Rajen's way suggested above is the way to go?
A little background....external data from a 3rd party client. I'v staged that external data to a SQL Server staging table. I have to try and match that data up to our database using SSN, DOB, and Gender...and if I can't match that way then I have to try
and match by Name. I need to make sure that there is only one and only one account for that match. If I cannot match and match one and only one, then I'll create rows on a DataAnomaly Table. If I do match, then I have to check and make sure that there is only
one and only one Member span for that match. Similarly handle the data anomaly and then check and make sure there is a "Diabetes" claim and similarly handle the DataAnomaly accordingly.
That's where I'm at. Sooooo are you saying to use Rajen's suggestion? I don't think I can do that because I need multiple SQL tasks and I cannot connect multiple OLE DB Source tasks.
Any help and suggestions are greatly appreciated.
Thanks.
Maybe you are looking for
-
How can I get a report to use a DSN instead of a database name?
DSNs are great things. By using a DSN in a database connection string, you don't have to worry about what happens if you have to look at a different database, or if a database name changes. All you have to do is change the database the DSN points t
-
How Do I Display My Number on my Screen Permanently?
How do I diplay My Number on my BB Curve 9700 3G? I can't figure it out!
-
PR05 Travel Expense Manager.Messag : Error while initiating travel form
Hi, We're upgrading from 4.6C to ECC6.0 . With transaction PR05 we're getting error message . Transaction PR05 -> entered in personnel no XXXXXXXXX and pressed the green checkmark. I then select a line - for this I selected the second line that said
-
DMS--Doc Mngt System---to attach word docs to Sales orders
dear, can u eloborate a bit more on DMS(documaent management system--to attach word doc's to our sales orders)....where we actually activate this...and how we link it up to our sales doc's..where we configure all these settings......would be really h
-
Hi guys i want to learn struts.i am quite familiar with java ejb jsp servlets etc.. i just wanted to learn this framework can any body provide some guidelines how to go about i mean can some some give me a sample code and all the jar files needed.. P