Oracle: PLS-00103: Encountered the symbol “”

Triggers, triggers and more triggers.
Thousands of them. Ran the scripts into Oracle using ColdFusion instead of SQLPlus only to find out that I now had thousands of invalid triggers.
A little puzzling, as the same scripts worked like a charm everywhere else. I go use the oracle web enterprise manager to see whehter I can recompile them and make a few valid. Nada!
Everytime the Enterrpise manager tries to compile the trigger I get the error:

PLS-00103: Encountered the symbol “”

Here is a sample trigger with issues:

CREATE OR REPLACE TRIGGER INS_MySuperTrigger BEFORE INSERT ON
MySuperTriggerTable REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW
DECLARE
newid NUMBER;
BEGIN
If :new.MySuperTrigger_ID IS NULL THEN
SELECT SEQMySuperTrigger.NextVal INTO newid FROM dual;
:new.MySuperTrigger_ID := newid;
End If;
END;

This is nuts. I use the generate SQL button of Enterprise manager to generate the SQL and copy and paste it into the Oracel SQL Developer UI, run the code without mods, and bingo; the trigger is valid and happy as a peach.

What gives? Long hours wasted with different websites and options, casing, single and double quotes, Egyptian prayer beads…, you name it, I tried it.
Until pulling a protocol sniffer to see what the difference is between Oracle Enterprise Manager and Oracle SQL Developer on the wire.

Come to find out Oracle does not recognize Windows CRLF (Chr(13) + Chr(10)) as blank space, if you replace all the CRLF with LF this works like a charm. Seemingly, web based Oracle Enterprise Manager does not do this translation, while the Oracle SQL Developer tool does. Yack! Lesson learned, I now run the scripts through a parser before running them to Oracle via JDBC and get valid triggers all the time.

Cheers,

MySQL: frustration with login at the command prompt or the space character mystery

Many years ago when trying to use MySQL I ran into this, but only get to note it down now because someone else run into this problem. I searched and lo and behold not much info out there, so I thought maybe a couple of pointers would be worth while.
When using the command line mysql tool you can specify the username and password of the user during login.
Many manuals describe the syntax as:

mysql -h hostname -u root -p password
or
mysql –user=user_name –password=your_password db_name

You think wow this is easy, right. I can interpret this very simply.
I go to the command prompt and type:

C:\>mysql –user=root –pasword=mypass

but to my astonishment I would get:

mysql: unknown variable ‘pasword=mypass’

Here are couple of other beauties that are in the manuals and don’t work at all like expected:

C:\>mysql -u root -p mypass
Enter password: ******
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

This could be very frustrating to someone new to MySQL on windows. Can’t even login to get the client program started.

