SQL Fetch max 3 values of a coloumn in descending order.
Oracle 10.2 gSelect distinct year
from year_col
order by year desc
2006
2005
2004
2003
2002
...
That the recent 3 years need to be selectedselect distinct max(year)
from year_col
order by year desc
Returns2006
but must also 2005,2004
Cannot use rownum as it continues to change.
Suggest a method.
Thank you.
Published by: Trooper on January 3, 2009 14:35
Select distinct year
from year_col
where year > to_number(to_char(sysdate,'yyyy')) - 3
order by year desc
/
Select year = 2007, 2008, 2009
SY.
Tags: Database
Similar Questions
-
Cannot find the MAX Date value in the USER_TAB_PARTITIONS HIGH_VALUE
Hi all
I'll try to find the Max value of the date of the HIGH_VALUE from the USER_TAB_PARTITIONS, but my request has failed because the HIGH_VALUE is a LONG column.
Appreciate your valuable contributions here.
Thank you
MK.Maldini says:
I'll try to find the Max value of the date of the HIGH_VALUEYou use the PL/SQL:
SQL> select high_value 2 from user_tab_partitions 3 where table_name = 'RANGE_SALES' 4 / HIGH_VALUE ---------------------------------------------------------------------------------------------- TO_DATE(' 1998-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 1998-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 1998-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 1999-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 1999-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 1999-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 1999-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 2000-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 2000-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 2000-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') TO_DATE(' 2000-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') HIGH_VALUE ---------------------------------------------------------------------------------------------- MAXVALUE 12 rows selected.
Now:
create or replace type DateList as table of date / declare v_DateList DateList := DateList(); v_max_high_value date; begin for v_rec in (select high_value from user_tab_partitions where table_name = 'RANGE_SALES') loop if v_rec.high_value != 'MAXVALUE' then v_DateList.extend; execute immediate 'begin :1 := ' || v_rec.high_value || '; end;' using out v_DateList(v_DateList.count); end if; end loop; select max(column_value) into v_max_high_value from table(v_DateList); dbms_output.put_line('Table RANGE_SALES max high value is ' || to_char(v_max_high_value,'MM/DD/YYYY HH24:MI:SS')); end; / Table RANGE_SALES max high value is 10/01/2000 00:00:00 PL/SQL procedure successfully completed. SQL>
SY.
-
Do stuff to PL/SQl that returns the value and redirect to modal page by setting this value
Hello
a button click Page1 I would perform a PL/SQL procedure that returns a value in P1_ITEMVAL and then redirect to a page 2 (modal page) and the value of an item on this page with the value previously returned. To do the same thing with a normal page is quite easy:
Button action is present, then process of PL/SQL that returns the value in the P1_ITEMVAL element and, finally, a branch at page 2 that sets P2_ITEMVAL with P1_ITEMVAL. I really have no idea how to do the same thing when the target is a modal page.
I created a unit test on https://apex.oracle.com/pls/apex (application 1554 - redir_to_modal)
Workspace: tests
USER: supporter
PWD: supporter1234
Any help would be much appreciated.
Kind regards
Pavel
Pavel
If you prepare a URL using the value calculated in the PLSQL of DA part you can then use a subsequent stage of javascript to set the location of the window.
This will jump to the top of the page of the modal dialog box
: P1_URL: = apex_util.prepare_url)
' f ? p ='|| : APP_ID - Application id
|': 2' - Page id
||': ' || : APP_SESSION - Session id
||':' -- Request
||':NO' -- Debug
: ': ' - Clear Cache
: ': ' - Settings
||' P2_ITEMVAL'
: ': ' - Parameter values
|| (: P1_ITEMVAL);
then in the action of javascript
Window.Location.Replace ($v ('P1_URL'));
Hope this is of some use
Concerning
Kelvin
-
Passing data from attachment of DB (Blob data Type) after the CLOB data type conversion, giving the error "ORA-06502: PL/SQL: digital error or value" in the PL/SQL package. If the BLOB size 32K > it will give another error works great my procedure.
For example, I enclose my code here.
function get_base64 (p_blob_in in blob) return clob is
CLOB v_clob;
CLOB v_result;
whole v_offset;
v_chunk_size PLS_INTEGER: = 12288;
v_buffer_varchar varchar2 (32767).
v_buffer_raw raw (32767).
Start
fnd_file.put_line (fnd_file.log, 'here');
If p_blob_in is null then
Returns a null value.
end if;
DBMS_LOB.CREATETEMPORARY (v_clob, true);
fnd_file.put_line (fnd_file.log, 'here1');
v_offset: = 1;
fnd_file.put_line (fnd_file.log, 'Loop value'-| ceil (DBMS_LOB.) GetLength (p_blob_in) / v_chunk_size));
because me in 1... ceil (DBMS_LOB. GetLength (p_blob_in) / v_chunk_size) loop
DBMS_LOB. Read (p_blob_in, v_chunk_size, v_offset, v_buffer_raw);
v_buffer_raw: = utl_encode.base64_encode (v_buffer_raw);
v_buffer_varchar: = utl_raw.cast_to_varchar2 (v_buffer_raw);
DBMS_LOB. WriteAppend (v_clob, length (v_buffer_varchar), v_buffer_varchar);
v_offset: = v_offset + v_chunk_size;
end loop;
fnd_file.put_line (fnd_file.log, 'Out of the loop');
v_result: = v_clob;
fnd_file.put_line (fnd_file.log, 'V_result length' - |) DBMS_LOB. GetLength (v_result));
fnd_file.put_line (fnd_file.log, 'V_result' - | v_result);
DBMS_LOB.freeTemporary (v_clob);
Return v_result;
exception
while others then
fnd_file.put_line (fnd_file.log, 'Error based on the encode_base64' - |) SQLERRM);
Returns a null value.
end;
In my main program I call this function as below:
Main proceedings...
l_return_clob CLOB.
Begin
....
l_return_clob: = get_base64 (p_blob_in);
-In returning it gives error - ORA-06502: PL/SQL: digital error or value
end;
Then, please mark the thread ANSWERED.
-
Hi all
I started playing with OEMM and I get the following error when I try to 'Trace Data Impact' in an Oracle table. Here's what I do:
- I created a template and collected a few schemas/tables:
- Now when I try to "Trace Data Impact' on the table AP_DEF_STG, I get the following:
I already tried to create a "Configuration" for her, I tried to text instead of graphics, but the error is the same. If I go to a view of Oracle and do a "track Data Lineage", I get the same error again.
That someone was already been in this situation? This is the full error trace:
({"error": true, "errorMessage": "SQL error during the tracing of lineage: ORA-22813: value of the operand exceeds the limits of the system"})
', 'errorType': 'Line error', 'errorCodes': "[LNGTRC_E0016]".
","stackTrace":"Error Codes - [LNGTRC_E0016].
Request - VizModelLineage
Settings - showInternalObject [false] showNoType [true] showControlLinks [false] startingIds [17 #4723 #0] isBizUI [false] ObjectID [17 #1 #0] showSummaryView [true] collapseLevel [features] resetCache [fake] profile [] showMappingsAsNodes [true] skipCache [false] tracingDirection [3] tracingType [DataLineage] [ReportTree2202015-104855025] originalStartingObject cacheId [17 #4723 #0] viewType actionType [loadlineage] of viewId [ReportTree2202015-104855025] [ModelLineage]
MITI.web.common.exceptions.LineageUIException: SQL for tracing line error: ORA-22813: value of the operand exceeds the limits of the system
at MITI.web.common.service.facades.LineageFacadeImpl.getLineageGraph (LineageFacadeImpl.java:284)
at MITI.flash.tabs.VizModelLineage.getLineageTree (VizModelLineage.java:429)
at MITI.flash.tabs.VizModelLineage.buildLineageGraph (VizModelLineage.java:356)
at MITI.flash.tabs.VizModelLineage.performAction (VizModelLineage.java:148)
at MITI.server.servlets.FlashServlet.doPost (FlashServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
to org.apache.coyote.AbstractProtocol$ AbstractConnectionHandler.process (AbstractProtocol.java:611)
to org.apache.tomcat.util.net.JIoEndpoint$ SocketProcessor.run (JIoEndpoint.java:316)
to java.util.concurrent.ThreadPoolExecutor$ Worker.runTask (ThreadPoolExecutor.java:895)
to java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:918)
to org.apache.tomcat.util.threads.TaskThread$ WrappingRunnable.run (TaskThread.java:61)
at java.lang.Thread.run(Thread.java:662)
Caused by: MITI.server.services.lineage.LineageException: (LNGTRC_E0016) SQL error during the tracing of lineage: ORA-22813: value of the operand exceeds the limits of the system
at MITI.server.services.lineage.database.LineageDataSource.handle (LineageDataSource.java:41)
at MITI.util.database.CommonDataSource.handleSQLException (CommonDataSource.java:124)
at MITI.util.database.CommonDataSource.executeTransaction (CommonDataSource.java:83)
at MITI.util.database.CommonDataSource.executeStatement (CommonDataSource.java:54)
at MITI.server.services.lineage.impl.LineageImpl.traceLineage (LineageImpl.java:554)
at MITI.server.services.lineage.common.LineageTracer.traceLineage (LineageTracer.java:1078)
at MITI.server.services.lineage.common.LineageTracer.traceDataLineage (LineageTracer.java:313)
at MITI.server.services.lineage.common.LineageTracer.traceTechnicalData (LineageTracer.java:176)
at MITI.web.common.service.facades.LineageFacadeImpl.getLineageGraph (LineageFacadeImpl.java:245)
... 21 more
Caused by: java.sql.SQLException: ORA-22813: value of the operand exceeds the limits of the system
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1035)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1188)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3386)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3487)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at MITI.util.database.Query.executeStatement (Query.java:45)
at MITI.util.database.Statement.execute (Statement.java:66)
to MITI.util.database.CommonDataSource$ 1.run(CommonDataSource.java:50)
to MITI.util.database.CommonDataSource$ 1.run(CommonDataSource.java:47)
at MITI.util.database.Transaction.execute (Transaction.java:92)
at MITI.util.database.CommonDataSource.executeTransaction (CommonDataSource.java:80)
... more than 27
Caused by:
MITI.server.services.lineage.LineageException: (LNGTRC_E0016) SQL error during the tracing of lineage: ORA-22813: value of the operand exceeds the limits of the system
at MITI.server.services.lineage.database.LineageDataSource.handle (LineageDataSource.java:41)
at MITI.util.database.CommonDataSource.handleSQLException (CommonDataSource.java:124)
at MITI.util.database.CommonDataSource.executeTransaction (CommonDataSource.java:83)
at MITI.util.database.CommonDataSource.executeStatement (CommonDataSource.java:54)
at MITI.server.services.lineage.impl.LineageImpl.traceLineage (LineageImpl.java:554)
at MITI.server.services.lineage.common.LineageTracer.traceLineage (LineageTracer.java:1078)
at MITI.server.services.lineage.common.LineageTracer.traceDataLineage (LineageTracer.java:313)
at MITI.server.services.lineage.common.LineageTracer.traceTechnicalData (LineageTracer.java:176)
at MITI.web.common.service.facades.LineageFacadeImpl.getLineageGraph (LineageFacadeImpl.java:245)
at MITI.flash.tabs.VizModelLineage.getLineageTree (VizModelLineage.java:429)
at MITI.flash.tabs.VizModelLineage.buildLineageGraph (VizModelLineage.java:356)
at MITI.flash.tabs.VizModelLineage.performAction (VizModelLineage.java:148)
at MITI.server.servlets.FlashServlet.doPost (FlashServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
to org.apache.coyote.AbstractProtocol$ AbstractConnectionHandler.process (AbstractProtocol.java:611)
to org.apache.tomcat.util.net.JIoEndpoint$ SocketProcessor.run (JIoEndpoint.java:316)
to java.util.concurrent.ThreadPoolExecutor$ Worker.runTask (ThreadPoolExecutor.java:895)
to java.util.concurrent.ThreadPoolExecutor$ Worker.run (ThreadPoolExecutor.java:918)
to org.apache.tomcat.util.threads.TaskThread$ WrappingRunnable.run (TaskThread.java:61)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.sql.SQLException: ORA-22813: value of the operand exceeds the limits of the system
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1035)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1188)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3386)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3487)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at MITI.util.database.Query.executeStatement (Query.java:45)
at MITI.util.database.Statement.execute (Statement.java:66)
to MITI.util.database.CommonDataSource$ 1.run(CommonDataSource.java:50)
to MITI.util.database.CommonDataSource$ 1.run(CommonDataSource.java:47)
at MITI.util.database.Transaction.execute (Transaction.java:92)
at MITI.util.database.CommonDataSource.executeTransaction (CommonDataSource.java:80)
... more than 27
Caused by:
java.sql.SQLException: ORA-22813: value of the operand exceeds the limits of the system
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:206)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1035)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1188)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3386)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3487)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1374)
at MITI.util.database.Query.executeStatement (Query.java:45)
at MITI.util.database.Statement.execute (Statement.java:66)
to MITI.util.database.CommonDataSource$ 1.run(CommonDataSource.java:50)
to MITI.util.database.CommonDataSource$ 1.run(CommonDataSource.java:47)
at MITI.util.database.Transaction.execute (Transaction.java:92)
at MITI.util.database.CommonDataSource.executeTransaction (CommonDataSource.java:80)
at MITI.util.database.CommonDataSource.executeStatement (CommonDataSource.java:54)
at MITI.server.services.lineage.impl.LineageImpl.traceLineage (LineageImpl.java:554)
at MITI.server.services.lineage.common.LineageTracer.traceLineage (LineageTracer.java:1078)
at MITI.server.services.lineage.common.LineageTracer.traceDataLineage (LineageTracer.java:313)
at MITI.server.services.lineage.common.LineageTracer.traceTechnicalData (LineageTracer.java:176)
at MITI.web.common.service.facades.LineageFacadeImpl.getLineageGraph (LineageFacadeImpl.java:245)
at MITI.flash.tabs.VizModelLineage.getLineageTree (VizModelLineage.java:429)
at MITI.flash.tabs.VizModelLineage.buildLineageGraph (VizModelLineage.java:356)
at MITI.flash.tabs.VizModelLineage.performAction (VizModelLineage.java:148)
at MITI.server.servlets.FlashServlet.doPost (FlashServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
Oracle has published OEMM 12.2.1 and this error is gone! So if you are facing this problem in an older version, just go to the newest one.
-
Apex 4.2
I searched through the forums of the research about this error, but I do not understand what to do from here. I am writing a process that sends an e-mail when a value of the claim is made (or on a button click). Procedure is as follows:
DECLARE l_body clob; l_body_html clob; l_subject varchar2(100); BEGIN l_body := empty_clob(); l_body_html := empty_clob(); IF V('REQUEST') in ('SAVE_ME') AND :P32_PARENT_UPDATED_FL IS NOT NULL THEN l_subject := 'Survey Job Request Updated'||utl_tcp.crlf||utl_tcp.crlf; l_body := 'Update'||utl_tcp.crlf; l_body_html := '<html> <head> <style type = "text/css"> /* Can add style attributes later */ </style> </head> <body>'||utl_tcp.crlf; l_body_html := l_body_html ||'Survey Job Request has been updated.<br /><br />'||utl_tcp.crlf; l_body_html := l_body_html ||'Title: '||utl_tcp.crlf; l_body_html := l_body_html ||:P32_TITLE||utl_tcp.crlf; l_body_html := l_body_html ||'<br />Request Category : '||utl_tcp.crlf; l_body_html := l_body_html ||:P32_REQUEST_CATEGORY||utl_tcp.crlf; l_body_html := l_body_html ||'<br />Update Date: '||utl_tcp.crlf; l_body_html := l_body_html ||:P32_UPDATE_DATE||utl_tcp.crlf; l_body_html := l_body_html ||'<br />Updated By: '||utl_tcp.crlf; l_body_html := l_body_html ||:P32_LAST_EDITED_BY_USERID||utl_tcp.crlf; l_body_html := l_body_html ||'</body></html>'; END IF; :P32_CANCELLATION_REASON := l_body_html; apex_mail.send( p_to => '[email protected]', p_from => '[email protected]', p_body => l_body_html, p_body_html => l_body_html, p_subj => l_subject); END;
I added two lines to the code (lines 08 and 09) and when I run my program, I now get the error:
- ORA-21560: 3 argument is null, invalid or out of range
Without these two lines, I received the error:
ORA-06502: PL/SQL: digital error or value: specified incorrect LOB Locator
I'm not quite sure what is wrong or what I can change. There seems to be right, and in fact, it worked before. I have no idea why this error keeps popping up. Any help on that would be great. Thanks in advance.
Hello
NewApexCoder wrote:
Hmmm... good point. I think that apex_mail.send must be called inside the IF block. But in the future, I added several conditional statements, won't I need to include the apex_mail.send function in each IF block? But at the same time, there is the case that if no conditional instructions are met? Tests, when none of the conditions are true (when I had a second IF block in the code), an email would not be defined, which is correct. Could that be causing a problem however. If the IF block is not filled could he always try to send an email about anything or the l_body_html and l_subject fields have in them the garbage that causing ORA error?
If the call to the procedure of sending (it is a procedure, and not a function) many times is necessary or useful depends on exactly what you're trying to do.
For example, you can write to Santa for
- Submit a wish list
- Change of address
- Contradiction with your boss, who can you tell Santa you were mean
or any combination of these grounds. If you want to send a simple email whenever any of the conditions are met (and not send a when none are met), then you could do something like this:
DECLARE
need_to_send BOOLEAN: = FALSE;
...
BEGIN
...
IF wish_list IS NOT NULL
THEN
l_body: = l_body | ...
need_to_send: = TRUE;
END IF;
IF old_addresss <> new_address
THEN
l_body: = l_body | ...
need_to_send: = TRUE;
END IF;
IF boss_is_a_big_fat_liar
THEN
l_body: = l_body | ...
need_to_send: = TRUE;
END IF;
IF need_to_send
SO - It's the only call to send
apex_mail. Send...
In any case, the error message ' ORA-21560: argument 3 sucks...» "is pretty clear: If you have not given a value to everything you're passing as p_body, then you'd better call the procedure.
-
reload the page when SQL query returns a value
Hello world
the title of this discussion may seem strange, but I'll try to explain why I need this:
A user has the ability to connect on my APEX application. There are several tabs in my application that are visible only if a certain SQL statement returns a value which is not the case by default. The user has also the ability to download a file that is transferred to an external system that analyzes the file and writes the data in the database. During this writing process - which may take several minutes - conditions for some of the tabs to show the will becomes real (-> the query will return a value). When the user refreshes the page manually, the tabs will be displayed. However, I want the tabs will appear automatically when the condition is met.
Is it possible to refresh the page as soon as the query returns a value? It is perhaps possible to check it on the client side and trigger a refresh of the page when the condition is met. It would be even better if only the tabset has been updated, but refreshing the full page is fine as well.
Thank you!
Here is an overview of how it can be done
This is possible thanks to a dynamic action being performed on a timer.
View default tabs and dynamic action hide them on loading the page if they are not to be considered
Create a dynamic action that will execute your query every 5 seconds or more
If the query returns data, you can use the dynamic action to show your tabs using javascript
-
ORA-06503: PL/SQL: function returned no value ORA-06512:
Hi all
SQL > set serveroutput on
SQL > CREATE OR replace FUNCTION qty_value (p_item_id number)
2 RETURN NUMBER
3 EAST
4 v_qty_arrival NUMBER;
5 BEGIN
6. SELECT THE CASE SENSITIVE OPTION
7. WHAT (SUM (b.quantity) - SUM (b.quantity_received)) < = 0 THEN 0
8 ELSE (SUM (b.quantity) - SUM (b.quantity_received))
9 END Qty_Arrival
10 INTO v_qty_arrival
Po_lines_all 11 a,
po_line_locations_all 12 b
13 WHERE a.po_line_id = b.po_line_id
14 AND a.item_id = p_item_id;
15 EXCEPTION
16 THEN THAN OTHERS THEN
17 v_qty_arrival: = NULL;
18 RETURN v_qty_arrival;
19 END qty_value;
20.
The function is created.
SQL >
SQL > select xxc_qty_arrivale (214960) double
2.
Select xxc_qty_arrivale (214960) double
*
ERROR on line 1:
ORA-06503: PL/SQL: function returned no value
ORA-06512: at the 'APPS '. XXC_QTY_ARRIVALE', line 19
Back AFTER using the exception block is fine as long as your code actually REACHED the exception block.
When there are no errors, then your code will not enter the exception block, but you still NEED to return a value, since it is what functions a function wants to return a value, that's what the functions are made for.
Spot the differences between the following 3 functions. Understand how they work.
The first function has only a return in the exception block but runs correctly. Result: error, because the back is missing in the code block.
The second function has a return in the exception block and one in the block of code and runs correctly. Result: no error, because the return is not missing in the code block.
The third function has a return in the exception block and one in the block of code and is forced into an error. Result: no error, because the return of the exception handler is used (instead of retriggering of the error, which you would normally do).
SQL > create or replace function myfunc
2 return number
3 as
4 start
5 dbms_output.put_line ('in the section of code');
6 null;
7 exception
8 then than others
9. can
10 dbms_output.put_line (' in the exception handler ' |) SQLERRM);
11 --
12 return 0;
13 --
14 end;
15.
The function is created.
SQL > select double myfunc;
Select double myfunc
*
ERROR on line 1:
ORA-06503: PL/SQL: function returned no value
ORA-06512: at "GHPLUS. MYFUNC", line 14
In the section of code
SQL > create or replace function myfunc
2 return number
3 as
4 start
5 dbms_output.put_line ('in the section of code');
6 null;
7 --
8 return 1;
9 --
10 exceptional
11 so that others
12. can
13 dbms_output.put_line (' in the exception handler ' |) SQLERRM);
14 --
15 return 0;
16 --
end 17;
18.
The function is created.
SQL > select double myfunc;
MYFUNC
----------
1
1 selected line.
In the section of code
SQL > create or replace function myfunc
2 return number
3 as
n number 4;
5. start
6 dbms_output.put_line ('in the section of code');
7 n: = 1/0; -force an error (zero divisor) to join the exception handler
8 --
9 return 1;
10-
exception 11
12 so that others
13. can
14 dbms_output.put_line (' in the exception handler ' |) SQLERRM);
15 --
16 return 0;
17 --
18 end;
19.
The function is created.
SQL > select double myfunc;
MYFUNC
----------
0
1 selected line.
In the section of code
In the handler for exception ORA-01476: divisor is equal to zero
SQL >
-
Getting Ora-06502: PL/SQL of Numeric or value error.
Hello
I m getting the following error when a calculation for form fields.
""Server Ajax Call returned error Ora-06502: PL/SQL digital error or value ".
I m using the dynamic action to calculate my value fields display. Here is the code of my DA.
(Required value) event: change
Selection type (required): product (s)
Article (s) (required): P141_PROP_COST, P141_DOWNPAY_AMT, P141_PREM_PERC, P141_DOWNPAY_PERC, P141_PREM_AMT
Begin
: P141_TOTAL_SELL_PRICE: =: P141_DOWNPAY_AMT +: P141_PREM_AMT;
: P141_COMM_AMT: =: P141_TOTAL_SELL_PRICE*.02;
: P141_TOTAL_SELL_PRICE_FEE: =: P141_TOTAL_SELL_PRICE +: P141_TRANSFER_COST +: P141_COMM_AMt;
: P141_INST_REM_AMT: =: P141_PROP_COST-: P141_DOWNPAY_AMT;
End;
Page point to presented: P141_PROP_COST, P141_DOWNPAY_AMT, P141_PREM_AMT, P141_TRANSFER_COST
Return point page: P141_TOTAL_SELL_PRICE, P141_COMM_AMT, P141_TOTAL_SELL_PRICE_FEE, P141_INST_REM_AMT
I m using another DA for the calculation and validation of my form fields rest. Here is the code:
{$("#P141_DOWNPAY_PERC").change (function ()}
var x = ($("#P141_DOWNPAY_PERC").val () / 100) * $("#P141_PROP_COST").val ();
$("#P141_DOWNPAY_AMT").val (x);
});
{$("#P141_DOWNPAY_AMT").change (function ()}
If ($("#P141_DOWNPAY_AMT").val () > $("#P141_PROP_COST").val ())
{
Alert ("section may be no greater than the basic price");
}
on the other
{var y = ($("#P141_DOWNPAY_AMT").val () / ($("#P141_PROP_COST").val ())) * 100;}
y = Math.Round (y);
$("#P141_DOWNPAY_PERC").val (y) ;}
});
{$("#P141_PREM_PERC").change (function ()}
var x = ($("#P141_PREM_PERC").val () / 100) * $("#P141_PROP_COST").val ();
$("#P141_PREM_AMT").val (x);
});
{$("#P141_PREM_AMT").change (function ()}
If ($("#P141_PREM_AMT").val () > $("#P141_PROP_COST").val ())
{
Alert ("section may be no greater than the basic price");
}
on the other
{var z = ($("#P141_PREM_AMT").val () / ($("#P141_PROP_COST").val ())) * 100;}
z = Math.Round (z);
$("#P141_PREM_PERC").val (z) ;}
});
Any help.
Concerning
Pa'Problems of implicit conversion' comes to mind when I see this:
: P141_TOTAL_SELL_PRICE: =: P141_DOWNPAY_AMT +: P141_PREM_AMT;
This is similar to the problems I've seen when using the default formats for the Date Picker Item Types.
I will add in some APEX_DEBUG. MESSAGE() lines to check what are the string values.
(remember, all bind variables are of type VARCHAR2)
You should maybe explicitly to convert strings to numbers using TO_NUMBER() and include the appropriate format.
(a bit like you have to do with the conversion of strings to dates.)
My $0.02 worth
MK
-
ORA-06502: PL/SQL: digital error or value
Hello
We have a package with a cursor that returns the session information:
create or replace PACKAGE BODY "LOGIN_AUDIT" ... ... CURSOR session_cur IS SELECT * FROM v$session WHERE audsid=USERENV('sessionid'); session_rec session_cur%ROWTYPE; ... FUNCTION get_osuser RETURN VARCHAR2 IS BEGIN RETURN session_rec.osuser; END; FUNCTION get_dbuser RETURN VARCHAR2 IS BEGIN RETURN NVL(session_rec.username, 'ORACLE_SYS'); END; ...
The package compiled successfully and works ok out for a function that is the get_osuser. When you launch sqlplus, we get the following error:
Select double LOGIN_audit.get_osuser;
*
ERROR on line 1:
ORA-06502: PL/SQL: digital error or value
ORA-06512: at "APPUSR. LOGIN_AUDIT', line 94
ORA-06512: at "APPUSR. LOGIN_AUDIT', line 102
The APPUSR has select priv on V$ SESSION and a select * from v$ session returns the session information. We can perform any other function since the package without any problem, for example:
APPUSR@APPD > select double login_audit.get_dbuser;
GET_DBUSER
-------------------------------------------------------------
APPUSR
Can someone help us work on what happens please.
PS Oracle: 11.2.0.3, OS Windows 2008 server.
Thank you
Really I have not aside, this and raise the question?
Why you write all this code?
wouldn't the following very good enough?
- FUNCTION get_osuser RETURN VARCHAR2; Use sys_context ('USERENV', 'OS_USER')
- FUNCTION get_dbuser RETURN VARCHAR2; Use sys_context ('USERENV', 'SESSION_USER')
- FUNCTION get_client_info RETURN VARCHAR2; Use sys_context ('USERENV', 'CLIENT_INFO')
- FUNCTION get_module_info RETURN VARCHAR2; Use sys_context ('USERENV', 'MODULE')
- FUNCTION get_action_info RETURN VARCHAR2; Use sys_context ('USERENV', 'ACTION')
Just do not know, I see the advantage of messing around with this slider and have to fight with the updating of information and others.
This would totally work around the error you get and probably accelerate - and make it easier to maintain.
??
Unless there is some additional requirements, that I'm missing
-
Error processing request. ORA-06502: PL/SQL: digital error or value OK
Hello
I want to open a session in an APEX application using the IE 8 browser, but I can't because this error:
Error Error processing request. ORA-06502: PL/SQL: digital error or value Ok I can run this app with Chrome or Mozilla, but I need to open it with IE.
Can you please tell me how should I solve this problem?
Thank you
It is a problem with your version of APEX that you use... There was a patch released about 6 months ago... or you can just upgrade to the latest version. I also had this problem, and there are several similar topics in this forum about the exact problem and at least the a precise details on the patch/fix.
-
Group values by Max + equal values
Hi Experts,
I'm looking for a query where I can group data accordingly and exclude the lines that didn't need.please helps to achieve this.
I have data like this in my picture
Number of type Cust_id
ABC 10 19
10 19 abcde
10 8 abcde
20 e 8
20 4 u
f 30 30
I need to put like this
Number of type Cust_id
ABC 10 19
10 19 abcde
20 e 8
f 30 30
Thank you
BharatLook at my first post:
Re: Group values by Max + equal values -
UTL_SMTP. Data ORA-06502: PL/SQL: digital error or value
Hello
I use utl_smtp to send an HTML email, I'm passing in a clob to utl_smtp.data (), works very well for some emails small relativley is no bigger nut, which return the following error
ORA-06502: PL/SQL: digital error or value
Does anyone know what the limitation is the size if the parameter of body to utl_smtp.data (), and is there another way to send large mails?
Thank you...refer to this
http://www.Oracle-base.com/articles/Misc/email-from-Oracle-plsql.php
http://asktom.Oracle.com/pls/asktom/f?p=100:11:3366784949717501:P11_QUESTION_ID:1739411218448
-
ORA-06502: PL/SQL: digital error or value: number too high accuracy
Hi all
Sorry I can't speak English very well
========
IM creating a function in the hr schema
I need to calculate a tax
syntax of the function is
CREATE OR REPLACE THE TAX FUNCTION
(F_TAX EMPLOYEES % OF SALARY TYPE)
RETURN NUMBER IS
V_SAL EMPLOYEES. % SALARY TYPE.
BEGIN
SELECT salary * 12
IN v_sal
Employees
WHERE EMPLOYEE_ID = F_TAX;
IF V_SAL > = 40000 THEN
V_SAL: = V_SAL / 0,20;
ELSIF V_SAL > = 30000 THEN
V_SAL: = V_SAL / 0.15;
END IF;
RETURN V_SAL;
TAX END;
==================
When I select a tax I have this problem
SELECT (EMPLOYEE_ID) TAX
EMPLOYEES
It comes
SELECT (EMPLOYEE_ID) TAX
*
ERROR on line 1:
ORA-06502: PL/SQL: digital error or value: number too high accuracy
ORA-06512: at "HR. The TAX", line 16V_SAL is declared as HR. EMPLOYEES. % OF SALARY TYPE. If you look at the definition of time. The table EMPLOYEES, the SALARY column is a NUMBER (8,2). This means that it can handle numbers up to $999,999.99 (8 total digits with 2 decimal places).
Your IF statement is dividing the salary by 0.20, which is equivalent to multiplying by 5 or dividing by 0.15, which is multiplied by 6.67. In reality, at least a salary is high enough now that when you multiply by 5 or 6.67 it exceeds the limit of $999,999.99 (especially when you already multiplied by 12 SALARY column in your SELECT statement).
-If your intention is to return in numbers that exceed the limits of the SALARY column in human resources. EMPLOYEES, you will need to declare V_SAL differently. You can declare V_SAL as a NUMBER (11.2), for example, given that any number that you store in a NUMBER (8.2), multiplied by 60, which can be represented in a NUMBER (11.2).
-If your intention is to return the numbers that fall within the limits of the SALARY column in human resources. USED, I suspect that the algorithm that you implemented is incorrect. Perhaps, for example, you would divide by 1.2 or 1.15 as a kind of tax accounting?Justin
-
Question by adding the LOBs-ORA-06502: PL/SQL: digital error or value
Hello
I'm using Oracle 11 g.
I have a requirement in which I need to add LOBs and I must insert the LOB in a table column. I am facing problem when the data exceeds certain limits. My program works like the following:
(Please note that my program logic is given below, not the exact program)
DECLARE
final_html CLOB.
int_html CLOB.
v_str VARCHAR2 (32767).
i the number: = 0;
BEGIN
DBMS_LOB.CREATETEMPORARY (lob_loc = > int_html, CACHE = > TRUE, hard = > dbms_lob.) CALL);
DBMS_LOB.CREATETEMPORARY (lob_loc = > final_html, CACHE = > TRUE, hard = > dbms_lob.) CALL);
DBMS_LOB. OPEN (int_html, DBMS_LOB. LOB_READWRITE);
DBMS_LOB. OPEN (final_html, DBMS_LOB. LOB_READWRITE);
dbms_output. ENABLE (1000000);
FOR i 1,100 loop
v_str: = "< b >" |
"< style td =" "DRESSING: break-word" width = "50" > < font size = "2" > ' | "
I have | ' < / police > < table > ' |
"< /tr >";
DBMS_LOB. WriteAppend (lob_loc = > int_html, amount = > LENGTH (v_str), BUFFER = > v_str);
END LOOP;
dbms_output.put_line (' the length of the int_html is :'||) DBMS_LOB. GetLength (int_html));
dbms_output.put_line (' the int_html :'|| is int_html).
final_html: = "< html >" | int_html | "< / html > ';
dbms_output.put_line (' the final_html :'|| is final_html).
EXCEPTION
WHILE OTHERS THEN
dbms_output.put_line(SQLCODE||) e -'|| SQLERRM);
DBMS_LOB. CLOSE (int_html);
DBMS_LOB. CLOSE (final_html);
DBMS_LOB. FREETEMPORARY (int_html);
DBMS_LOB. FREETEMPORARY (final_html);
END;
When the loop is made of lesser value, say FOR example, the loop i IN 1.10, the program works very well, but when the closure is done for values more I'm ' - 6502-ORA-06502: PL/SQL: digital error or value ' error message.
Please help me solve this problem.
Thanking you in advance.
Kind regards
SriCan you please specify what environment you run this?
I modified your code as follows
The code executed successfully until the length has been<= 32767="" i.e="" (="" until="" for="" i="" in="">=>
In addition, you must use the function APPEND to concatenate variables clob.
Please check the maximum size by default for varchar2 or dbms_output in your server since you get the error for just the loop in the range (FOR i IN 1,100).
And Yes, Siva comments are valid.
DECLARE
final_html CLOB.
int_html CLOB.
v_str VARCHAR2 (32767).i the number: = 0;
BEGIN
DBMS_LOB.CREATETEMPORARY (lob_loc-online int_html, CACHE-online TRUE, hard-online dbms_lob. CALL);
DBMS_LOB.CREATETEMPORARY (lob_loc-online final_html, CACHE-online TRUE, hard-online dbms_lob. CALL);
DBMS_LOB. OPEN (int_html, DBMS_LOB. LOB_READWRITE);
DBMS_LOB. OPEN (final_html, DBMS_LOB. LOB_READWRITE);
dbms_output. ENABLE (1000000);FOR i 1.1092 loop
v_str: = '
' || ';
'' || ' ||
I have | '
'DBMS_LOB. WriteAppend (lob_loc-int_html, amount => (v_str), BUFFER LENGTH-online v_str online);
END LOOP;
dbms_output.put_line (' the length of the int_html is :'||) DBMS_LOB. GetLength (int_html));
Start
dbms_output.put_line (' the int_html :'|| is int_html).
dbms_output.put_line (' the length of the int_html is :'||) DBMS_LOB. GetLength (int_html));
exception when others then
dbms_output.put_line(SQLCODE||) e -'|| SQLERRM);
end;
/*
Start
final_html: = ''|| int_html | »';
dbms_output.put_line (' the final_html :'|| is final_html).
exception when others then
dbms_output.put_line(SQLCODE||) e -'|| SQLERRM);
end; */EXCEPTION
WHILE OTHERS THENdbms_output.put_line(SQLCODE||) e -'|| SQLERRM);
DBMS_LOB. CLOSE (int_html);
DBMS_LOB. CLOSE (final_html);
DBMS_LOB. FREETEMPORARY (int_html);
DBMS_LOB. FREETEMPORARY (final_html);END;
Published by: Gurnani houta July 29, 2011 03:11
Published by: Gurnani houta July 29, 2011 03:14
Maybe you are looking for
-
How to use the headphones cable and load on iphone 7?
I am very interested in th new IPhone but I'm not clear on how couldn't I maintain the main use that I have now with it. In many cases, I use my headset while I load the Iphone: -audio conversation at the end of the day when the battery is low and he
-
version 32.0.2 does not load and the top bar appears fuzzy
I get a blank page and a blurry bar at the top. Impossible to click onon anything after downloading the new version. (32.0.2) I use WIN 7, Office
-
HP Pavilion a6000n: no need for replacement motherboard - it's the standard micro ATX?
I want to upgrade this computer and get a new card mother and CPU. Currently there is a M2N68-LA/NARRATED-GL8E made by Asus for HP. No matter what micro ATX motherboard will work, or that it has an odd size or placement of screw hole or else incompat
-
Satellite M60 light in case someone
HelloMy satellite m60 doesn't work. Specifically, after work I go to winXP pro--> power off early. Today I try to switch on my laptop, I push the button to start it, first of all, light start button lights up for about 5 seconds and after crossing th
-
Unable to connect to the internet via 3G or WiFi on Satellite A110-178
I am not able to connect to internet with my 3G modem or wireless.Error messages said I should check the settings or that it is impossible to find connections. When I turn on the computer, I noticed that it takes longer than usual and there is an err