How to compare string in PL/SQL? - oracle

i just want to know that, there is any way through which i can Compare a column value with Some String value.Something like this...
suppose column name is SHIPMENT_EXPEDITE_HAWB then can i have like this in plsql
SHIPMENT_EXPEDITE_HAWB=='PD'
Thaanks in advance!!!

You just need one equals, not two.
IF shipment_expedite_hawb = 'PD' THEN
dbms_output.put_line('Same');
END IF;

Just use the comparison operator =
E.g.
SHIPMENT_EXPEDITE_HAWB = 'PD'

Related

Concatenating string from SSIS for loop task

I have an SSIS package which loops over an array of dates. On each iteration I would like to append the current date to a string to get a full string of all the dates iterated.
What I did was to make an expression where: dateconcatvariable + ", " +currentdatevariable
However, dateconcatvariable is resetting on every iteration of the for loop and so in the end I end up with the last date iterated over instead of all the dates.
the variable is a package level variable.
Any ideas on how to get a concatenation to happen on SSIS?
Thanks!
1. Create a string variable #User::var
2. Use an Expression component and set the expression to #User::var = #User::var + (WSTR, 15)#User::yourdatevar
This should give you the general idea.

match regular expression

I have to requirement to check the value 91981552e1775310VgnVCM100000a2b6140a____;standard;212.58.244.70;Oct-22-2012;24353teehdtehg; where the date and 24353teehdtehg is dynamic.
How can I may it more generic so that I can check expected_value =~/actual_value/ excluding the dynamic values in Ruby.
I wouldn't use a regular expression if at all possible. You seem to have an input string that can easily be altered and used to compare against an expected value without using a regular expression.
str = "91981552e1775310VgnVCM100000a2b6140a____;standard;212.58.244.70;Oct-22-2012;24353teehdtehg;"
actual_value = str.split(';')[0..-3].join(';')
# "91981552e1775310VgnVCM100000a2b6140a____;standard;212.58.244.70"
Then just compare the two
expected_value == actual_value
I guess you could use something like :
/91981552e1775310VgnVCM100000a2b6140a____;standard;212\.58\.244\.70;(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-\d{2}-\d{4};\d{5}[a-z]{9};/
depending on what the string could actually be.

Whats the XPath equivalent to SQL In query?

I would like to know whats the XPath equivalent to SQL In query. Basically in sql i can do this:
select * from tbl1 where Id in (1,2,3,4)
so i want something similar in XPath/Xsl:
i.e.
//*[#id= IN('51417','1121','111')]
Please advice
(In XPath 2,) the = operator always works like in.
I.e. you can use
//*[#id = ('51417','1121','111')]
A solution is to write out the options as separate conditions:
//*[(#id = '51417') or (#id = '1121') or (#id = '111')]
Another, slightly less verbose solution that looks a bit like a hack, though, would be to use the contains function:
//*[contains('-51417-1121-111-', concat('-', #id, '-'))]
Literally, this means you're checking whether the value of the id attribute (preceeded and succeeded by a delimiter character) is a substring of -51417-1121-111-. Note that I am using a hyphen (-) as a delimiter of the allowable values; you can replace that with any character that will not appear in the id attribute.

Ruby String manipulation of HTML Element IDs

I'm looking for a safe way of building a string of a HTML element id from another element id.
I need to go from something like "attr_name_442_a" to "attr-row-422", the text part of the ids are consistent with just the number changing. This number will be in the range of 1 to 4 digits.
I thought of doing this but is there a better Ruby style method?
newID = oldID.gsub("_","-").gsub("name","row").gsub("-a","")
You may be able to pull this off with a single Regex
newID = oldID.gsub /(\w+)_name_(\d+)_a/, '\1-row-\2'
new_id = "#$1-row-#$2" if $old_id =~ /\A([^_]+)_name_(\d{1,4})_a\z/
I would probably add an else condition if the regex didn't match just so I knew I was catching everything.

How do I extract the right most number in a string?

I have strings like this:
https://www.facebook.com/username_with_number_14/posts/101505775425654414
https://www.facebook.com/username/posts/101505775425654466
I need to extract the number on the end of the string in Ruby. In the first string, it is the second and last number, whereas in the second string it is the first, only and last number.
At the moment I am extracting the number like this:
int1 = Regexp.new('.*?(\\d+)',Regexp::IGNORECASE).match()[1]
But when this is applied to the first string, it extracts the number part of the username, not the desired number.
How can I do it so that it will work on both strings?
text = <<ENDTEXT
https://www.facebook.com/username_with_number_14/posts/101505775425654414
https://www.facebook.com/username/posts/101505775425654466
ENDTEXT
p text.lines.map{|line| line.scan(/\d+/).last}
#=> ["101505775425654414", "101505775425654466"]
for me works regexp like this:
^.*?(\d+)$
look here: http://rubular.com/r/CJzsgjedqJ
Try this
int1 = Regexp.new('.*\\/(\\d+)$',Regexp::IGNORECASE).match()[1]
The $ matches the end of the string. So I put all numbers from the last / to the end of the string into the capturing group 1.

Resources