The approach I found working for windows based installation is to ignore the manual and avoid space between parameters.
Thus rather than using -u root, you will need to use -uroot. This will magically work. E.g.:
C:\>mysql -uroot -pmypass
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 19Server version: 5.0.67-community-nt
MySQL Community Edition (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.
mysql>

Hope this will avoid some frustration out there.
Cheers,

CF: ColdFusion functions and the case of the mysterious space

Spent lots of time trying to find out why a space was returned from a function call to a function in a component. We would place the output directly into a html form text control, but a space would always be added to the front of the expected return string.
Broke out the old Hex editor to save and check file contents. Output each character at a time, just could not see why this would happen.
Many hours later, a headache started to kick in. Time for a break. Then, a hunch started knocking at the back of my scull and got louder and louder.
To prove it to myself, I created an intermediate variable into which I stored the function result. When this scheme was used, no space. If I used the function output in place, space! It turned out to be the Output attribute of the function definition. You will need to set it to ‘No’. If you leave it off and attempt to use the function in place, Coldfusion will introduce a space in the return. Very, very annoying.

Here is sample code to reproduce the problem, two function that are identical except one has the output attribute specified; if you use the function 2 inline CF will produce a space in front of the output; see the output for f2 below:


<cffunction name="fFunction1" output="No">

<cfset var strReturn ="Hello World">
<cfreturn strReturn>
</cffunction>

<cffunction name="fFunction2" >
<cfset var strReturn ="Hello World">
<cfreturn strReturn>
</cffunction>

<cfset sOutput1=fFunction1()>
<cfset sOutput2=fFunction2()>

<cfoutput>
f1:--#fFunction1()#--
<BR>
o1:--#sOutput1#--
<BR>
f2:--#fFunction2()#--
<BR>
o2:--#sOutput2#--
<BR>
</cfoutput>

Output:

f1:--Hello World--
o1:--Hello World--
f2:-- Hello World--
o2:--Hello World--

CF: ColdFusion Impact of Content Type Declaration on the HTTP header with application/octet-stream

So, I encountered this little problem with XML transmissions for a customer. They would receive regular XML streams to update their data and all was working dandy, until one it didn’t ;o)
To CF it looked like all of a sudden the content of the HTTP traffic vanished, in other words we did not seem to have anything in GetHttpRequestData().content except for empty string.
Of course, no one fessed up to having changed anything at all, so here I go digging through code and cannot find anything obvious and, then, I turn out the big guns: Protocol Sniffers and packet capture.
Hah, I think, now I can show them that they are not sending any content, but instead I can see the content clearly in the packet capture which starts heavy head scratching and coffee sipping.
More looking into code and I find that the only time we bypass GetHttpRequestData().content is if we are running a binary check, e.g. we have this condition:
IsBinary(GetHttpRequestData().content)
From the protocol packets I can clearly see that the content is not binary so, at first, I cannot imagine how this condition would be even trigger and bypass the remainder of the processing until, seing the light, I remove the condition.
Bingo, now I can see content but it is all wrong. It looks like CF has processed the content of the transmission to numeric values instead of XML strings.
Dang!
So in the end, more digging to see that the http content type declaration of the originating transmission had changed from text/xml to application/octet-stream; it looks like whenever CF received this it automatically converted the perfectly fine XML into an octet stream, which, then, turned the content to be binary data instead of leaving it as simple string. A simple misdeclaration by the customer which caused this hoopla.
So after much searching I wish I could have been able to tell the RAW data in the transmission from the interpreted data. This would have made the diagnosis much simpler. So Adobe, in the future please consider adding the raw information to the GetHttpRequestData function, so we don’t have to guess what parts are being interpreted and what the transmission contained.
For now, I went back to the customer and asked them to correct their content declaration.

CF: Coldfusion and the perennial rounding bug

Through the years using any function that did implicit rounding in CF was not the safest thing to do. Many times when I thought this was resolved it came back with a vengeance to bite me in the you-know-what.
Thus, the safe route to use is to go through the database to round anything, unless you really do not have any choice.
This time it was the LSCurrencyFormat function which caused the headaches. It will round down at the .5 fraction rather than round up which is very annoying and disturbing at the same time. Here is a function specifically made for currency handling and it does not handle the basic calculations correctly.

Example code (comparing the round behavior against LSCurrency):

<cfloop from="0.001" to="0.009" step="0.001" index="fraction">

<cfset Amount = 1.10 + fraction>
<cfoutput>
number: #Amount# ls: #LSCurrencyFormat(Amount,'none')#
compare to rounded #Round(Amount *100)/100#
<BR>
</cfoutput>

</cfloop>

Unfortunately, I had flip back all the use of LSCurrencyFormat and pre-round the numbers via the database before passing them to this function. I do hope that Adobe does a little more testing on rounding for these in the future.

CF: How to detect nested transactions within cftransaction

Sometimes it cannot be helped. You are expanding ColdFusion code and have to implement transactions. You have to, then, use components that cannot be changed, that, in turn, may have to do transactions. Now the problem, ColdFusion does not like nested transactions. Nested transactions are simply not supported.

