 




<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Best way to retrieve values, SQL or Queries and how?</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/</link>
	<description></description>
	<lastBuildDate>Sat, 25 May 2013 17:28:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: bug68</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-69884</link>
		<dc:creator>bug68</dc:creator>
		<pubDate>Tue, 03 Nov 2009 13:11:19 +0000</pubDate>
		<guid isPermaLink="false">#comment-69884</guid>
		<description><![CDATA[Hi, again

thanks Tom for you tip, this select instruction are very usefull, and for my needs work well.
Normally i use the suggestion of CharlieBrowne inside of programs but in that case i need this for quit solution.

thank everybody.]]></description>
		<content:encoded><![CDATA[<p>Hi, again</p>
<p>thanks Tom for you tip, this select instruction are very usefull, and for my needs work well.<br />
Normally i use the suggestion of CharlieBrowne inside of programs but in that case i need this for quit solution.</p>
<p>thank everybody.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ronkoontz</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-69859</link>
		<dc:creator>ronkoontz</dc:creator>
		<pubDate>Mon, 02 Nov 2009 20:30:18 +0000</pubDate>
		<guid isPermaLink="false">#comment-69859</guid>
		<description><![CDATA[In query400 use the Like keyword.]]></description>
		<content:encoded><![CDATA[<p>In query400 use the Like keyword.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bug68</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-69349</link>
		<dc:creator>bug68</dc:creator>
		<pubDate>Thu, 22 Oct 2009 11:18:36 +0000</pubDate>
		<guid isPermaLink="false">#comment-69349</guid>
		<description><![CDATA[thanks Tom for this, i will try test and then send my comments.

bug68]]></description>
		<content:encoded><![CDATA[<p>thanks Tom for this, i will try test and then send my comments.</p>
<p>bug68</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-69321</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Wed, 21 Oct 2009 20:56:50 +0000</pubDate>
		<guid isPermaLink="false">#comment-69321</guid>
		<description><![CDATA[&lt;pre&gt;
SELECT
   sourceColumn ,
   posstr(sourceColumn,&#039;60F:&#039;)+length(&#039;60F:&#039;) as locS,
   locate(&#039; :&#039;,sourceColumn, posstr(sourceColumn,&#039;60F:&#039;) ) as locE,
   substr(sourceColumn, posstr(sourceColumn,&#039;60F:&#039;)+length(&#039;60F:&#039;),locate(&#039; :&#039;,sourceColumn, posstr(sourceColumn,&#039;60F:&#039;) ) -length(&#039;60F:&#039;) -1) as extractSubstring
 FROM sourceTable
&lt;/pre&gt;

I used sourceColumn as the name of the column you&#039;re extracting from and sourceTable as the name of the table. The first three columns in the select-list are there just for visual comparison.

posstr(sourceColumn,&#039;60F:&#039;) is where the first search-string starts
locS is the starting position of your extract-string in sourceColumn
locE is the position of the ending search-string in the substring beginning where the first search-string starts

extractSubstring is all you should need. Where I used [length(&#039;60F:&#039;)], you can probably just use the constant length of &#039;60F:&#039; which is (4).

Regardless, I probably wouldn&#039;t do it this way. If it needed to be done in SQL, I&#039;d create a UDF() and code the logic. Along with the logic, I&#039;d explain what in the world I was doing.

With a UDF(), you could also pass in any search values; you wouldn&#039;t be limited to &#039;60F:&#039; nor &#039; :&#039;. A UDF() could test to ensure that &#039;60F:&#039; appeared in the source string and that &#039; :&#039; was in a position after the first search-string.

Trying to make this work in a single SQL statement is asking for trouble when the first minor change in specs comes along. I&#039;m not sure I even like trying to explain here what the above statement does! Very ugly, eh?

Tom]]></description>
		<content:encoded><![CDATA[<pre>
SELECT
   sourceColumn ,
   posstr(sourceColumn,'60F:')+length('60F:') as locS,
   locate(' :',sourceColumn, posstr(sourceColumn,'60F:') ) as locE,
   substr(sourceColumn, posstr(sourceColumn,'60F:')+length('60F:'),locate(' :',sourceColumn, posstr(sourceColumn,'60F:') ) -length('60F:') -1) as extractSubstring
 FROM sourceTable
</pre>
<p>I used sourceColumn as the name of the column you&#8217;re extracting from and sourceTable as the name of the table. The first three columns in the select-list are there just for visual comparison.</p>
<p>posstr(sourceColumn,&#8217;60F:&#8217;) is where the first search-string starts<br />
locS is the starting position of your extract-string in sourceColumn<br />
locE is the position of the ending search-string in the substring beginning where the first search-string starts</p>
<p>extractSubstring is all you should need. Where I used [length('60F:')], you can probably just use the constant length of &#8217;60F:&#8217; which is (4).</p>
<p>Regardless, I probably wouldn&#8217;t do it this way. If it needed to be done in SQL, I&#8217;d create a UDF() and code the logic. Along with the logic, I&#8217;d explain what in the world I was doing.</p>
<p>With a UDF(), you could also pass in any search values; you wouldn&#8217;t be limited to &#8217;60F:&#8217; nor &#8216; :&#8217;. A UDF() could test to ensure that &#8217;60F:&#8217; appeared in the source string and that &#8216; :&#8217; was in a position after the first search-string.</p>
<p>Trying to make this work in a single SQL statement is asking for trouble when the first minor change in specs comes along. I&#8217;m not sure I even like trying to explain here what the above statement does! Very ugly, eh?</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: charliebrowne</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-68959</link>
		<dc:creator>charliebrowne</dc:creator>
		<pubDate>Mon, 12 Oct 2009 20:02:36 +0000</pubDate>
		<guid isPermaLink="false">#comment-68959</guid>
		<description><![CDATA[Then I would say you should scan for &#039; :60F:&#039; 
The more data you can include in the scan, the better chance you have of not changing something incorrectly.
Now once you fine the starting position in the string, you can rplace the value.]]></description>
		<content:encoded><![CDATA[<p>Then I would say you should scan for &#8216; :60F:&#8217;<br />
The more data you can include in the scan, the better chance you have of not changing something incorrectly.<br />
Now once you fine the starting position in the string, you can rplace the value.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bug68</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-68951</link>
		<dc:creator>bug68</dc:creator>
		<pubDate>Mon, 12 Oct 2009 17:20:25 +0000</pubDate>
		<guid isPermaLink="false">#comment-68951</guid>
		<description><![CDATA[HI,

about your question, Tom, yes always trailing blanks and a colon after the value.

thanks]]></description>
		<content:encoded><![CDATA[<p>HI,</p>
<p>about your question, Tom, yes always trailing blanks and a colon after the value.</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-68847</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Thu, 08 Oct 2009 21:58:05 +0000</pubDate>
		<guid isPermaLink="false">#comment-68847</guid>
		<description><![CDATA[Is there always trailing blanks and a colon after the value? Or is the leading colon for the next segment the only delimiter?

Tom]]></description>
		<content:encoded><![CDATA[<p>Is there always trailing blanks and a colon after the value? Or is the leading colon for the next segment the only delimiter?</p>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: graybeard52</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/best-way-to-retrieve-values-sql-or-queries-and-how/#comment-68590</link>
		<dc:creator>graybeard52</dc:creator>
		<pubDate>Thu, 01 Oct 2009 23:04:42 +0000</pubDate>
		<guid isPermaLink="false">#comment-68590</guid>
		<description><![CDATA[To find it in RPG, use the %scan to scan for the string.  It returns the position the string is found.]]></description>
		<content:encoded><![CDATA[<p>To find it in RPG, use the %scan to scan for the string.  It returns the position the string is found.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 6/9 queries in 0.013 seconds using memcached
Object Caching 366/369 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-25 17:53:52 -->