Bug? Simply insert statement throws the following error.

55 views
Skip to first unread message

Glyn

unread,
Sep 6, 2012, 10:53:55 AM9/6/12
to ra...@googlegroups.com

Simple insert statement throws the following error.

The error is not making a lot of sense to me. Can someone please point me in the right direction here. I don't thing anything is incorrect with the syntax.


local.queryService = new query();
local.queryService = applyData(arguments.data,local.queryService);
local.queryService.setDatasource("hermesDS");
local.queryService.setName("getQuery");   local.queryService.setSQL("
INSERT INTO redeemed (redeemedID, created, incentiveID, recipientID, codeID, active)
VALUES ('#createUuId()#', '#now()#', :incentiveID, :recipientID,:codeID, '1')
");
local.result = local.queryService.execute();
local.getQuery= local.result.getResult();


Error: PS the number [45] is nothing to do with me and keeps incrementing on every error.

message : The named parameter [45] has not been provided

The named parameter [45] has not been provided at railo.runtime.tag.Throw._doStartTag(Throw.java:142):142 at railo.runtime.tag.Throw.doStartTag(Throw.java:131):131 at throw_cfm$cf.udfCall(C:\railo\lib\railo-server\context\library\function\throw.cfm:11):11 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:215):215 at railo.runtime.type.UDFImpl._call(UDFImpl.java:434):434 at

9: name=&quot;extendedInfo&quot; type=&quot;string&quot; required=&quot;no&quot; hint=&quot;extended information to the exception.&quot;&gt;&lt;cfargument <br> 10: name=&quot;object&quot; type=&quot;any&quot; required=&quot;no&quot; hint=&quot;Throws a Java exception from a CFML tag. This attribute is mutually exclusive with all other argments of this function.&quot;&gt;&lt;!--- <br> <b>11: ---&gt;&lt;cfthrow attributeCollection=&quot;#arguments#&quot;&gt;&lt;!--- </b><br> 12: ---&gt;&lt;/cffunction&gt;<br>



Scott Busche

unread,
Sep 6, 2012, 10:58:44 AM9/6/12
to ra...@googlegroups.com
I'm assuming you're omitting them from the code, but just to be sure, are you setting the values for the params you have? :incentiveID, etc?

local.queryService.addParam( value="blah", cfsqltype="cf_sql_varchar" );

Peter Boughton

unread,
Sep 6, 2012, 10:58:56 AM9/6/12
to ra...@googlegroups.com
Where is the code that is setting the values for incentiveID, recipientID, and codeID ?

Glyn

unread,
Sep 6, 2012, 11:12:44 AM9/6/12
to ra...@googlegroups.com
O thats just a base function i'm testing.


public any function applyData(required struct data,queryService) {
        for(var i in arguments.data) {
       
            if(isSimpleValue(arguments.data[i])) {
                queryService.addParam(name=right(i,len(i) - 2),value=arguments.data[i],cfsqltype="cf_sql_varchar");
            }
        }
        return queryService;
    }

Glyn

unread,
Sep 6, 2012, 11:15:01 AM9/6/12
to ra...@googlegroups.com
even if i take then out I get the same error different number...


INSERT INTO redeemed (redeemedID, created, incentiveID, recipientID, codeID, active)
                VALUES ('#createUuId()#', '#now()#', '1', 'e8a6f1d0-f5bb-11e1-a21f-0800200c9a66','1', '1')

The named parameter [13] has not been provided

Glyn

unread,
Sep 6, 2012, 11:24:00 AM9/6/12
to ra...@googlegroups.com

Adam Cameron

unread,
Sep 6, 2012, 11:28:23 AM9/6/12
to ra...@googlegroups.com
I suspect Railo is seeing part of your now() value as a param, eg:

{ts '2012-09-06 12:34:56.000' } (or whatever the format is)

It's seeing :34 and :56 as params.

I don't have a Railo server here to test, but it's worth checking, perhaps?

And, I hasten to add, both your UUID and your TS should be params of their own, not hard-coded in your SQL.

--
Adam

Glyn

unread,
Sep 6, 2012, 11:33:48 AM9/6/12
to ra...@googlegroups.com
That's interesting,yes that was the issue. I normally let the db do the work for dates.

Adam Cameron

unread,
Sep 6, 2012, 11:38:29 AM9/6/12
to ra...@googlegroups.com
Ha!  Lucky guess.

I s'pose that counts as a wee bug?  I'll have to check what CF does when I get home (and I'll report back with that).

--
Adam

Glyn

unread,
Sep 6, 2012, 11:53:28 AM9/6/12
to ra...@googlegroups.com
that would be really good, let me know. thanks you again.

Adam Cameron

unread,
Sep 6, 2012, 11:57:55 AM9/6/12
to ra...@googlegroups.com
Will do.  "When I get home" will be about +6h from now, and I'm off to the pub to meet a coupla my cousins over from NZ between now and then, so whether I do it tonight depends on how many pints I end up having between now and then.  Said cousins are female, so it might not be a huge session.  But theyr'e from the South Island so... who knows... they might drink me under the table.  Chuckle.

Anyway, I will report back as soon as I get in front of a computer and I don't have a pint glass in my hand, and a road cone on my head.

--
Adam

Peter Boughton

unread,
Sep 6, 2012, 1:01:08 PM9/6/12
to ra...@googlegroups.com
What Adam says does seem likely - it would certainly explain the changing numeric values - and yet colons inside the string are ignored - and there doesn't appear to be anything complicated about the SQL provided to trip that behaviour up.

There were a couple of bugs with named params in script queries with older versions of Railo, but those were fixed some time/versions back, so unless this is on an old version...

Glyn: You haven't mentioned what version you're running here. If it's not the latest stable release, what happens if you upgrade and try again?

Adam Cameron

unread,
Sep 7, 2012, 4:10:31 AM9/7/12
to ra...@googlegroups.com
Yeah, I ended up slightly too much beer last night to contemplate looking into this properly.  But I've done so now.

I've written up my findings here (because it effects ColdFusion as well as Railo): http://adamcameroncoldfusion.blogspot.co.uk/2012/09/not-obvious-bug-in-querycfc.html.

It is definitely a problem with the parameter parsing process in both CF and Railo.

Steps to reproduce:

<cfprocessingdirective pageencoding="UTF-8">
<cfscript>
    q1 = queryNew("");
    queryAddColumn(q1, "id", [1,2,3,4,5,6,7]);
    queryAddColumn(q1, "daysofWeek", ["Rāhina","Rātū","Rāapa","Rāpare","Rāmere","Rāhoroi","Rātapu"]);
    queryAddColumn(q1, "ts", [now(),now(),now(),now(),now(),now(),now()]);

    o = new Query(
        dbtype    = "query",
        sql        = "
            SELECT    *
            FROM    q1
            WHERE    ts = '#now()#'
        "
    );

    o.setAttributes(q1=q1);

    o.execute();
    q2 = o.getResult();

    writeDump(variables);
</cfscript>

I've raised https://issues.jboss.org/browse/RAILO-2059.

Cheers.

--
Adam

Adam Cameron

unread,
Sep 7, 2012, 5:27:15 AM9/7/12
to ra...@googlegroups.com
[Slaps head in despair]

As Igal pointed out on the ticket: doing '#now()#' is not syntactically correct, as the value of now() has embedded single quotes.

There is no bug here.

Sigh.

--
Adam
Reply all
Reply to author
Forward
0 new messages