Well, at least if I could detect whether I am in a transaction I could write around this I think. But there is no way that I have found. No clear posting on how to do this.

First approach I used was to create a function that would open and close a transaction, then detect the error thrown. If the error was thrown I was assuming that we were in a transaction and thus could not open a new one, a fuction like this:


<CFSET var blnReturn = false>
<CFTRY>
<CFTRANSACTION>
<!--- emptry transaction tag --->

</CFTRANSACTION>
<CFCATCH type="Any">
<CFSET blnReturn=true>
</CFCATCH>

</CFTRY>
<CFRETURN blnReturn>

Unfortunatly, this does not work. When CF throws an error for nesting, even within the try/catch block for the purposfully nested transaction, the transaction wrapper is removed. Thus you are hosed if an error occurs later down the execution.

What to do then?

After much researching and failure, here is the approach I did find working. The trouble with this is, that there is no guarantee that it will work in future versions of CF, which I hope will introduce a simple function like InTransaction() . We are using the ColdFusion Java implementation of the Transaction Tag to find out whether we have a current transaction. This is the fully wrapped function.


<CFFUNCTION name="InTransaction" access="public" displayname="checks to see whether we are currently running a database transaction. returns true or false." output="No" RETURNTYPE="boolean">
<CFSET var objTrans ="">
<CFSET var blnActiveTransaction=false>
<CFSET var objCurrentTrans="">
<!--- Call to CF implementation of TransactionTag to expose Java functions --->
<cfobject type="Java" class="coldfusion.tagext.sql.TransactionTag" name="objTrans" action="create">
<!--- objCurrentTrans will become undefined if the Java function call getCurrent() returns Null,
otherwise this returns a pointer to current transaction instance --->

<cfset objCurrentTrans = objTrans.getCurrent()>
<cfif IsDefined("objCurrentTrans")>
<CFSET blnActiveTransaction=true>
</cfif>
<!--- return result --->
<CFRETURN blnActiveTransaction>
</CFFUNCTION>

This works in ColdFusion 8 and 7.

Cheers.

CF: Silent Server Side Debugging

So you get this call. Customer says “Nothing is working”; you cannot replicate. When you go to your application or site everything is working just fine.
Have you been there? I have many a time. Wouldn’t it be great to have had the debug output (classic coldfusion format) when the customer ran this?
Well you can. You can change the way coldfusion does the debugging in a fairly straight forward fashion, i.e. you can capture all debug information and save it to files for later analysis by changing the debug handler.
You do this like so:

1.) Download the sample file (ToFile.zip).
2.) Extract and place the file (ToFile.cfm) in your debug handlers directory [cfusion root]\wwwroot\WEB-INF\debug. If you installed ColdFusion in C:\CfusionMX8 this would be the final directory to place the file in: C:\CfusionMX8\wwwroot\WEB-INF\debug
3.) Log in to ColdFusion Administrator and navigate to Debugging & Logging:Debug Output Settings
4.) Change the “ Select Debugging Output Format” drop down to “ToFile.cfm

For each page that you are generating a debug file, the time needed as well as the file name to which the debug information was saved will be displayed at the bottom of the screen.
You have the option to specify a variable in URL, Form, or Variables scope.
Specify a variable named: “DebugSilent” to suppress the bottom text altogether.

Be careful though how long you keep this on as it will generate many files that need to cleared out.

-Bilal

Using Richt Text TextArea results in error (java.lang.Double cannot be cast to java.lang.String)

Well you guessed correctly from the title. There is something odd going on.
If we are passing on variables that are typed as numeric to an argument (height and width) that would conceivable accept numeric values we will get this error:

java.lang.Double cannot be cast to java.lang.String

Here is sample code to reproduce this:

<cfset iHeight=Val(200)>
<cfset iWidth=Val(500)>

<cfform name=”myForm” method=”POST” action=”Self.cfm”>

<cftextarea richtext=”true”
toolbar=”Basic”
name=”MyRTField”
height=”#iHeight#”
width=”#iWidth#” value=””>
</cftextarea>

</cfform>

This could easily occur when passing values as returns from functions. I found two ways of avoiding this.
a) specifically declare variables as strings

<cfset iHeight=”200″>
<cfset iWidth=”500″>

b) introduce space when passing arguments so as to force an implicit conversion


height=” #iHeight# “
width=” #iWidth# “

Micromarketing – Web 2.0+ and the evolution of human to machine marketing

It all started with search engines. People built sites and wanted other people to find them. This was a submission game. If I submit my site to X engines, it would increase traffic by n. This type of site registration work was done mostly by generalists maybe using special submission software to make this repetitive task easier.
However, as search engines became smarter, this stopped working well. Besides, the few surviving search engines where exploring the mechanisms on how to make more revenue and would for that reason alone want to control the results more actively.
Thus, a change happened in marketing. Even before this happened I did make a bold prediction that we would have this new aspect of marketing appear. The human to machine specialist. Marketing before this was mostly an affair of humans trying to convince other humans to do things or spend money on things and services they presumably did not think to be needing otherwise.
The common incarnation of the human to machine marketer was the search engine specialist. Now, here was a marketer blissfully unconcerned about any human audience, rather focusing his energies on how to influence a system (search engine), which in turn would yield the outcome (higher search results). Whole companies specialized in this and are still today providing these services to others.
Banner companies appeared, and a sophisticated system of banner advertising that was content sensitive appeared. Things evolved and no one in their right mind wanted to click on banners any longer. Google ads was begotten and as most things Google, it drowned everything else out. Google rules the masses with Add text banners.
Now, we have this Web 2.0 happening and some of the paradigms with sites and submissions went out the door. So, then, you may ask, what with this web 2.0 stuff happening, whatever that is, will happen to the human to machine people? Will this have any impact on how marketing will evolve? Of course, thanks for the lead in …. If I were free to opine (which I am) I am going to make a prediction. Marketing will change once more to adopt to the next level of message delivery. Machine to machine marketing, or more specifically machine to machine Micromarketing, will emerge.
Sure, obvious you say; maybe so, but let me explain my particular take on this. Imagine a web application in new web 2.0 style, highly interactive, highly social (high stickiness). Maybe you and your buddies are watching a bike race unfold online. As you are looking at the leader riding his Schwinn bike to victory, in the background systems (machines) are negotiating advertising rates with Schwinn based on this event, i.e. sports (special section bike related), audience (your buddies, target group size, average incomes and ages, etc.); Schwinn’s systems may have to bid automatically against a competitor (automated market rate auctions) to gain the rights to transparently overlay a marketing message on the race as the race unfolds. This happens several times, as leaders change position, new Marketing messages are negotiated. This is target advertising driven to a next level, highly personalized, informative, automatic, integrated. Wow! You are right, there is no escape now, we will be truly slaves to our passions and exploited for our whims ;o)
However, we are not there yet. There is a lot of work needed to create this next level of reality for marketing. Infrastructure and systems and protocols are just a few things.

  • Negotiation protocol for marketing events. Probably something on top of WS standards, containing event information, exposure times, audiences, bid information.
  • Advertising systems that can recognize types of events and are policy driven (executing against a pre-defined marketing strategy) to react to 1000s+ add requests per second.
  • Micro-payment system: The ability needs to exist to pay for impressions or executions (clicks, seconds of videos watched, games played, names captured); maybe a quarter cent per incidence.

Of course, some of this could be outsourced to specialist, which will then program your policies in their systems on your behalf. Maybe this could be the next Doubleclick service. Just say I didn’t tell you so.

Why the iPod must die

