Query of queries disallows SQL right() function
We're attempting to do a query of queries using the SQL
right() function like this:
select *
from getresults
where right([key],charindex('\',reverse([key]),1)-1) not in
(#quotedvaluelist(getexcluded.file_name)#)
We've even replaced that where clause with a much more simple
where right([key])='m'
just to make sure that it wasn't the nesting functions that
were causing the problem.
In either case, we get the error:
Query of Queries syntax error.
Encountered "right" at line 0, column 0. Incorrect
conditional expression,
Expected one of [like|null|between|in|comparison] condition,
What SQL functions are disallowed from query of queries?
Thanks,
Kris
Nasty stuff huh. Just happened to discover myself today that
Left doesn't work. I'd suspect that Aggregate functions are the
ONLY ones that will work. It would have been nice if they'd at
least allowed CF vs DB functions in their own "database" language.
BTW, also discovered that Count() returns Null rather than 0
when there aren't any per your WHERE clause.
Similar Messages
-
Problem using DECODE() function with a Query of Queries
I
posted
on my blog about an issue I was having trying to use the PL/SQL
DECODE() function with a Coldfusion Query of Queries. This function
works fine when you query a database for information. However, when
you query another query, it seems that CF doesn't recognize it. I
got errors stating that it found a left parenthesis where it
expected a FROM key word. Here is a simplified version of what I am
trying to do:
quote:
<!--- Simulated query; similar to what I was calling from
my database --->
<cfscript>
qOriginal = queryNew("Name,Email,CountryCode",
"VarChar,VarChar,VarChar");
newRow = queryAddRow(qOriginal, 5);
querySetCell(qOriginal, "Name", "Joe", 1);
querySetCell(qOriginal, "Email", "[email protected]", 1);
querySetCell(qOriginal, "CountryCode", "AMER", 1);
querySetCell(qOriginal, "Name", "Sally", 2);
querySetCell(qOriginal, "Email", "[email protected]", 2);
querySetCell(qOriginal, "CountryCode", "AMER", 2);
querySetCell(qOriginal, "Name", "Bob", 3);
querySetCell(qOriginal, "Email", "[email protected]", 3);
querySetCell(qOriginal, "CountryCode", "ASIA", 3);
querySetCell(qOriginal, "Name", "Mary", 4);
querySetCell(qOriginal, "Email", "[email protected]", 4);
querySetCell(qOriginal, "CountryCode", "EURO", 4);
querySetCell(qOriginal, "Name", "John", 5);
querySetCell(qOriginal, "Email", "[email protected]", 5);
querySetCell(qOriginal, "CountryCode", "EURO", 5);
</cfscript>
<cfquery name="qCountries" dbtype="query">
SELECT DISTINCT(CountryCode) AS CountryCode,
DECODE(states, "AMER", "North America & Canada",
"EURO", "Europe & Africa", "ASIA", "Japan &
Asia","") CountryName
FROM qOriginal
ORDER BY CountryCode
</cfquery>
<cfdump var="#qCountries#">
<!--- ========== END OF CODE ========== --->
So running this returned the following error:
Query Of Queries syntax error.
Encountered "(. Incorrect Select Statement, Expecting a
'FROM', but encountered '(' instead, A select statement should have
a 'FROM' construct.
Does anybody know why this doesn't work? Is it just not
supported? Please note that I have also tried to use the CASE()
function instead of DECODE() and that resulted in basically the
same error. For now I an looping over my distinct query with a
switch statement and manually loading a new query with the data how
I want it. But it would be a lot cleaner and less code to have the
DECODE() to work. Thx!DECODE() is an Oracle function, not generic SQL. Q-of-Q is a
very limited subset of SQL and lacks many functions and clauses
available in standard SQL, especially what you may be used to using
in your particular RDBMS.
See
Query
of Queries user guide
Phil -
I'm attempting to dynamically generate a rather large SQL query via the "PL/SQL function body returning SQL query" report region option. The SQL query generated will possibly be over 32K. When I execute my page, I sometimes receive the "ORA-06502: PL/SQL: numeric or value error" which points to a larger than 32K query that was generated. I've seen other posts in the forum related to this dynamic SQL size limitation issue, but they are older (pre-2010) and point to the 32K limit of the DNS (EXECUTE IMMEDIATE) and DBMS_SQL. I found this post (dynamic sql enhancements in 11g) which discusses 11g no longer having the 32K size limitation for generating dynamic SQL. Our environment is on 11gR2 and using ApEx 4.2.1. I do not know which dynamic SQL method -- DNS or DBMS_SQL -- ApEx 4.2.1 is using. Can someone clarify for me which dynamic SQL method ApEx uses to implement the "PL/SQL function body returning SQL query" option?
As a test, I created a page on apex.oracle.com with a report region with the following source:
declare
l_stub varchar2(25) := 'select * from sys.dual ';
l_sql clob := l_stub || 'union all ';
br number(3) := 33;
begin
while length ( l_sql ) < 34000 loop
l_sql := l_sql || l_stub || 'union all ';
end loop;
l_sql := l_sql || l_stub;
for i in 1 .. ceil ( length ( l_sql ) / br ) loop
dbms_output.put_line ( dbms_lob.substr ( l_sql, br, ( ( i - 1 ) * br ) + 1 ) );
end loop;
return l_sql;
end;
The dbms_output section is there to be able to run this code in SQL*Plus and confirm the size of the SQL is indeed larger than 32K. When running this in SQL*Plus, the procedure is successful and produces a proper SQL statement which can be executed. When I put this into the report region on apex.oracle.com, I get the ORA-06502 error.
I can certainly implement a work-around for my issue by creating a 'Before Header' process on the page which populates an ApEx collection with the data I am returning and then the report can simply select from the collection, but according to documentation, the above 32K limitation should be resolved in 11g. Thoughts?
Shane.What setting do you use in your report properties - especially in Type and in Region Source?
If you have Type="SQL Query", then you should have a SELECT statement in the Region Source. Something like: SELECT .... FROM ... WHERE
According to the ERR-1101 error message, you have probably set Type to "SQL Query (PL/SQL function body returning SQL query)". In this situation APEX expects you to write a body of a PL/SQL function, that will generate the text of a SQL query that APEX should run. So it can be something like:
declare
mycond varchar2(4000);
begin
if :P1_REPORT_SEARCH is not null THEN
mycond:='WHERE LAST_NAME like :P1_REPORT_SEARCH ||''%''';
end if;
return 'select EMPLOYEE_ID, FIRST_NAME, LAST_NAME from EMPLOYEES ' ||mycond;
end;
And for escaping - are you interested in escaping the LIKE wildcards, or the quotes?
For escaping the wildcards in LIKE function so that when the user enters % you will find a record with % and not all functions, look into the SQL Reference:
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm
(You would than need to change the code of your function accordingly).
If you are interested in escaping the quotes, try to avoid concatenating the values entered by the user into the SQL. If you can, use bind variables instead - as I have in my example above. If you start concatenating the values into the text of SQL, you are open to SQLInjection - user can enter anything, even things that will break your SQL. If you really need to allow users to choose the operator, I would probably give them a separate combo for operators and a textfield for values, than you could check if the operator is one of the allowed ones and create the condition accordingly - and than still use bind variable for inserting the filtering value into the query. -
Working with Custom SQL Using Descriptor Query Manager Queries
Hi All,
I am Working on Descriptor Query Manager Queries
Configuring Custom SQL Using Java and Workbench
Using Java I wrote a static method as in the code given below.
public static void insertEmployee(ClassDescriptor descriptor){
descriptor.getQueryManager().setInsertSQLString(
"insert into EMPLOYEE (EMP_ID, EMP_NAME, EMP_JOB, SAL, DEPTNO) values (#EMP_ID, #EMP_NAME, #EMP_JOB, #SAL, #DEPTNO)"
I wrote a insert SQL Query in the custom SQL tab of the Toplink workbench .
Using java and Using Toplink Workbench I had a problem how to call this insert query in the sessionEJBBean .
Can any one suggest me in this regard.
Thanks in advance
regards,
SatishWhat is the problem you are experiencing?
Normally you can just execute the query by calling
'executeQuery(queryName, domainclass) on the session.
See also
http://www.oracle.com/technology/products/ias/toplink/
doc/10131/main/_html/qrybas003.htm#BCFIBGGJ
Just out of curiosity: why do you need a custom SQL
to insert something? Can't you use persist()?
regards,
LonnekeOr even UnitOfWork ? Why go down the route of using custom inserts to insert objects unless you have some business logic that Toplink's UnitOfWork API cannot provide ? -
Save layout of queries in SQL Developer query builder?
Sometimes queries are very complex and moving tables around in the graphical view is really helpfull to better understand them.
Unfortunately this layout does not get saved with "save" (because this is a simple text file).
Once upon there was a query builder (included with designer 2000 and later vom 1991 to 1998) that had a proprietary format (.brw) to just do that: Save a query including layout.
Any chance to save the layout of SQL Developer query builder queries?I dont think there is any way to save the layout for the query, you can request an enhancement on the Exchange for this http://sqldeveloper.oracle.com/
But if you only need to restore the query you are working with later, or move it to another workstation and continue editing using the query builder, you only need the SQL code generated; when you paste it in an opened worksheet (on the same database or even a clone with the same structure) the query builder is able to resume working just fine with default positioning for the table objects.
If you hand edit the query and insert some SQL manually then the query builder may stop working for particularly complex statements, in this case it will warn you and disable itself. -
Use evdre to query data from a SQL View
Hi all
I believe that it is possible to use evdre to query data from a SQL View. If this is possible then how does one go about setting it up in the evdre options (assuming that the view has already been created)?
Regards,
ByronByron, perhaps this is no longer supported, it might be worth opening up a case at service.sap.com on this. However, I did find the following on Page 11 of the "Usages and Considerations of EVDRE" pdf file. This doc is imbedded in the helpfile for BPC 7 SP5 (which was released in August of 2009, well after note 1315011 was last updated.
It looks like you are limited to one custom view per application, since you have to name the view in a parameter at the APPLICATION level. Go into BPC Administration, login to the application related to the custom view, choose "Set Application Parameters" and enter the name of the view to the Application Parameter called "EVDRE_QUERYVIEWNAME" If it is not listed, go ahead and create it at the bottom of the Application parameter screen.
Also: I interpreted the following info from Page 10 of the same doc:
In your EVDRE, set the following options:
QueryEngine: MANUAL
QueryType: enter either NEXJ OR TUPLE see below:
NEXJ - Use two-dimensional queries using the nonemptycrossjoin function
TUPLE - Use two-dimensional queries using tuples"
And I'm assuming you'd enter a Y for the following two parameters:
QueryViewName
"..to enforce the query engine to use a used-defined SQL view of the fact tables, when trying to read the values using SQL queries. This option is typically used in conjunction with the SQLOnly option (see below). "
Option SQLOnly
"..to enforce the query engine to only execute SQL queries, when reading data. This can be achieved using this option." -
Over the past several weeks we've been experiencing periodic
hangs of the ColdFusion service. We finally invested in SeeFusion
and found the problem, but aren't sure how to fix it
The code that hangs is a query of queries block. Basically we
are getting a result set from verity (~1000 rows), then getting a
result set from SQL server (~3000 rows), and joining the two with
the query of query statement. Everything will run fine for a few
hours, then that block of code will bog down. When I dumped the
threads during the error, everything gets hung like so:
"jrpp-255" runnable
at
coldfusion.sql.imq.rttExpr.guesstimateJavaType(rttExpr.java:439)
at
coldfusion.sql.imq.rttExpr.guesstimateJavaType(rttExpr.java:371)
at
coldfusion.sql.imq.imqTable.guessColumnType(imqTable.java:443)
at
coldfusion.sql.QueryTableMetaData.InferMetaDataTypes(QueryTableMetaData.java:350)
at coldfusion.sql.imq.TableList.validate(TableList.java:166)
at
coldfusion.sql.imq.rttSelectExprSpec.validate(rttSelectExprSpec.java:498)
at
coldfusion.sql.imq.rttSelectStmt.validate(rttSelectStmt.java:84)
at
coldfusion.sql.imq.jdbcStatement.fetchResult(jdbcStatement.java:538)
at
coldfusion.sql.imq.jdbcStatement.execute(jdbcStatement.java:131)
at coldfusion.sql.Executive.executeQuery(Executive.java:775)
at coldfusion.sql.SqlImpl.execute(SqlImpl.java:240)
at
coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:500)
at
cfauctionManagement2ecfc978963305$funcJOINAUCTIONSTOVERITY.runFunction(D:\inetpub\wwwroot \CustomTags\mysite\component\auctionManagement.cfc:137)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344)
at
coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
at
coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:290)
at
coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:254)
at
coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56)
at
coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:366)
at
coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:198)
at
coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:157)
at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:1594)
at
coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:341)
at
cfact_search_auctions2ecfm1040202400._factor47(D:\inetpub\wwwroot\CustomTags\mysite\actio n\act_search_auctions.cfm:849)
at
cfact_search_auctions2ecfm1040202400.runPage(D:\inetpub\wwwroot\CustomTags\mysite\action\ act_search_auctions.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at
coldfusion.filter.CFVariablesScopeFilter.invoke(CFVariablesScopeFilter.java:63)
at
coldfusion.tagext.lang.ModuleTag.doStartTag(ModuleTag.java:255)
at
coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:1925)
at
cfindex2ecfm1952396859.runPage(D:\inetpub\wwwroot\mysite\cfml\auctions\index.cfm:18)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at
coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
at
cflas2dvegas2dtimeshares2ecfm1477369516.runPage(D:\inetpub\wwwroot\mysite\cfml\las-vegas- timeshares.cfm:1)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
at
coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
at
coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
...etc
I believe this means CF is trying to "guesstimate" the java
type of each column in the result set. We tried to work around that
by CASTing each column as a varchar, but we still have the same
issue.
If anyone has an idea what the problem could be, we'd really
appreciate any help. Also, if anyone can suggest a way to merge the
two result sets without using SQL, that would be great too. I've
already tried nested loops to manually build the final result set,
but that was taking up to 5 seconds to run.
Environment:
CFMX 7.0.2
Win2K
SQL Server 2K> We need more information than that to display a record,
so we select
> everything out of the database (which is fairly quick),
then JOIN that to the
> verity results (WHERE auctionID = KEY).
Right. And what do you need THOUSANDS of matches for, in one
hit, here?
And what do you need ALL those columns for, when dealing with
all these
thousands of rows. You've not really answered my question as
to "what's
the end result here?" What are you trying to achieve? I don't
mean what
you're doing to aggregate the data, but simply *why*? What is
the
requirement you have here to be engaging in this enterprise
in the first
place? Search screen? Stock control report? What?
Is there any way of optimising how much processing you're
doing?
If - say - you're doing a search results screen, you probably
don't need
1000s of results: you probably need 20. So just ask the DB
for 20: WHERE
id IN (#list of 20 IDs from Verity search results#)
If the user goes "NEXT >>", then grab the next 20
(cache the Verity query
somehow, rather than re-query it).
Obviously there's some heavy-lifting processing that might
need to process
the whole lot. Can this not be done in a sliding window of
results? Or
could you not pass the list of IDs from the Verity resultset
into the DB
somehow, and do the filtering on the DB engine, rather than
with CF (which
is not very good at bulk data processing, as you're seeing.
It's not what
it's designed for).
I find QoQ to be very flaky for all ut the most basic
operations. For
basic stuff it's fine. It does not surprise me that it seems
to leak
memory (or whatever it's doing) and eventually give up the
ghost. This
does not help you, I realise, but as a suggested practice:
don't expect too
much out of QoQ. Try some other method instead.
Adam -
Improve built in SQL MAX function
Hi
I am trying to improve the performance of the built in SQL max function. right now searching through over 500,000 rows takes lot of time which can be reduced. Can anyone suggest me something which would be helpful in this or may be give me a link if it has been discussed before?
Anything is appreciated.
ThanksTolls wrote:
Um...considering you were planning on improving on the MAX function, I sort of thought you might actually know how to use it. Otherwise how would you know it was running slowly?thanks Tolls i'd figured it out right after i posted it. i guess i was too excited after reading (you got it in milliseconds) that posted right away without doing anything myself..but yeah it did make it super fast..thanks a lot for your help and time..
cotton.m wrote:
d_khakh wrote:
hi tolls thanks for getting back
could u explain how did u do that? i found out how to create index..i have the following statement:
create index col on table2 (col2);
cud u tell me how to go from here and find the max in col2..thanks again for ur help?
sigh
Where to go from here? Just execute your damn query. If you really did create the index on the right column and your database isn't stupid and there isn't a lot more to this problem then you told us about like some where clauses then that's it. She's as fast as she's going to get.
And remember, it's impolite to converse in a public forum while chewing your cud. Unless of course you actually meant "could" but were just too lazy to type it. Don't be lazy, use full words. Thanks.like i said above..i figured it out after some time.
i wasn't being lazy ..thats msn talk..i thought people understood that..anyways your point noted too. -
Query of queries date comparison
Cut to the basics, I'm trying to run the following code:
<cfset qData = QueryNew("dataDate,ID")>
<cfset padDate = "#DateFormat(Now(),"dd mmm yy")#
23:59">
<cfset queryAddRow(qData)>
<cfset QuerySetCell(qData,"ID",1)>
<cfset QuerySetCell(qData,"dataDate",padDate)>
<cfset delDate = "#DateFormat(Now(),"dd mmm yy")#
00:00">
<cfquery name="qZero" dbtype="query">
SELECT ID
FROM qData
WHERE dataDate = '#delDate#'
</cfquery>
This works fine in MX7 but I need to put it on a server using
MX6.1. It appears that in 6.1 query of queries considers the
dataDate field to be a date but will not accept a date on the right
hand side of the equals sign in the where clause so comes up with
'Unsupported type comparison'. Is there any way round this?I just ran into this problem actually.
What appears to be happening is QoQ has trouble comparing SQL
date types and DB date types. I had to perform an lsdateformat on
the data to get it to process.
I am also looking into a problem where QoQ is switching my
dates to strings. CF has yet to impress me. For every kind of cool
thing they do there are 25 lame things. -
How to Passing clob to PL/SQL pipeline function
I have a PL/SQL stored function which takes clob as input parameter and sends the results in a pipe line.
create or replace function GetIds(p_list clob, p_del varchar2 := ',') return ideset_t pipelined is
I am using ojdbc14.jar (Oracle 10g driver) with oracle 9i (9.2.0.1.0).
I want to use the following SQL Query select * from table(GetIds(clob))
Now the question is how can I pass the clob from JDBC?
Here is my client code
PreparedStatement stmt = con.prepareStatement("SELECT COLUMN_VALUE FROM TABLE(GETIDS(?, ','))");
stmt.setCharacterStream(1, new StringReader(str), str.length());
stmt.executeQuery();
I get the following error when I try to run the program. The same thing works fine if the chracter lenght is less than some chaaracters.
java.sql.SQLException: ORA-01460: unimplemented or unreasonable conversion requested
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:420)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:896)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:452)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:986)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:2888)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:2960)
at Test.main(Test.java:42)
Exception in thread "main"
The setChracterStream works for any insert/update clob. Example when I tried the query (INSERT INTO CLOB_TEST VALUES(?)) setCharacterStream just works fine.
Please any one can help me how to solve this.
Thanks in advance.Hóla LuÃs,
when you pick the PL/SQL function body returning a boolean, it implicitly means that TRUE means OK, while FALSE means error, always.
In order to associate such error to a given form field, you have to go back to the page definiton / validations and specify the name of the item in the corresponding field.
When you first create the validation rule, this value is not present even if you ask for the error message inline with the field.
The error message text can be specified in the validation definition, if I am not wrong.
When you need to return special error messages, including dynamic content for instance, you can use the Function Returning Error Message type, which reports an error when the string returned by the function is not null. This comes in handy when you want to display an item's code, for example, rather than generic text.
Even in this case, you must go back to the validation and specify the name of the field if you want to see it inline.
Hope it helps,
Flavio -
Can't find answer to Query Of Queries runtime error
Not only I browsed this forum but also googled this problem but unfortunnately I have no luck in finding the answer.
All I did was writing this simple query:
<cfquery name="test" dbtype="query">
select SSN,BirthDate from myquery where SSN <> '' OR BirthDate <> ''
</cfquery>
and I got this error:
Query Of Queries runtime error.
Comparison exception while executing <>.
Unsupported Type Comparison Exception: The <> operator does not support comparison between the following types:
Left hand side expression type = "DOUBLE".
Right hand side expression type = "STRING".
I tried the following and did not work either, still got the same error.
<cfquery name="test" dbtype="query">
select SSN,BirthDate from myquery
where SSN <> <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value=""/>
OR BirthDate <> <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value=""/></cfquery>
Has someone ever encountered the same problem and know how to solve it?HELP ! ! ! Going into testing soon. I need this to work to get correct report results ! ! ! !
My issue seems similar to the one under discussion and the reply from lawhite01 caught my eye. Can you roll my issue into this discussion?
This is a 2 parter. The second part is the QoQ part, but the 1st part has a line in the query that is similar to the QoQ one and it uses the same data. Part 1 also throws an error.
PART # 1.
I'm trying to use a query table created through QueryNew and then query it.
I need multiple columns in the query table I create:
<cfscript>
tot_AllCurrentDraftListing = QueryNew("AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS, JP_KW_1, JP_JobTitle, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaName, JP_AreaID, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_sal_low1, JP_sal_high1, JP_Grade2, JP_sal_low2, JP_sal_high2, JP_Grade3, JP_sal_low3, JP_sal_high3, JP_Grade4, JP_sal_low4, JP_sal_high4, JP_Grade5, JP_sal_low5, JP_sal_high5, JP_Posted, JP_TypeHire, JP_HRemail");
</cfscript>
Then I populate all the cells of the query table.
Then I set up to use the created query table.
I do this first:
<cfquery name="qAltPostID" datasource="#at_datasource#">
SELECT AltPoster, fk_Job_AnnounceNum
from JOB_JPContacts
Where AltJPContactType = 'AltPosterID'
and AltPoster = '#session.IHSUID#'
</cfquery>
Then, in my first query using the created query, I expect to need to choose from multiple values, so I'm using this line in the query (this is NOT a QoQ query):
and AnnounceNum IN (<cfqueryparam cfsqltype="CF_SQL_varchar" value="#ValueList(qAltPostID.fk_Job_AnnounceNum)#">)
I've also tried:
and AnnounceNum IN (#ValueList(qAltPostID.fk_Job_AnnounceNum)#)
and:
and JOB_AnnounceNum IN
SELECT fk_Job_AnnounceNum
from JOB_JPContacts
Where AltJPContactType = 'AltPosterID'
and AltPoster = '#session.IHSUID#'
ERROR is: one record should return. I get 0.
PART # 2: Here's the QoQ part.
I get the error:
Query Of Queries runtime error.
Comparison exception while executing IN.
Unsupported Type Comparison Exception: The IN operator does not support comparison between the following types:
Left hand side expression type = "LONG".
Right hand side expression type = "STRING".
A tutorial I found gave an example using only one column for this part of the fix:
tot_AllCurrentDraftListing = QueryNew("AnnounceNum", "CF_SQL_VARCHAR")
How would I set up the query with the datatype when I'm using multiple columns:
<cfscript>
tot_AllCurrentDraftListing = QueryNew("AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS, JP_KW_1, JP_JobTitle, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaName, JP_AreaID, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_sal_low1, JP_sal_high1, JP_Grade2, JP_sal_low2, JP_sal_high2, JP_Grade3, JP_sal_low3, JP_sal_high3, JP_Grade4, JP_sal_low4, JP_sal_high4, JP_Grade5, JP_sal_low5, JP_sal_high5, JP_Posted, JP_TypeHire, JP_HRemail");
</cfscript>
I used this code after all the cells contained values and before running my QoQ query:
<cfloop index="intID" from="1" to="#tot_AllCurrentDraftListing.recordcount#" step="1">
<cfset tot_AllCurrentDraftListing["AnnounceNum"] [intID] = JavaCast("string", intID) />
</cfloop>
Is that correct?
Thanks.
Whoever can help me with this should be awarded extra points ! ! ! ! -
Combining results with a Query of Queries - NOT QUITE THERE!!!
I have included a small sample of my database, specifically the four tables I am trying to work with in the hopes that someone can steer me down the right path. Here are the four tables and the bottom is a visual desciption of what I am trying to achieve;
ORDERS
SALES CALLS
ID
SaleDate
TerritoryManager
UserID
SaleDate
TerritoryManager
ID
UserID
426
01-Oct-09
Mike B
10112
10/1/2009
Mike B
253
10112
427
01-Oct-09
Russ C
10115
10/1/2009
Mike B
254
10112
430
01-Oct-09
Jerry W
10145
10/1/2009
Mike B
255
10112
432
01-Oct-09
Ron H
10118
10/1/2009
Mike B
256
10112
433
01-Oct-09
Ron H
10118
10/1/2009
Ron H
257
10118
10/1/2009
Ron H
258
10118
PRODUCTS ORDERED
10/1/2009
Ron H
260
10118
OrderID
Quantity
NewExisting
UserID
10/1/2009
Russ C
261
10115
426
12
0
10112
10/1/2009
Mike B
267
10112
427
2
0
10115
10/1/2009
Mike B
268
10112
427
3
1
10115
430
1
0
10145
USERS
430
1
0
10145
TerritoryManager
Zone
UserID
432
1
0
10118
Mike B
Central
10112
432
1
0
10118
Russ C
Central
10115
432
1
1
10118
Jerry W
Central
10145
432
1
1
10118
Ron H
Central
10118
433
2
1
10120
Don M
Central
10120
Central Zone
Ttl Calls
Ttl Orders
Ttl Items
Ttl New Items
Mike B
5
1
12
1
Russ C
1
1
5
Jerry W
1
2
Ron H
3
2
6
3
I have tried to achieve this result in many ways to no avail. If I try to combine PRODUCTS ORDERED with ORDERS I get an erroneous count. I finally resigned myself to getting all the info I needed with separate queries and then trying to combine them with a query of queries. This worked fine until the last query of queries which timed out with no results. I am a newbie and would appreciate any constructive help with this. I am including my queries below as well;
<cfquery name="qGetOrders" datasource="manna_premier">
SELECT Count(Orders.ID) AS CountOfID,
Orders.UserID AS Orders_UserID,
Users.UserID AS Users_UserID,
Users.TMName
FROM Users INNER JOIN Orders ON Users.[UserID] = Orders.[UserID]
GROUP BY Orders.UserID, Users.UserID, Users.TMName;
</cfquery>
<cfquery name="qGetSalesCalls" datasource="manna_premier">
SELECT Count(Sales_Calls.ID) AS CountOfID,
Users.UserID AS Users_UserID,
Users.TMName,
Sales_Calls.UserID AS Sales_Calls_UserID
FROM Users INNER JOIN Sales_Calls ON Users.[UserID] = Sales_Calls.[UserID]
GROUP BY Sales_Calls.UserID, Users.UserID, Users.TMName;
</cfquery>
<cfquery name="qGetProducts" datasource="manna_premier">
SELECT Count(ProductOrders.OrderID) AS CountOfOrderID,
Sum(ProductOrders.Quantity) AS SumOfQuantity,
Sum(ProductOrders.NewExisting) AS SumOfNewExisting,
ProductOrders.UserID
FROM Orders INNER JOIN ProductOrders ON Orders.[ID] = ProductOrders.[OrderID]
GROUP BY ProductOrders.UserID;
</cfquery>
<cfquery name="qqCombOrd_Prod" dbtype="query">
SELECT *
FROM qGetOrders, qGetProducts
</cfquery>
<cfquery name="qqCombOrd_ProdtoSales" dbtype="query">
SELECT *
FROM qqCombOrd_Prod, qGetSalesCalls
</cfquery>
PLEASE HELP!!! I'm about to go scouting for bridges to leap from!You might be able to simplify that query by getting rid of the subqueries. Something like this
SELECT TerritoryManager
, count(sc.userid) totalcalls
, sum(po.quantity) total
, sum(newexisting) totalnew
, count(o.userid) totalorders
from users u join salescalls sc on u.userid = sc.userid
join orders o on u.userid = o.userid
join productorders po on u.userid = po.userid
where userzone = 'CENTRAL' -
A strange query of queries bug in CF11?
Hi,
I have this strange query of queries result that could be a bug in CF11. The result is fine in CF10.
Basically, I have 2 queries, qrA and qrB. I do a join of the two in joinQr, after which I do a query of qrA. Since I didn't alter qrA in any way, I would expect newQrA to give me the same result as qrA. However it only gives me one row ("D"). Now, here's the strange thing: If I start off qrA with the letters in ascending order ["A", "B", "C", "D"], then newQrA gives me the right result.
<cfset qrA = queryNew("")>
<cfset queryAddColumn( qrA, "size", "varchar", [ "D", "A", "B", "C" ] )>
<cfset qrB = queryNew("")>
<cfset queryAddColumn( qrB, "size", "varchar", [ "A" ] )>
<cfset queryAddColumn( qrB, "quantity", "integer", [ 0 ] )>
<cfquery name="joinQr" dbtype="query">
select qrA.*, qrB.quantity
from qrA, qrB
where qrA.size = qrB.size
</cfquery>
<cfquery name="newQrA" dbtype="query">
select *
from qrA
</cfquery>
<cfdump var="#qrA#">
<cfdump var="#qrB#">
<cfdump var="#joinQr#">
<cfdump var="#newQrA#">For your interest, by coincidence, my first test was with
<cfset queryAddColumn( qrA, "size", "varchar", [ "A","B","C","D" ] )>
It turns out that the order "A","B","C","D" works, whereas "D","A","B","C" fails. Quite funny, really. -
I am getting this error :The right function requires 2 argument(s).
declare
@startdate datetime,
@enddate datetime
SET @STARTDATE ='01-MAR-2014'
SET @enddate = '01-MAR-2014'
Set @StartDate = Convert(datetime, Convert(char(10), @StartDate, 120) + ' 00:00:00', 120)
set @enddate =convert(datetime,Convert(char(10),@enddate, 120) + ' 23:59:59',120)
SELECT
[row_date]
,[logid]
,CONVERT(VARCHAR(6), (ISNULL(SUM([acwouttime] + [auxouttime] + [holdtime]), 0))/3600) +
':' + RIGHT('0' + CONVERT(varchar(2),(ISNULL(SUM([acwouttime] + [auxouttime] + [holdtime]), 0)) % 3600) / 60), 2)
+ ':' + RIGHT('0' + CONVERT(varchar(2), (ISNULL(SUM([acwouttime] + [auxouttime] + [holdtime]), 0)) % 60), 2)AS HoldTime
FROM [CMSData].[dbo].[hagent2]
WHERE ([logid] IN (1382, 1493,1382,1493,1444,1466,1301,1074,1655,
1749,1685,1686,1684,1617,1681,1792,1595,1597,1687,1622))
AND (row_date BETWEEN @StartDate AND @EndDate)
GROUP BY
[row_date]
,[logid]
hi friends when I am executing this query I am getting this error please help me I will grateful to you .
ERROR: The right function requires 2 argument(s).you may be better off making date filter as below
declare
@startdate datetime,
@enddate datetime
SET @STARTDATE ='01-MAR-2014'
SET @enddate = '02-MAR-2014'
AND (row_date >= @StartDate AND row_date <@EndDate)
see
http://visakhm.blogspot.in/2012/12/different-ways-to-implement-date-range.html
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Reusing query results in PL/SQL
I have a procedure in a package that I want to query several times using the analytical function row_number to get, say, the 5th row and the 95th row:
select days_missed_negative_is_late
into l_5pct
from (select days_missed_negative_is_late,
row_number() over(order by days_missed_negative_is_late asc) rn
from (*some complicated query*)
order by days_missed_negative_is_late))
where rn = 5;
then I do the whole thing again, except the last line reads "rn=95". This seems inefficient. I would like to build the results one time then query it twice:
select days_missed_negative_is_late
into l_5pct
from something
where rn = 5;
select days_missed_negative_is_late
into l_5pct
from something
where rn = 95;
or the equivalent functionality, of course. Again, this is in a PL/SQL package. Any ideas of the best way to build the results and read them several times?Here is an example.
1 select object_name from
2 (select object_name,row_number() over(order by created) rn
3 from all_objects
4 where rownum<101)
5* where rn in(5,95)
SQL> /
OBJECT_NAME
I_CON2
DEPENDENCY$
You could for example 1) use a cursor and loop or
2) select and bulk collect.
I hope this helps.
Maybe you are looking for
-
Hi,. I have a InfoPath 2010 form which was published to SharePoint 2010. I migrated the content db to SQL Server 2012 and I have converted the Sharepoint 2010 (windows based) to the SharePoint 2013 claims based site. I have not fully upgraded the si
-
Our software uses Adobe Reader to print PDF files, via a Java application that runs an exec command to invoke AcroRd32.exe. This has been working fine for years without problems, however recently one of our client sites upgraded all their Windows mac
-
STILL Not Able to Stop Search Suggestions
This is a follow-up to an earlier question I asked, viz. [https://support.mozilla.org/en-US/questions/928773 Stop Search Suggestions in the Awesome Bar]. The solution presented in that question worked for a while, but now the ugly problem has returne
-
DNS server configuration on solaris 10
Please, can somebody give me the way, step by step to configure a DNS server on solaris 10. i want to have the directories and files that it is necessary to modify and the modification to have a domain name "deptech.lan" with ip adress of the DNS ser
-
What is the use of XSLT..... I want to ask if the tree of the xml file has changed( such as remove a node from the tree), and then use the transformer to display the changed tree ......... does it mean that we don't need to rewrite the xml file to sa