Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB-QL, underscores

 
Jeremy Wright
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I received this question in a Whizlabs test, and I'm not sure I understand this right...

Select all pattern values of a LIKE expression that would identify a word starting with a 'J' and having 'on' as the last two characters.
[A] 'J%on_'
[B] 'J*on%'
[C] 'J%on*'
[D] 'J_on%'
[E] 'J%_on_'
They give the correct answer as A,E.
Quote: "The only way to identify words having 'on' as the last two characters is by having a string that contains 'on' and an underscore, as in 'on_'.

However, I understood that '_' stands for any single character. Can it also stand for nothing?

Thanks,

Jeremy
 
Sankar Subbiramaniam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do have the same understanding.
Quote from EJB specs page230:
The pattern-value is a string literal in
which an underscore (_) stands for any single character, a percent (%) character stands for any sequence
of characters (including the empty sequence), and all other characters stand for themselves.
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeremy Wright:
I received this question in a Whizlabs test, and I'm not sure I understand this right...

Select all pattern values of a LIKE expression that would identify a word starting with a 'J' and having 'on' as the last two characters.
[A] 'J%on_'
[B] 'J*on%'
[C] 'J%on*'
[D] 'J_on%'
[E] 'J%_on_'
They give the correct answer as A,E.
Quote: "The only way to identify words having 'on' as the last two characters is by having a string that contains 'on' and an underscore, as in 'on_'.

However, I understood that '_' stands for any single character. Can it also stand for nothing?

Thanks,

Jeremy


I have the same understanding too. It seems that the answer shoud be J%on which is not in the options.
Probable they mean that It should start with J and two charecters before last character should be 'on'. That would make the answer "J%on_". Still E wouldn't be right.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic