I have the HTML in the screenshot, I can get the table using:
//table[contains('#class','table')]
but there are several similar tables on the page. Now I want to make sure I have the right table by checking that its ths have a specific column header ( In this case 'Sqft)'.
I tried:
//table[contains('#class','table')]//th[contains(text(),'Sqft")
but this is failing. How to I get this working?
//table[contains(#class, 'table') and .//th[contains(., 'Sqft')]]
or the other way around
//th[contains(., 'Sqft')]/ancestor::table[contains(#class, 'table')][1]
On a general note, in order to prevent partial attribute matches, include the token delimiter in the search. For CSS class names, the delimiter is a space:
//table[contains(concat(' ', #class, ' '), ' table '))]
Related
I am trying to code a sqlldr.ctl file WHEN Clause to limit the records imported to those matching a portion of the current Schema's name.
The code I have (which does NOT work) is:
LOAD DATA
TRUNCATE INTO TABLE TMP_PRIM_ACCTS
when REGION_NUM = substr(user,-3,3)
Fields terminated by "|" Optionally enclosed by '"'
Trailing NULLCOLS
( PORTFOLIO_ACCT,
PRIMARY_ACCT_ID NULLIF (PRIMARY_ASSET_ID="NULL"),
REGION_NUM NULLIF (PARTITION_NUM="NULL")
)
sqlldr returns:
SQL*Loader-350: Syntax error at line 3.
Expecting quoted string or hex identifier, found "substr".
when PARTITION_NUM = substr(user,-3,3)
I cannot put single quotes around "user", because that turns it into the literal string "user". Can anyone explain how I can reference the "active" User in this WHEN Clause?
Thank you!
Can you try something like this? (now I can't make test with SQLLDR, but this is syntax I used for changing values):
when REGION_NUM = "substr(:user,-3,3)"
It doesn't look like you can. The documentation only shows fixed values:
Trying to use an expression in when that clause (or in nullif; thought I'd try to see if you could cause a rejection based on null PK value) you just see the literal value in the log:
Table TMP_PRIM_ACCTS, loaded when REGION_NUM = 0X73756273747228757365722c2d332c3329(character 'substr(user,-3,3)')
which is sort of what you referred when you said you couldn't quote user, but you'd have to quite the whole thing anyway. Using :user doesn't work either, the colon is seen as just another character, it doesn't try to find a column called user instead.
The simplest approach may be to pre-process the data file and remove any rows which don't match the pattern (e.g. via a regex). That would actually be slightly easier if you used an external table instead of SQL*Loader.
Alternatively, generate your control file and embed the correct literal value based on the user you'll connect as.
Here is the code:
-- create table novaya.unnormal as
select query from default.daily_session_mobile
where dt = '20161020'
and page in ('/click_search_deal', '/click_search_product')
and query like '%memberID=33930938%'
and query like '%스텐드지퍼팩%'
The result only has one record and it is right
The value in the field of "query" is
searchCount=52&rank=39&logType=click¤tView=/search_list&searchId=4c3ecee1354943e999e0c1566243bf87&logCategory=event&itemID=22780015&itemProductID=4&q=스텐드지퍼팩&memberID=33930938&productID=4993730&eventReferrer=/click_search_list&request_time=1476889555129&tz=+0900&appVersion=4.3.8&wl_mo=LG-F400L&wl_ma=LGE&wl_sn=Android&wl_v=4.4.2&wl_r=1440x2392&wl_l=ko&wl_c=KR
and there is no space in the value. We focus on the "q=스텐드지퍼팩&" in it.
It seems good.
But when I use create table novaya.unnormal as select ...
the table novaya.unnormal's query have been cut.
The new "query" only has a part of the whole query which is
"searchCount=52&rank=39&logType=click¤tView=/search_list&searchId=4c3ecee1354943e999e0c1566243bf87&logCategory=event&itemID=22780015&itemProductID=4&q="
half of it is missing.
What is wrong with this?
When you create a table using create table novaya.unnormal as statement, without specifying any input/output format and delimiters, all defaults will be chosen which probably causes the 스 character to act as a separator.
I suggest looking at the properties of the source table (describe formatted default.daily_session_mobile), and creating the new table with similar input/output format and delimiters. (setting them between novaya.unnormal and as)
I need to get the content of a cell, which occasionally contains a ',' character. If so, I need to isolate the content to the portion before the ',' character.
substring-before(//td[contains(text(),'Dokumentnummer')]/following-sibling::td[1],\",\")
This gives me the desired substring, but only if a ',' exists. How can I make it return the whole string, if it does'nt exist?
You can add a ',' before calling substring-before, thus making sure there will allways be at least one comma:
substring-before(concat(//td[contains(text(),'Dokumentnummer')]/following-sibling::td[1],
','),
',')
I have a fixed length data file a.dat with below data in it
1234544550002200011000330006600000
my focus is on specific positions
POSITION(1:4)
POSITION(5:8)
and I want to add values in these 2 positions and insert it in a field named Qty in XYZ_Table.
I am trying to the following in my CTL file. But it fails, and I don't know how to pursue it further.
LOAD DATA
INFILE '$SOME_DATA/a.dat'
APPEND
PRESERVE BLANKS
INTO TABLE XYZ_Table
(QTY POSITION(1:4)+POSITION(5:8) "to_number(:QTY)")
I need to achieve this addition functionality in SQL Loader only.
If the above methodology is not possible, it would be great if you can help me with a different approach.
P.S: What I am trying to achieve is just one part of the bigger CTL file.
You need to identify the positions you want to add together but not load into their own columns as "BOUNDFILLER", which means don't load them but remember them for use in an expression later. Then use like this:
LOAD DATA
infile test.dat
append
preserve blanks
INTO TABLE X_test
TRAILING NULLCOLS
(val_1 BOUNDFILLER position(1:4)
,val_2 BOUNDFILLER position(5:8)
,qty ":val_1 + :val_2"
)
If i have a CSV file that is in the following format
"fd!","sdf","dsfds","dsfd"
"fd!","asdf","dsfds","dsfd"
"fd","sdf","rdsfds","dsfd"
"fdd!","sdf","dsfds","fdsfd"
"fd!","sdf","dsfds","dsfd"
"fd","sdf","tdsfds","dsfd"
"fd!","sdf","dsfds","dsfd"
Is it possible to exclude any row where the first column has an exclamation mark at the end of the string.
i.e. it should only load the following rows
"fd","sdf","rdsfds","dsfd"
"fd","sdf","tdsfds","dsfd"
Thanks
According to the Loading Records Based on a Condition section of the SQL*Loader Control File Reference (11g):
"You can choose to load or discard a logical record by using the WHEN clause to test a condition in the record."
So you'd need something like this:
LOAD DATA ... INSERT INTO TABLE mytable WHEN mycol1 NOT LIKE '%!'
(mycol1.. ,mycol2 ..)
But the LIKE operator is not available! You only have = and !=
Maybe you could try an External Table instead.
I'd stick a CONSTRAINT on the table, and just let them be rejected. Maybe delete them after load. Or a unix "grep -v" to clear them out the file.