From: lovely raj12 on
I have taken the cfdump for tmpqry and it shows all data for the range ( No
error at this step ) . But when we exceute this dbquery we get below
mentioned error .

<cfquery name="qry" dbtype="query" >
SELECT *
FROM tmpqry
ORDER BY #colSort# ASC
</cfquery>

senerio:

I am using createobject to create a reference for component and call
MDArraySort function in the cfc and getting this error .

'The system has attempted to use an undefined value, which usually indicates a
programming error, either in your code or some system code.

Null pointer is undefined.... '

i am using this code in a cfc file.

<cffunction name="MDArraySort" Returntype="query" access="public" >
<cfargument name="colArray" type="array" required="true">
<cfargument name="colNames" type="string" required="true">
<cfargument name="colSort" type="string" required="true">
<cfargument name="sensorIDs" type="string" required="true">

<cfscript>
var tmpqry = Querynew(colNames);
var qRow = QueryAddRow(tmpqry, Arraylen(colArray) );
</cfscript>

<cfloop from="1" to="#Arraylen(colArray)#" index="qRowIndex">

<cfscript>

sIndexinSensorIDs = colArray[qRowIndex]["SENSOR"]&"##";
Temp_readin_code = colArray[qRowIndex]["READING_CODE"]&"##";

QuerySetCell(tmpqry, 'SENSOR', sIndexinSensorIDs, qRowIndex);
QuerySetCell(tmpqry, 'TYPE',javacast('String',colArray[qRowIndex]["TYPE"]),
qRowIndex);
QuerySetCell(tmpqry, 'TIMESTAMP2',
LSParseDateTime(colArray[qRowIndex]["TIMESTAMP2"]), qRowIndex);
QuerySetCell(tmpqry,
'ORDER_BY_PARAM',javacast('String',colArray[qRowIndex]["ORDER_BY_PARAM"]),
qRowIndex);
QuerySetCell(tmpqry, 'READING_CODE',Temp_readin_code , qRowIndex);
QuerySetCell(tmpqry,
'READING',javacast('String',colArray[qRowIndex]["READING"]), qRowIndex);
QuerySetCell(tmpqry,
'PK_READING',javacast('String',colArray[qRowIndex]["PK_READING"]), qRowIndex);
QuerySetCell(tmpqry,
'ALARM_STATUS',javacast('String',colArray[qRowIndex]["ALARM_STATUS"]),
qRowIndex);
QuerySetCell(tmpqry, 'DURATION',
javacast('String',colArray[qRowIndex]["DURATION"]), qRowIndex);
QuerySetCell(tmpqry,
'DESCRIPTION',javacast('String',colArray[qRowIndex]["DESCRIPTION"]), qRowIndex);

</cfscript>
</cfloop>

<cfquery name="qry" dbtype="query" >
SELECT *
FROM tmpqry
ORDER BY #colSort# ASC
</cfquery>

<cfreturn qry >

</cffunction>

It is working fine for some date range and and getting above mentioned error
in sone situation .


From: BKBK on
[i]It is working fine for some date range and and getting above mentioned error
in sone situation .[/i]

The return object [i]qry[/i] is perhaps undefined for certain date ranges. If
so, then a possible workaround is to include the following line within the
cfscript block at the top:

var qry = queryNew(colNames);



From: Dan Bracuk on
I think your problem is this line.
ORDER BY #colSort# ASC

because you didn't scope your variable.
From: BKBK on
Dan Bracuk wrote:
[i]... you didn't scope your variable. [/i]

The arguments scope isn't compulsory.

Adam Cameron wrote:
[i]Are there any nulls in this column? [/i]

From what I can see, colSort is user input.




From: lovely raj12 on
Thanks for reply ...

No NULL value i get when i am taking dump of tempqry . I am taking sort order on Timestamp values .

Hoping for reply asap .