<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">KeithBertram's Blog</title><subtitle type="html" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/atom</id><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog" /><link rel="self" type="application/atom+xml" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/atom" /><generator uri="http://telligent.com" version="12.1.2.22116">Telligent Community (Build: 12.1.2.22116)</generator><updated>2008-11-25T14:08:00Z</updated><entry><title>Oracle Quoted Strings</title><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/oracle-quoted-strings" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/oracle-quoted-strings</id><published>2012-03-15T01:52:27Z</published><updated>2012-03-15T01:52:27Z</updated><content type="html">&lt;p&gt;Oracle 10g instroduced a new way to quote strings to prevent ​those strings with single apostrophes from causing errors. For example:&lt;/p&gt;
&lt;p&gt;insert into myaddress (name, address) values (&lt;span class="ms-rteForeColor-2"&gt;&amp;#39;Jim O&amp;#39;Brien&amp;#39;&lt;/span&gt;, &amp;#39;10 Elm St.&amp;#39;);&lt;/p&gt;
&lt;p&gt;would fail because of the single apostrophe in O&amp;#39;Brien.&lt;/p&gt;
&lt;p&gt;Using Oracle 10g or later, you can change the quoted string to be:&lt;/p&gt;
&lt;div&gt;insert into myaddress (name, address) values (q&amp;#39;#Jim O&amp;#39;Brien#&amp;#39;, q&amp;#39;#10 Elm St.#&amp;#39;);&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;Simply start the quote of the string with the letter q followed by a single apostrophe and then another character of your choosing. This third character can be any character found on the keyboard such as !@#%^&amp;amp;* or any alpha. To end string, use the character you used in the third spot followed by a single quote.&lt;/div&gt;
&lt;div&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;I&amp;#39;ve tested sql statements processed with mdlDB_addRowWithMslink and&amp;nbsp;mdlDB_processSQL which performed without issue. I also tested mdlDB_writeColumn and received error -1765 &amp;quot;&lt;span style="text-decoration:underline;"&gt;quoted string not properly terminated&amp;quot;.&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://communities.bentley.com/aggbug?PostID=202328&amp;AppID=29879&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Keith Bertram </name><uri>https://communities.bentley.com/members/879fb95e_2d00_12bc_2d00_46cf_2d00_a82c_2d00_3862f8b6bf84</uri></author></entry><entry><title>MDLCGI</title><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/mdlcgi" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/mdlcgi</id><published>2009-02-02T23:58:00Z</published><updated>2009-02-02T23:58:00Z</updated><content type="html">&lt;p&gt;
Sometimes is just pays to read the doc. I was expirementing with mdlcgi today and I discovered a problem with my code in that the returned string was not being interpreted as XML as I wished. In other words, my xmlhttp.responseXML object was returning NULL each time even though my xmlhttp.responseText had the correct xml looking string value. Everything I could find on the web pointed me to not having the correct Content-Type value set to &amp;quot;text/xml&amp;quot;. The question I kept asking my self is where do I set this value? I think I tried everything until I decided to read the document for mdlcgi. The doc's content included the following:
&lt;/p&gt;
&lt;p&gt;
&amp;quot;Write a ContentType header specifying the response's MIME type, followed by a blank line, to the opened pipe.&amp;quot;
&lt;/p&gt;
&lt;p&gt;
Ah Ha! So I added the following line to the top of my returned pipe and it WORKED!.
&lt;/p&gt;
&lt;p&gt;
Content-Type: text/xml; charset=utf-8\n\n&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Note the double \n at the end of the line. This line must be by itself and it must be followed by a blank line. 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://communities.bentley.com/aggbug?PostID=33943&amp;AppID=29879&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Keith Bertram </name><uri>https://communities.bentley.com/members/879fb95e_2d00_12bc_2d00_46cf_2d00_a82c_2d00_3862f8b6bf84</uri></author></entry><entry><title>Finding Gaps of numbers within an Oracle Table</title><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/finding-gaps-of-numbers-within-an-oracle-table" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/finding-gaps-of-numbers-within-an-oracle-table</id><published>2009-01-10T01:41:00Z</published><updated>2009-01-10T01:41:00Z</updated><content type="html">&lt;p&gt;
Today I needed to find a gap within a series of numbers located in a table. So for instance I have a table with a series of mslink values:
&lt;/p&gt;
&lt;p&gt;
MSLINK
&lt;/p&gt;
&lt;p&gt;
1
&lt;/p&gt;
&lt;p&gt;
2
&lt;/p&gt;
&lt;p&gt;
3 
&lt;/p&gt;
&lt;p&gt;
5 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
In the above table, I want to find the number 4. The solution is to use the &amp;quot;minus&amp;quot; query operator available from Oracle. Basically the minus operator takes the results of one query and gives you the values that do not exist in the second query. Here is the query:
&lt;/p&gt;
&lt;p&gt;
select mslink+1 from mytable minus select mslink from mytable;
&lt;/p&gt;
&lt;p&gt;
The trick here is the +1 for the mslink. When the database gets to the value of 3 in the table, it will add one making the value 4. It will then take the 4 and see if it exists in the second query. Since 4 does not exist in the table, it will return 4 as a gap which it correct! The query will probably do two full table scans but this is better than searching through the table yourself by fetching each row. I have not tested this on a table with millions of rows. My test example had about 4K rows and worked great! If I get around to testing this on a table with million+ rows, I'll update this blog. 
&lt;/p&gt;
&lt;p&gt;
If other gaps exist, they also will be returned by Oracle. If you want just one row returned, you could make a subquery of the above and use the rownum property. Here is an example:
&lt;/p&gt;
&lt;p&gt;
select mslink from (select mslink+1 mslink from mytable minus select mslink from mytable) where rownum = 1;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://communities.bentley.com/aggbug?PostID=29683&amp;AppID=29879&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Keith Bertram </name><uri>https://communities.bentley.com/members/879fb95e_2d00_12bc_2d00_46cf_2d00_a82c_2d00_3862f8b6bf84</uri></author></entry><entry><title>Interesting Oracle sql situation - And a work around</title><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/interesting-oracle-sql-situation-and-a-work-around" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/interesting-oracle-sql-situation-and-a-work-around</id><published>2008-12-18T19:16:00Z</published><updated>2008-12-18T19:16:00Z</updated><content type="html">&lt;p&gt;
I ran into an interesting situation with Oracle's to_number function. First let me setup what I was trying to do. Bentley Comms has a table named mapindex that contains a column named mapname. This column typically contains names of maps used by the user. It can also contain what I would call &amp;quot;coded&amp;quot; values such as &amp;quot;x-&amp;lt;MSLINK #&amp;gt; where the &amp;lt;MSLINK #&amp;gt; is an actual mslink value contained within one of the other maps. The use of this coded value is not important for this blog. What I needed to do is search through this table and find all the rows that start with &amp;quot;x-&amp;quot; and whose MSLINK # is within a particular range. The query I built to return the required rows is shown below (the range I'm using in this example is between 1 and 100:
&lt;/p&gt;
&lt;p&gt;
select * from mapindex where mapname like 'x-%' and to_number (substr (mapname, 3)) &amp;gt; 1 and to_number(substr(mapname, 3)) &amp;lt; 100;
&lt;/p&gt;
&lt;p&gt;
To help understand the problem, here is some sample data.
&lt;/p&gt;
&lt;table style="width:105px;height:115px;"&gt;
	
		&lt;tr&gt;
			&lt;th&gt;mapname&lt;/th&gt;
		&lt;/tr&gt;
	
	
		&lt;tr&gt;
			&lt;td&gt;mymap1&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;mymap2&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;x-1&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;x-2&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;x-3&lt;/td&gt;
		&lt;/tr&gt;
	
&lt;/table&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
On my Oracle server, the query worked perfectly but on the customer's server, the query returned error &amp;quot;ORA-01722: invalid number&amp;quot;. As it turned out our two servers processed the query differently.My server filtered the rows by those starting with x- first and then processed the to_number functions. Thus providing an error free result. The customer's server didn't filter based upon the column mapname starting with x- and instead sent the mymap1 and mymap2 values to the to_number function. i.e. to_number (substr ('mymap1', 3)) and to_number(substr('mymap2', 3)) respectively. Since these produce invalid numbers, the function fails with the error mentioned above. So how did I solve the problem? Actually it was quite simple. I made a subquery that guarentees to return the rows whose mapname column starts with x- and then I sent these results to an outer query that processes the to_number function. Here is the final query:
&lt;/p&gt;
&lt;p&gt;
select * from &lt;span style="text-decoration:underline;"&gt;(select mapname from mapindex where mapname like 'x-%') &lt;/span&gt;where to_number (substr (mapname, 3)) &amp;gt; 1 and to_number(substr(mapname, 3)) &amp;lt; 100; 
&lt;/p&gt;
&lt;p&gt;
The underlined section is the subquery that returns only those rows whose mapname starts with x-. These results are then passed to the outer query guarenteeing that starting with the 3rd character and beyond works nicely with the to_number function. I wonder if there are other ways to solve this problem. I was hoping to find an Oracle hint that forces the where clause to process in a given order. I didn't find one but maybe it does exist.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://communities.bentley.com/aggbug?PostID=26978&amp;AppID=29879&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Keith Bertram </name><uri>https://communities.bentley.com/members/879fb95e_2d00_12bc_2d00_46cf_2d00_a82c_2d00_3862f8b6bf84</uri></author><category term="Oracle" scheme="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/archive/tags/Oracle" /><category term="subquery" scheme="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/archive/tags/subquery" /><category term="query" scheme="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/archive/tags/query" /></entry><entry><title>mdlDB_findLinks</title><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/mdldb-findlinks" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/mdldb-findlinks</id><published>2008-12-15T22:53:00Z</published><updated>2008-12-15T22:53:00Z</updated><content type="html">&lt;p&gt;
mdlDB_findLinks is a great api function used to find elements in models that have a database link to a given mslink and entity number. Today I discovered slight problem that causes the function to return an error even though the element should be found in the given model. I'll spare you from the details and just say that the integer passed by reference in the second parameter MUST be initialized to zero else you'll run into the same problem as I did earlier today. Thanks to Allen Brown of Bentley for helping me discover this problem. 
&lt;/p&gt;
&lt;p&gt;
I also found out that this function does NOT get the elements from the element cache as documented. Instead it sets up a scanner with an extended attribute buffer to look for the elements. 
&lt;/p&gt;
&lt;p&gt;
One other note in regards to this function and looking for elements with dmrs linkages. Set the environment variable MS_FINDDMRSLINK to a value of one (1) to return such elements. Without this variable only the linkage types defined by MS_LINKTYPE are returned. 
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://communities.bentley.com/aggbug?PostID=26086&amp;AppID=29879&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Keith Bertram </name><uri>https://communities.bentley.com/members/879fb95e_2d00_12bc_2d00_46cf_2d00_a82c_2d00_3862f8b6bf84</uri></author><category term="scanning" scheme="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/archive/tags/scanning" /><category term="Database" scheme="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/archive/tags/Database" /></entry><entry><title>ASP.NET and the default Web Server</title><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/asp-net-and-the-default-web-server" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/asp-net-and-the-default-web-server</id><published>2008-12-02T22:47:00Z</published><updated>2008-12-02T22:47:00Z</updated><content type="html">&lt;p&gt;
I'm a relative novice at writing ASP.NET applications so this post may seem silly or trivial to the more experienced but I noticed that when I use the default Web Server (WebDev.WebServer.EXE in the Process list), it never seems to clean up after itself after I close the browser. In fact I even notice that the this webserver has a mind of its own when restarting the application after a previous debug session. Here is what I mean: my current application has several pages in which the user is prompted for various information. Within the last page, I print some variable information to the visual studio output window that is specific only to the this last page. If I debug the application and then restart the application from the beginning, I start to see the debug information that is specific to the LAST page scrolling in the output window. Strange!!!
&lt;/p&gt;
&lt;p&gt;
I've now reserved myself to just killing the WebDev.WebServer.EXE process from Task Manager and moving on... 
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://communities.bentley.com/aggbug?PostID=23069&amp;AppID=29879&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Keith Bertram </name><uri>https://communities.bentley.com/members/879fb95e_2d00_12bc_2d00_46cf_2d00_a82c_2d00_3862f8b6bf84</uri></author></entry><entry><title>Oracle 10g setup problem</title><link rel="alternate" type="text/html" href="https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/oracle-10g-setup-problem" /><id>https://communities.bentley.com/other/old_site_member_blogs/bentley_employees/b/keithbertrams_blog/posts/oracle-10g-setup-problem</id><published>2008-11-26T00:08:00Z</published><updated>2008-11-26T00:08:00Z</updated><content type="html">&lt;p&gt;
Yesterday I needed to install Oracle 10g client on my desktop to talk to a 10g server located within a VM. I did something wrong during the installation and needed to re-install (twice in fact!). Once I installed correctly (so I thought), I attempted to connect to the server but was faced with an obscure NLS error. I believe the error was ORA-12705 - invalid or unknown NLS parameter value specified. I could find very little help on the web as to how to fix this problem. There were plenty of articles, I just couldn't find one that fixed MY problem. 
&lt;/p&gt;
&lt;p&gt;
Eventually I stumbled upon a thread that talked about modifying the system's PATH variable to remove the previous install's modifications. I guess when Oracle 10g client is installed it adds to the path something like &amp;quot;c:\oracle\product\10.2.0\client_1&amp;quot;. Subsequent installs just increments the client_2, client_3, etc. Well after my last good install, I was using &amp;quot;c:\oracle\product\10.2.0\client_3&amp;quot; but the path included references to&amp;nbsp;&amp;quot;c:\oracle\product\10.2.0\client_1&amp;quot;and &amp;quot;c:\oracle\product\10.2.0\client_2&amp;quot;. All I had to do was remove the paths to client_1 and client_2 and my problem went away. Hope this helps.
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="https://communities.bentley.com/aggbug?PostID=21810&amp;AppID=29879&amp;AppType=Weblog&amp;ContentType=0" width="1" height="1"&gt;</content><author><name>Keith Bertram </name><uri>https://communities.bentley.com/members/879fb95e_2d00_12bc_2d00_46cf_2d00_a82c_2d00_3862f8b6bf84</uri></author></entry></feed>