Problem with select query that includes a date
I've been fighting with this for about 4 hours - yes, quite literally... I've never been good with date stuff. I have a brain block.
Anyway, here's the situation:
I have an Access database that has a time/date field. There are no times, just a date in mm/dd/yyyy format.
That table is a list of classes held for the past three years. I want to make a query that only shows the classes that have ended after January 1 of this year. I don't want to put 01/01/2010 in the query itself because I want it to still work next year.
This is the current query:
<cfquery name="classes" datasource="#DSN#" dbtype="ODBC">
SELECT classesTitles.ClassTitle, classesTitles.ClassDesc, classCatagories.catagoryName, classes.classStart, classes.classEnd, classes.classNotes, owners.fName, owners.lName, classTime.timeSlot, classes.classID, classes.classLimit
FROM classCatagories INNER JOIN (((classes INNER JOIN classesTitles ON classes.classTitle = classesTitles.classTitleID) INNER JOIN classTime ON classes.classTime = classTime.timeID) INNER JOIN owners ON classes.classInstructor = owners.ownerID) ON classCatagories.catagoryID = classesTitles.ClassType
WHERE classes.classEnd < 01/01/#DatePart("yyyy", now())#
ORDER BY classes.classStart, classCatagories.catagoryName, classTime.timeSlot, classesTitles.ClassTitle
</cfquery>
I don't get any results, but I should get a list of every class that has an end date before January 1 of this year - about 200 records.
When I swap around the where clause to:
<cfquery name="classes" datasource="#DSN#" dbtype="ODBC">
SELECT classesTitles.ClassTitle, classesTitles.ClassDesc, classCatagories.catagoryName, classes.classStart, classes.classEnd, classes.classNotes, owners.fName, owners.lName, classTime.timeSlot, classes.classID, classes.classLimit
FROM classCatagories INNER JOIN (((classes INNER JOIN classesTitles ON classes.classTitle = classesTitles.classTitleID) INNER JOIN classTime ON classes.classTime = classTime.timeID) INNER JOIN owners ON classes.classInstructor = owners.ownerID) ON classCatagories.catagoryID = classesTitles.ClassType
WHERE classes.classEnd > 01/01/#DatePart("yyyy", now())#
ORDER BY classes.classStart, classCatagories.catagoryName, classTime.timeSlot, classesTitles.ClassTitle
</cfquery>
I get EVERY class in the database, and I should only be getting about 50
The classes are about 8 weeks long, the begin date and end date are in the database as date/time fields, so I need to show everything that ended in 2010, regardless of when it started.
I'm sure it's something glaringly obvious, but it's escaping me.
THANKS
Michelle
The format of your date field in access is irrelevent to the situation at hand. Use proper date objects instead of trying to build a suitable string. For the first of January of the current year, the coldfusion functions createdate(), year(), and now() are your freinds. Then, in case Adam's post was not clear, use cfqueryparam with the resulting variable.
Similar Messages
-
Problem with select query in search
Hi,
Here i am using MYSQL database and when i am insertind date to database it is saving like '2009-11-10 00:00:00' and when i used to dispaly this in dateformat as '11/10/2009' .
here is the problem occurs , when i write a search query as
select recruitername,interviewdate ,skillset
from details
where interviewdate = #form.interviewdate#
i am getting problem with date . would u please help me how to solve this issue .Try to use DateFormat
select recruitername,interviewdate ,skillset
from details
where interviewdate = #DateFormat(form.interviewdate, "yyyy-dd-mm")# -
Problem with select query inside a function.
Hi,
i have created a function as
create or replace function "NEW"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
select sum(allocation_percent) into v_alo from employeeproject where start_date < s_date and end_date > e_date and pid != 'BPDE-KER12' and employee_id = emp;
select allocation_percent into v_alo2 from employeeproject where start_date < s_date and end_date > e_date and pid = 'BPDE-KER12' and employee_id = emp;
select max(end_date) into v_date from employeeproject where employee_id=emp having max(end_date) <= S_DATE;
if v_alo < 100 then
return 1;
else if v_alo2 = 100 then
return 2;
else if v_date < s_date then
return 3;
else
return 4;
end if;
end if;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;it is compiled correctly.
when executing the function with
select abc.a,new(a,'03-jan-2011','04-jan-2011') "status" from abc where new(a,'03-jan-2011','04-jan-2011') in (1,2,3,4);it is returning
A status
1 5
2 5
3 5
instead of
A status
1 1
2 2
3 3
and when i comment any two select statements then some part of my ans is correct.
unable to understand the behaviour.
can any pls help me understand it.
Thanks,
hariHi,
thanks for the reply, and sorry for my ugly code.
i am using Oracle database 10g express edition.
Case could be a option to use but i need to figure why my query is not returning any value when used together.
my requirement is to find
the employees who are have allocation percent sum < 100 for a defined period(excluding pid=BPDE-KER12) and
employee who is mapped to pid=BPDE-KER12 not in my first requirement in that period and
the employees whose latest end date is less than the new start date.
i have tried the new modified code as you said but this time it returns null, not even exceptions running.
i divide my requirement into three functions which will return value.
1. create or replace function "NEW4"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
--to check if the employee total percentage is <100 then return 1 else return 4
select sum(allocation_percent) into v_alo from pm_employee_project
where
start_date < s_date and end_date > e_date and pid !='BPDE-KER12' and employee_id = emp;
if v_alo < 100 then
return 1;
elsif v_alo2 = 100 then
return 2;
elsif v_date < s_date then
return 3;
else
return 4;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;
then,
select abc.a,NEW4(a,'03-jan-2011','30-jan-2011') "STATUS" from abc
result,
A STATUS
1 *1*
2 4
3 4 2.create or replace function "NEW5"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
--To select employee who are in a specific pid.
select allocation_percent into v_alo2 from pm_employee_project where
start_date < s_date and end_date > e_date and pid = 'BPDE-KER12' and
employee_id = emp;
if v_alo2 = 100 then
return 2;
elsif v_alo < 100 then
return 1;
elsif v_date < s_date then
return 3;
else
return 4;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;
then,
select abc.a,NEW5(a,'03-jan-2011','30-jan-2011') "STATUS" from abc
Result,
A STATUS
1 5
2 *2*
3 5 3. create or replace function "NEW6"
(emp in number,
s_date in DATE,
e_date in DATE)
return number
is
v_alo number default 0;
v_alo2 number default 0;
v_date date;
begin
--to select the employee whose project end date is less thann the new date.
select max(end_date) into v_date from pm_employee_project where
employee_id=emp having max(end_date) <= S_DATE;
if v_alo2 = 100 then
return 2;
elsif v_alo = 100 then
return 1;
elsif v_date < s_date then
return 3;
else
return 4;
end if;
exception
when NO_DATA_FOUND then
return 5;
end;
then,
select abc.a,NEW6(a,'03-jan-2011','30-jan-2011') "STATUS" from abc
Result,
A STATUS
1 5
2 5
3 *3* so my function works properly individually, but i want all the three conditions in a single function with same order as above 1 then 2 and then 3.
and when i try to do it that way i am not getting my result as
A STATUS
1 *1*
2 *2*
3 *3*
so how can i proceed.
my input table values,
select * from abc
A B C
1 2 2
2 1 3
3 1 2
select * from pm_employee_project
varchar2 varchar2 date date date varchar2
EMPLOYEE_ID PID START_DATE END_DATE ALLOCATION_PERCENT SUPERVISOR_ID
1 10 02-JAN-11 31-JAN-11 89 -
1 20 05-JAN-11 20-JAN-11 9 -
1 BPDE-KER12 21-JAN-11 31-JAN-11 11 -
2 BPDE-KER12 01-JAN-11 31-JAN-11 100 -
3 30 01-JAN-10 01-JAN-11 100 -
Hi All,
i_dfkkko-xblnr
IF NOT i_dfkkko[] IS INITIAL .
SELECT opbel
belnr
FROM erchc
INTO TABLE i_erchc1
FOR ALL ENTRIES IN i_dfkkko
WHERE opbel EQ i_dfkkko-xblnr.
ENDIF.
I am using the above select query.problem is when i put the value
of i_dfkkko-xblnr by going to the table erchc i am getting the record.But this qury is not resulting any value.
i have checked in debug mode copied the value of xblnr of i_dfkkko
and went to erchc table and passed to opbel of erchc i got the reords.
can anybody pls help..
Rgds,
SaiHi,
The database would be having the value with leading zeroes.
Use FM "CONVERSION_EXIT_ALPHA_INPUT" to conver the values & then pass to select query.
_dfkkko-xblnr
IF NOT i_dfkkko[] IS INITIAL .
loop at i_dfkkko.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
VALUE(INPUT) = i_dfkkko-xblnr
IMPORITNG
VALUE(OUTPUT) = i_dfkkko-xblnr.
modify i_dfkkko.
endloop.
SELECT opbel
belnr
FROM erchc
INTO TABLE i_erchc1
FOR ALL ENTRIES IN i_dfkkko
WHERE opbel EQ i_dfkkko-xblnr.
ENDIF. -
So, I work on a legacy CF web site and there are numerous SELECT * FROM USERS_TABLE queries all over the site.
Well, we changed the structure of said table in the database on our Testing and Staging sites, with no issues.
When we pushed up to our production environment and changed the structure of the production DB table, the server kept kicking back "Value can not be converted to requested type."
After doing some searching out there, it looks like CF caches the structure of the table, and you either have to restart CF to clear it, or rename and then name-back the DSN to fix the issue.
http://www.bennadel.com/blog/194-ColdFusion-Query-Error-Value-Can-Not-Be-Converted-To-Requ ested-Type.htm
That said, this doesn't happen in our testing and staging environments - so what would be the difference?
Is there some setting I need to change in the CF Admin to keep this from happening again?Also, if you can use a Stored Procedure to retrieve the data, do so. Standard queries gets all the information, anyway, chokes bandwidth passing it all to the CF server, and forces the CF server to filter, sort, and format the data. SPs tell the db server to get ONLY the data requested, and forces the db server to filter and sort the data, leaving only formatting to the CF server.
That's not true. The only time CF messes with data returned from the DB is if there's a maxrows attribute, and the record set returnded from the DB has more than that number of records... which causes CF to truncate the recordset to the correct size before returning it. The DB might or might not stop sending rows down to CF after CF says "yeah, I've got all I want now".
Other than that, for all intents and purposes all CF does with the SQL is pass it to the DB and wait for an answer. The only thing it does to the returned data is to create a CF record set ("query") with it... this does not involve any filtering and sorting.
Adam -
Problem with Select query fetching records.
Hi All,
SELECT bukrs belnr gjahr bldat cpudt aedat cputm usnam xblnr bktxt waers
FROM bkpf INTO TABLE bkpf_tbl
WHERE bukrs IN s_bukrs AND blart IN ('RE' , 'ZL')
AND ( ( cpudt > prv_date )
OR ( cpudt = prv_date AND cputm >= prv_time ) )
OR ( ( aedat > prv_date )
OR ( aedat = prv_date AND cputm >= prv_time ) )
AND gjahr IN s_gjahr
AND monat IN s_monat
AND belnr IN s_belnr
My prv_date is 05/04/2010 while debugging.
CPUDT (Accounting Document Entry Date) in BKPF doesnu2019t have any entries.
But AEDAT (Date of the Last Document Change by Transaction) is having a single entry on date 05/04/2010.
While this query is showing number of records around 200000. I feel something is wrong with the AND/OR statements.
Please suggest some ideas?Hi Mishra,
I dont know the excaly wht u r passing in the prv_date and cpudt . But one thing i notice that blart part.
SELECT bukrs belnr gjahr bldat cpudt aedat cputm usnam xblnr bktxt waers
FROM bkpf INTO TABLE bkpf_tbl
WHERE bukrs IN s_bukrs AND blart eq 'RE' or blart eq 'ZL'
AND ( ( cpudt > prv_date )
OR ( cpudt = prv_date AND cputm >= prv_time ) )
OR ( ( aedat > prv_date )
OR ( aedat = prv_date AND cputm >= prv_time ) )
AND gjahr IN s_gjahr
AND monat IN s_monat
AND belnr IN s_belnr.
With Regards,
Sumodh.P -
Problem with select query (results cant b displayed)
SELECT url,SUM(data_received) xyz FROM logs GROUP BY url ORDER BY xyz desc
when i triedthe above query in the worksheet it works fine but when i write same query in code i get this error.
myjsp page has this code.
<%while (rset.next())
out.println("<tr>");
out.println("<td>" +
rset.getString(1) + "</td><td>" +
rset.getInt(2) + "</td><td> " +
"</td>");
out.println("<tr>");
%>
This is the error
500 Internal Server Error
java.sql.SQLException: Invalid column name at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240) at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:3201) at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1880) at oracle.jdbc.driver.ScrollableResultSet.findColumn(ScrollableResultSet.java:1308) at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1618) at list_action._jspService(_list__action.java:67) [list_action.jsp] at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.0.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:60) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:416) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:119) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230) at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)
please helpit is better to use into table ....itab.
dont go for joins if u r joining four tables .......
it is better to for all entries.
SELECT aauart awerks akdauf akdpos
bftrmi baufnr bstlbez baufpl
blead_aufnr bprodnet
FROM aufk AS a
INNER JOIN afko AS b
ON baufnr EQ aaufnr
INTO TABLE i_data1
WHERE a~auart IN s_auart
AND a~kdauf IN s_vbeln
AND a~werks EQ p_werks
AND b~aufnr IN s_aufnr
AND b~ftrmi IN s_ftrmi.
if i_data1[] is not initial .
if any sorting criteria is required based on primary keys write the sort statement here.
select crueck crmzhl
cvornr carbid clmnga cxmnga
crmnga cism04 cism05 cbudat
d~kunnr
e~arbpl
FROM afru AS c inner join vbak AS d
ON caufnr EQ aaufnr innerjoin crhd AS e
like this u need to do...........................
u have joined around five tables ...definetly that wont work
endif. -
Problem with select query when it returns a NULL value
Hi all,
I have a d/b table called QMEL and i picked VBELN from that table. Now if the VBELN value in that table is NULL i have to wtite an if condition.
Can i say it like this
IF VBELN = ' '.
write: enter into the if condition.
ELSE.
write: enter into the else condition.
ENDIF.
or should is say some thing else? my objective is ..i should execute some statments if VBELN has no value and i should execute some othet statements if VBELN has a value.
Kindly help..as even though i put above condition..it deosnot work
Regards,
Jessica Samhi
check this
if u r using selection optins use this code
IF NOT s_material[] IS INITIAL.
SELECT material
FROM marc
INTO l_material
WHERE material IN s_material.
ENDSELECT.
IF sy-subrc NE 0 AND l_material IS INITIAL.
MESSAGE e302 WITH space.
ENDIF.
ENDIF.
if u r using parameter then
IF NOT P_material IS INITIAL.
SELECT material
FROM marc
INTO l_material
WHERE material EQ P_material.
ENDSELECT.
IF sy-subrc NE 0 AND l_material IS INITIAL.
MESSAGE e302 WITH space.
ENDIF.
ENDIF.
~linganna
Edited by: katigiri linganna on Apr 8, 2009 5:58 AM -
Problem with select query:help
SELECT url,SUM(data_received) xyz FROM logs GROUP BY url ORDER BY xyz desc
when i triedthe above query in the worksheet it works fine but when i write same query in code i get this error.
myjsp page has this code.
<%while (rset.next())
out.println("<tr>");
out.println("<td>" +
rset.getString(1) + "</td><td>" +
rset.getInt(2) + "</td><td> " +
"</td>");
out.println("<tr>");
%>
This is the error
500 Internal Server Error
java.sql.SQLException: Invalid column name at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240) at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:3201) at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1880) at oracle.jdbc.driver.ScrollableResultSet.findColumn(ScrollableResultSet.java:1308) at oracle.jdbc.driver.OracleResultSet.getInt(OracleResultSet.java:1618) at list_action._jspService(_list__action.java:67) [list_action.jsp] at com.orionserver[Oracle Containers for J2EE 10g (10.1.3.0.0) ].http.OrionHttpJspPage.service(OrionHttpJspPage.java:60) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:416) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:478) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:401) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:719) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:376) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:870) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:451) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:218) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:119) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:230) at oracle.oc4j.network.ServerSocketAcceptHandler.access$800(ServerSocketAcceptHandler.java:33) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:831) at com.evermind[Oracle Containers for J2EE 10g (10.1.3.0.0) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595)
please helpThis is not the proper forum....
Post this thread to
Java Server Pages (JSP)
Greetings...
Sim -
Problem with a query with a BLOB data type
Hi i've a problem with this query in 11g. R1
SELECT
LOGTIMESTAMP,
LOGTIMEMILLIS,
MSGID,
XMLTYPE(MESSAGEBODY, nls_charset_id('AL32UTF8')).getClobVal() as LLamada
FROM
vordel.AUDIT_MESSAGE_PAYLOAD,
vordel.AUDIT_LOG_POINTS
WHERE
AUDIT_LOG_POINTS.LOGPOINTSPK = AUDIT_MESSAGE_PAYLOAD.MP_LOGPOINTSPK AND
LOGTIMESTAMP between TO_TIMESTAMP('03-12-2011 00:00','DD-MM-YYYY HH24:MI') and TO_TIMESTAMP('03-12-2011 12:00','DD-MM-YYYY HH24:MI')
and filtertype = 'LogMessagePayloadFilter'
and filtername like 'Log Llamada%'MESSAGEBODY: data type of the Column is BLOB
throw this error after execute the query
Error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00200: could not convert from encoding UTF-8 to UCS2
Error at line 1
ORA-06512: at "SYS.XMLTYPE", line 283
ORA-06512: at line 1Could you check the BLOB really contains UTF-8 encoded XML?
What's your database character set?The BLOB contains UTF-8 Encoded
and the database where i am connectes have AL32UTF8 character set, but my internal instance have "AMERICAN_AMERICA.WE8ISO8859P1"
that is a problem?
How could I change the character set of the oracle local client to the character set of the remote oracle data base? -
1. How to create an explain plan with rowsource statistics for a complex query that include multiple table joins ?
When multiple tables are involved , and the actual number of rows returned is more than what the explain plan tells. How can I find out what change is needed in the stat plan ?
2. Does rowsource statistics gives some kind of understanding of Extended stats ?You can get Row Source Statistics only *after* the SQL has been executed. An Explain Plan midway cannot give you row source statistics.
To get row source statistics either set STATISTICS_LEVEL='ALL' in the session that executes theSQL OR use the Hint "gather_plan_statistics" in the SQL being executed.
Then use dbms_xplan.display_cursor
Hemant K Chitale -
Problem with "SELECT...FOR UPDATE OF..." and "POST command" combination
Problem in committing transactions in Multiple Forms (Oracle Forms) with POST built-in command:
Consider that the following statements are written in WHEN-WINDOW-CLOSED trigger of a called form.
Statements in called form (Form name: FORM_CHILD):
go_block('display_block') ;
do_key('execute_query') ;
-- Data from table_b will be populated in this block, based on the value of COLUMN_1 obtained
-- from TABLE_A.
-- Example: If the value of COLUMN_1 is 10, then all the matching records from TABLE_B, which
-- are inserted with value 10 in TABLE_B.COLUMN_1 will be fetched and shown here.
if user_choice = 'YES' then
commit ;
else
rollback ;
end if ;
Statements in calling forms:
There are two calling forms having following statements and it is going to call the above said called form.
CALLING FORM 1
Statements in KEY-COMMIT trigger:
post;
call_form(form_child, no_activate) ;
Statements in ON-INSERT trigger:
select column_1
from table_a
for update of column_1
where column_2 = 'X' ;
update table_a
set column_1 = column_1 + 1
where column_2 = 'X' ;
insert into table_b ...;
insert into table_b ...; Statements in KEY-COMMIT trigger:
post;
call_form(form_child, no_activate) ;
CALLING FORM 2:
Statements in ON-INSERT trigger:
select column_1
from table_a
for update of column_1
where column_2 = 'X' ;
update table_a
set column_1 = column_1 + 1
where column_2 = 'X' ;
insert into table_b ...;
insert into table_b ...;
insert into table_b ...;
Our understanding:
Assume that both the forms are running from two different machines/instances, issuing commit at the same time. In this case, forms will start executing the statements written in ON-INSERT trigger, the moment POST command is executed. Though the commit is issued at the same time, according to oracle, only one of the request will be taken for processing first. Assume that calling form 1 is getting processed first.
So, it fetches the value available in COLUMN_1 of TABLE_A and locks the row from further select, update, etc. as SELECT...FOR UPDATE command is used (note that NOWAIT is not given, hence the lock will be released only when COMMIT or ROLLBACK happens) and proceed executing further INSERT statements. Because of the lock provided by the SELECT...FOR UPDATE command, the statements in calling form 2 will wait for the resource.
After executing the INSERT statements, the FORM_CHILD is called. The rows inserted in to TABLE_A will be queried and shown. The database changes will be committed when user closes the window (as COMMIT is issued in its WHEN-WINDOW-CLOSED trigger). Then the SELECT...FOR UPDATE lock will be released and calling form 2's statements will be executed.
Actual happenings or Mis-behavior:
Calling form 2 starts executing INSERT statements instead of waiting for SELECT...FOR UPDATE lock. Also, the value selected from TABLE_A.COLUMN_1 is same in both the calling forms, which is wrong.
The rows inserted into TABLE_B are having similar COLUMN_1 values in calling form 2 and they are fetched and shown in the called form FORM_CHILD.
Note that in calling form 2 also POST only is issued, but the changes posted there are accessible in calling form 1 also, which is wrong.
Kindly suggest us as to how to fix above problem. It will be much use, if you can send us the information regarding the behavior of Oracle Forms POST built-in also.
Our mail ID: [email protected]
Thanks a lot in advance.You have several problems:
1. On-Insert will ONLY run if you have created a new record in a base-table block. If you haven't done that, then the POST command will not cause it to run.
2. Select for update without a "no wait" will lock records for the first form, but when the second form tries this, it will hit the ORA-00054 exception, and will NOT wait. The only way you could make it wait is to issue an UPDATE sql command, which is not such a good way to go.
All POST does is issues SQL insert or update commands for any changes the user has made to records in a form's base-table blocks, without following with a Commit command.
Also understand that Commit is the same as Commit_Form, and Rollback is the same as Clear_Form. You should read up on these in the Forms help topics. -
Hi,
I have a problem with af:query. Here's what I do:
1. create a VO, define view criteria
2. drag and drop view criteria from data controls to an empty form, choosing query and table
3. When I run the page and click any of the buttons, I get: "Because of inactivity, your session has timed out and is no longer active...."
I see no exceptions in output window. What am I doing wrong?
Here is my view defenition:
<?xml version="1.0" encoding="windows-1250" ?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<!---->
<ViewObject
xmlns="http://xmlns.oracle.com/bc4j"
Name="EmployeesView"
Version="11.1.1.49.49"
SelectList="Employees.EMPLOYEE_ID,
Employees.FIRST_NAME,
Employees.LAST_NAME,
Employees.EMAIL,
Employees.PHONE_NUMBER,
Employees.HIRE_DATE,
Employees.JOB_ID,
Employees.SALARY,
Employees.COMMISSION_PCT,
Employees.MANAGER_ID,
Employees.DEPARTMENT_ID"
FromList="EMPLOYEES Employees"
BindingStyle="OracleName"
CustomQuery="false"
PageIterMode="Full"
UseGlueCode="false">
<DesignTime>
<Attr Name="_codeGenFlag2" Value="Access|VarAccess"/>
</DesignTime>
<Variable
Name="firstName"
Kind="viewcriteria"
Type="java.lang.String"
DefaultValue="0"/>
<EntityUsage
Name="Employees"
Entity="project3.Employees"
JoinType="INNER JOIN"/>
<ViewAttribute
Name="EmployeeId"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="EmployeeId"
EntityUsage="Employees"
AliasName="EMPLOYEE_ID"/>
<ViewAttribute
Name="FirstName"
PrecisionRule="true"
EntityAttrName="FirstName"
EntityUsage="Employees"
AliasName="FIRST_NAME"/>
<ViewAttribute
Name="LastName"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="LastName"
EntityUsage="Employees"
AliasName="LAST_NAME"/>
<ViewAttribute
Name="Email"
IsUnique="true"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="Email"
EntityUsage="Employees"
AliasName="EMAIL"/>
<ViewAttribute
Name="PhoneNumber"
PrecisionRule="true"
EntityAttrName="PhoneNumber"
EntityUsage="Employees"
AliasName="PHONE_NUMBER"/>
<ViewAttribute
Name="HireDate"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="HireDate"
EntityUsage="Employees"
AliasName="HIRE_DATE"/>
<ViewAttribute
Name="JobId"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="JobId"
EntityUsage="Employees"
AliasName="JOB_ID"/>
<ViewAttribute
Name="Salary"
PrecisionRule="true"
EntityAttrName="Salary"
EntityUsage="Employees"
AliasName="SALARY"/>
<ViewAttribute
Name="CommissionPct"
PrecisionRule="true"
EntityAttrName="CommissionPct"
EntityUsage="Employees"
AliasName="COMMISSION_PCT"/>
<ViewAttribute
Name="ManagerId"
PrecisionRule="true"
EntityAttrName="ManagerId"
EntityUsage="Employees"
AliasName="MANAGER_ID"/>
<ViewAttribute
Name="DepartmentId"
PrecisionRule="true"
EntityAttrName="DepartmentId"
EntityUsage="Employees"
AliasName="DEPARTMENT_ID"/>
<ViewCriteria
Name="EmployeesViewCriteria"
ViewObjectName="project3.EmployeesView"
Conjunction="AND">
<Properties>
<CustomProperties>
<Property
Name="mode"
Value="Basic"/>
<Property
Name="allowConjunctionOverride"
Value="true"/>
<Property
Name="autoExecute"
Value="false"/>
<Property
Name="showInList"
Value="true"/>
<Property
Name="displayOperators"
Value="InAdvancedMode"/>
</CustomProperties>
</Properties>
<ViewCriteriaRow
Name="vcrow24"
UpperColumns="1">
<ViewCriteriaItem
Name="FirstName"
ViewAttribute="FirstName"
Operator="STARTSWITH"
Conjunction="AND"
UpperColumns="0"
Required="Optional">
<ViewCriteriaItemValue
Name="EmployeesViewCriteria_vcrow24_EmployeeId_vcval0"
Value=":firstName"
IsBindVarValue="true"/>
</ViewCriteriaItem>
</ViewCriteriaRow>
</ViewCriteria>
<ViewLinkAccessor
Name="EmployeesView"
ViewLink="project3.EmpManagerFkLink"
Type="oracle.jbo.RowIterator"
IsUpdateable="false"/>
</ViewObject>
And JSF page:
<af:panelGroupLayout layout="vertical">
<af:panelHeader text="Employees">
<af:query id="employeesViewCriteriaQueryId" headerText="Search"
disclosed="true"
resultComponentId="employeesViewCriteriaQueryResultId"
value="#{bindings.EmployeesViewCriteriaQuery.queryDescriptor}"
model="#{bindings.EmployeesViewCriteriaQuery.queryModel}"
queryListener="#{bindings.EmployeesViewCriteriaQuery.processQuery}"
queryOperationListener="#{bindings.EmployeesViewCriteriaQuery.processQueryOperation}"/>
</af:panelHeader>
<af:table value="#{bindings.EmployeesView1.collectionModel}" var="row"
rows="#{bindings.EmployeesView1.rangeSize}"
emptyText="#{bindings.EmployeesView1.viewable ? 'No rows yet.' : 'Access Denied.'}"
fetchSize="#{bindings.EmployeesView1.rangeSize}"
id="employeesViewCriteriaQueryResultId">
<af:column sortProperty="EmployeeId" sortable="false"
headerText="#{bindings.EmployeesView1.hints.EmployeeId.label}">
<af:outputText value="#{row.EmployeeId}">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.EmployeesView1.hints.EmployeeId.format}"/>
</af:outputText>
</af:column>
<af:column sortProperty="FirstName" sortable="false"
headerText="#{bindings.EmployeesView1.hints.FirstName.label}">
<af:outputText value="#{row.FirstName}"/>
</af:column>
<af:column sortProperty="LastName" sortable="false"
headerText="#{bindings.EmployeesView1.hints.LastName.label}">
<af:outputText value="#{row.LastName}"/>
</af:column>
</af:table>
</af:panelGroupLayout>
Regards
Jernej
Message was edited by:
Jernej KaseIt also seems that quick queries don't work with SQL92 sqlBuilder.
I get the following error:
Messages for this page are listed below.
Error
SQL error during statement preparation. Statement: SELECT Employees.EMPLOYEE_ID, Employees.FIRST_NAME, Employees.LAST_NAME, Employees.EMAIL, Employees.PHONE_NUMBER, Employees.HIRE_DATE, Employees.JOB_ID, Employees.SALARY, Employees.COMMISSION_PCT, Employees.MANAGER_ID, Employees.DEPARTMENT_ID FROM EMPLOYEES Employees WHERE (( ( ( UPPER(Employees.FIRST_NAME) LIKE UPPER(:vc_temp_1) ) OR ( ? IS NULL ) ) ) )
Error
Missing IN or OUT parameter at index:: 2
Is this a bug or this doesn't work by design?
Edit: and if I create named query I get the following error:
Caused by: oracle.jbo.NoDefException: JBO-25058: Definition fn of type Attribute not found in EmployeesView1
at oracle.jbo.server.ViewObjectImpl.findAttributeDef(ViewObjectImpl.java:5634)
at oracle.jbo.uicli.binding.JUSearchBindingCustomizer.getQuickSearchVC(JUSearchBindingCustomizer.java:847)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlSearchBinding.processQuery(FacesCtrlSearchBinding.java:222)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
... 47 more
I think just ran out of options...
Message was edited by:
Jernej Kase -
Hi .
I was creating the pass the values t in temp tables though s sis package vs2012 .
First I was taken on executive SQL TASK.
IN EXCUTIVE SQL TASK . I was write the stored proce:
Sp;
reate procedure USP_GETEMP2333
AS
begin
Select eid,ename,dept,salary from emp
end;
create table #temp(eid int,ename varchar(20),dept varchar(20),salary int)
insert into #temp
exec USP_GETMP02333
go.
It was executive correctly.
I was taken another sequence container. In the sequence container iam creating one executive sql
In 2<sup>nd</sup> excutive sql task: sql statements is
if object_id('emp_fact_sal') is not null
drop table emp_fact_sal
select eid,ename as emp_name,sal_bar=
case when salary<=5000 then 'l'
when salary >5000 and salary<=7000 then 'm'
else
'h'
end
into emp_fact_sal from #temp.
and one falt flies it was taken to designation .
iam changing all connection properties:
in oldeb connection:
in excutive sal task properties .
delay validation is true,
and retain connection maner is also true,
and package mode is 64 bit is false.
But iwas excutive in 2<sup>nd</sup> excutive ql task .
Iam getting this type of errors,
[Execute SQL Task] Error: Executing the query " if object_id('emp_fact_sal') is not null
drop ta..." failed with the following error: "Invalid object name '#Temp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
correctly.
Please help meArthur suggestion works but you shouldnt even be doing this on a SQL Task.
Use a data flow task. You'll have better control over the data that is being transfered and get better performance because no staging table will be used.
Just because there are clouds in the sky it doesn't mean it isn't blue. But someone will come and argue that in addition to clouds, birds, airplanes, pollution, sunsets, daltonism and nuclear bombs, all adding different colours to the sky, this
is an undocumented behavior and should not be relied upon. -
Problem with Hierarchical query
Gurus,
I have a problem with hierarchical query, which I am pasting below.
select sys_connect_by_path (Fname,'/')"PATH",Fname,id,level
,(SELECT COUNT(ID)-1 FROM (SELECT CONNECT_BY_ROOT LNAME LNAME,ID FROM CMT_PERSON
START WITH ID = 'emplo000000000126009'
CONNECT BY PRIOR ID=MANAGER_ID)
GROUP BY FNAME)"COUNT"
from CMT_PERSON
WHERE
LEVEL <= 4
----And ID='emplo000000000001877'
CONNECT BY PRIOR id=manager_id
----AND NOT LEVEL > 3
START WITH ID='emplo000000000126009'
As per the result, count is getting repeated for all the levels. That is, count is coming 16100 for every level, Can you please help where exactly I am going wrong
RegardsYou do not say anything about what count you want to get?
A wild guess could be:
select
sys_connect_by_path (p1.fname, '/') "PATH",
p1.fname,
p1.id,
level,
(select count (id) - 1
from
(select connect_by_root p2.lname lname, p2.id
from cmt_person p2
start with p2.id = p1.id
connect by prior p2.id = p2.manager_id)
) "COUNT"
from cmt_person p1
where level <= 4
connect by prior p1.id = p1.manager_id
start with p1.id = 'emplo000000000126009';Since your inner query simply starts with the hardcoded employee id, naturally it will give you the same count.
My guess is your inner query should start with the person id from the outer query?
If that is not the case - please state in plain english what you are trying to accomplish ;-)
(Oh, and please paste code within tags so we can read it more easily...)
Maybe you are looking for
-
How to know the correct Elapsed Time?
When I run a query twice, I get better timing on the query the second time around. I am assuming this is happening becuase some or most of the data is still in cache. How do I remove the cache data so that I know if my Indexing or anything else reall
-
Constant Selection on MultiProvider is not working properly
Hi All, We have a MP based on 2 DSOs, say DSO1 & DSO2. DSO1: Char 1, Char 2, Char 3 and KF1 DSO2: Char 1, Char 2, Char 4 and KF2. Now, I am creating a query by using constant selection. I have kept all chars in Rows pane and 2 KF in Columns pane. I h
-
Is oracle project generate alert incase of any delays in Tasks Or prject
Hi Experts It's possible to generated auto alert in case of delay's in Task/Projects ? If yes please give me link.
-
My IPad has one half of the screen with vertical multi colored stripes and the other half is normal. Has anyone had this problem and if so is there a solution?
-
I'm running Lion 10.7.1 and Safari 5.1. No matter how many times I install Flash Player, Safari won't recognize it and tells me I need to download the latest version. I'm reduced to watching videos on another browser. Any ideas?