First of, I admit that I have owned an iPod. I owned it very briefly and did admire the attention that Apple has given to designing a well rounded MP3 player. However, I gave it away very quickly. I owned several other MP3 players before and after the iPod. The MP3 player that I am currently using is made by Samsung; and the main reason I bought it for was the radio tuner, followed by size and ease of use. Which overall brings me to the topic at hand, the future of the MP3 players in general and iPod in particular.
The reasons that I did not keep my original iPod and also gave away multiple iPods that I received as promotional gifts and purchase bonus are very simple on one side but point out some of the issues that will, of course only in my humble opinion, doom its existence.
To start with iTunes rubs me the wrong way. As a more technical person than the usual user, I did not like how iTunes took over my computer (with little to no choice), was consuming resources precariously and would not allow me to transfer tunes to anything else but iPod.
I went on to discover something else about myself while dealing with the iPod (and other MP3) players. You could call it a journey of self discovery of sorts. Though the idea of downloading and assembling your own tunes seems pretty cool at first, the stark truth is, it is a LOT OF WORK.
I did a completely statistically irrelevant survey to confirm my suspicions, I asked 7 people about their approach to iPod music management; astonishingly enough they did the same thing. Once they had loaded their favorite tunes, they made very few changes to their music play lists or downloaded music, ripped their CDs etc. Of course there are plenty of people who enjoy doing these things, they just don’t seem to be in the majority.
This must probably go under the more “dah” moments in live. We all relish the choice, but are not willing to put in the effort. Thus, I like the other people in my survey realized that this downloading and song organizing part of the iPod does not work for us as the maker intended.
Thus, I am looking for the next wave of devices that truly promises to me the notion of complete choice by giving up any choice whatsoever. Counterintuitive you may say,”hah!” but not truly so I retort. I am thinking here of interactive, internet based radio available 24/7 with or without commercials, where I can pick a genre/type of music I feel like listening to, then I am able to make my preference known within the type by either fast forwarding or ranking the tunes. The new interactive radio station would learn my strange music ways and be able to quickly become adapt at knowing what to play to me, even be able to play medleys, cross music boundaries and present new bands/songs/artists to me.
No more iTunes, no more needing to download anything, if I like a song I can ask for more frequent replay. I pay or not pay (via commercials) professionals to go out there and find the stuff I like. A serving of Indy… here you go, newest Pop/Rock, right away Sir…
Now is this the stuff of far away future? Was I too quick to write the obituary of such an ingenuous device? I, of course, do not think so. The companies at the best position to deliver this are the companies that already sell us our daily other gadgets, such as the wireless carriers. They have realized this potential and working on services and devices that are nudging us ever closer towards this music nirvana. Unfortunately, they have only one way track thinking, e.g. make money directly on subscription services. Leaving out tremendous potential for ad dollars, cross marketing of goods (how about being able to buy tickets for a band you just heard that will be performing in your area. The carrier would know where you are located, they would know you just rated the song highly, bingo! you are ripe for the plucking.). I don’t want to mention merchandising, but I think I just have. In other words there is potential beyond subscription for revenue.
I also see potential for our friends from satellite Radio; they have the content, but they need to get off the bandwagon that radio is one directional. The radio of the future is interactive. Their gadgets need to be improved and maybe a free service would be available for people that do not want to do subscription, but would be willing to get commercials or merchandising messages etc. Wow, this could be cool.
Apple is no dummy either. I believe, they have foreseen the death of the iPod already ;o) and I am convinced they are working diligently on the next best thing. What could this be? How could they capitalize on the trends I am predicting (crystal ball and all). iPhone is a start of course, but they just now get to a device that has sufficient bandwidth to access high quality music streams. What’s the other way? Keep the best part of the iPod alive indefinetly and ensure it can get licensed easily and it gets into as many places as possible (Unfortunately licensing is not one of Apple’s strengths). What am I talking about? The iPod’s connection interface of course. Your radio clock has it, your car has it, your zip pocket in your pants will have it before you know it. It should become more ubiquitous than plain m&m’s that don’t melt in your hand. Thus, there could be a way in which the iPod could live on forever, however, its days as the music player of choice are numbered.