Synchronous processes within pl/sql
Is there a directive or some mechanism within pl/sql where you can kick-off a process and not have to wait for it to complete in order to continue your main procedure?
I am thinking of this scenario for a pl/sql procedure (in simple terms):
1. Build a cursor to retreive records.
2. Within a loop, bulk collect 100 of the records into a collection.
3. If result set is not empty, send those 100 records off to be processed in a called procedure.
4. Without waiting for the called procedure to complete, bulk collect another 100 records and send those off to be processed.
5. End the loop and the main procedure when the result set returned is empty. The spawned procedures may or may not still be executing.
I know you can do this in Java, but I want to do it in Pl/SQL (10g).
Any ideas?
http://djmein.blogspot.com/2009/08/generate-days-in-month-pipelined.html
Similar Messages
-
Using OS Commands within PL/SQL
How can I use Operating system commands from within PL/SQL procedures or functions? Kindly explain with an example.
Thanx,
SBPreviously we have used external procedures to use Windows kernel32.dll to start an external program. However this does not work on Oracle9i.
Instead I have modified an example in Java to acceive this. The following class can start an external program either synchronously or asynchronously and in synchronous mode it will return the programs output.
import java.io.*;
import java.util.*;
public class util
// Executes an operating system command. The command shall be fully qualified.
// The Java connects with silent login. No environment set-up files are run
// and no path is set. The mode can be "sync" or "async" for respectively
// synchronous and asynchronous execution
static public int OSCmd(String cmd, String mode, String[] output)
throws IOException, InterruptedException
System.out.println("OSCmd "+cmd+" ("+mode+")");
output[0]="";
// start command
Process proc = Runtime.getRuntime().exec(cmd);
if (mode.equals("sync"))
// get command's stdout and stderr
InputStream stdout = proc.getInputStream();
InputStream stderr = proc.getErrorStream();
String str;
// Stdout
BufferedReader br = new BufferedReader(new InputStreamReader(stdout));
while ((str = br.readLine()) != null)
output[0]+=str+"\n";
br.close();
// Stderr
br = new BufferedReader(new InputStreamReader(stderr));
while ((str = br.readLine()) != null)
output[0]+=str+"\n";
br.close();
// wait for command to terminate
proc.waitFor();
return proc.exitValue();
return 0;
You need the following permissions:
call dbms_java.grant_permission('COMMON', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'execute');
call dbms_java.grant_permission('COMMON', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
call dbms_java.grant_permission('COMMON', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
And then create the Java stored procedure:
create or replace function os_cmd2(p_cmd varchar2, p_mode varchar2, p_output in out varchar2) return number
as language java
name 'util.OSCmd(java.lang.String, java.lang.String, java.lang.String[]) return int'; -
How To Use a Hidden Page Item within an SQL Report Query without Submitting
Hi,
Using: Oracle ApEx 3.0.1
I have an sql report region that contains a hidden page item as part of the "where clause". My problem is, based on a value entered by the user, I need to assign this value enetered to my hidden item, so that it can be used within the where condition of my sql but this would need to be done without actually submitting the form.
At the moment, I can set the value via an on-demand process but my SQL is still not returing any values as the hidden page item within the query is not set (as page has not been submitted).
Can anybody please assist as I am not sure how to do this and whether in actual fact, this is possible to do, without having submitted the page.
Thanks.
Tony.
Edited by: Tony F. on Nov 12, 2011 1:39 AMYou can set a session value using a dummy ajax call e.g:
Add the following to the 'Function and Global Variable Declaration' region
function f_set_item(pThis){
var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=dummy',1);
get.add('P1_ID',pThis.value)
gReturn = get.get();
get = null;
}Where P1_ID is the session value to be set. Then call the function in the usual way e.g.
javascript:f_set_item(this);
I hope that helps
Shunt -
Dynamic SQL within a SQL Query ?
is there any possibility to do like this ?
SELECT table_name, XXXXXXXX('SELECT Count(*) FROM '||table_name) tot_rows
FROM dba_tables
WHERE owner = 'SCOTT';or any other trick to run dynamic SQL within the SQL Query?
Hoping....that it should be.
Regards,
OrapdevOne small disadvantage: it is executing 202 SQL statements: 3 "user SQL statements" (the one above and the 2 "select count(*)..."), and 199 internal ones ...How did you get to those numbers?
I just traced this statement and found completely different results:
TKPROF: Release 10.2.0.3.0 - Production on Tue Jul 10 12:12:10 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Trace file: diesl10r2_ora_5440.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
declare cursor NlsParamsCursor is SELECT * FROM
nls_session_parameters;begin SELECT Nvl(Lengthb(Chr(65536)),
Nvl(Lengthb(Chr(256)), 1)) INTO :CharLength FROM dual; for NlsRecord in
NlsParamsCursor loop if NlsRecord.parameter = 'NLS_DATE_LANGUAGE' then
:NlsDateLanguage := NlsRecord.value; elsif NlsRecord.parameter =
'NLS_DATE_FORMAT' then :NlsDateFormat := NlsRecord.value; elsif
NlsRecord.parameter = 'NLS_NUMERIC_CHARACTERS' then
:NlsNumericCharacters := NlsRecord.value; elsif NlsRecord.parameter =
'NLS_TIMESTAMP_FORMAT' then :NlsTimeStampFormat := NlsRecord.value;
elsif NlsRecord.parameter = 'NLS_TIMESTAMP_TZ_FORMAT' then
:NlsTimeStampTZFormat := NlsRecord.value; end if; end loop;end;
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 1
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
SELECT NVL(LENGTHB(CHR(65536)), NVL(LENGTHB(CHR(256)), 1))
FROM
DUAL
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.01 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
total 3 0.01 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
1 FAST DUAL (cr=0 pr=0 pw=0 time=7 us)
SELECT *
FROM
NLS_SESSION_PARAMETERS
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 17
total 3 0.00 0.00 0 0 0 17
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
17 FIXED TABLE FULL X$NLS_PARAMETERS (cr=0 pr=0 pw=0 time=124 us)
select PARAMETER,VALUE
from
nls_session_parameters where PARAMETER in('NLS_NUMERIC_CHARACTERS',
'NLS_DATE_FORMAT','NLS_CURRENCY')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 3
total 3 0.00 0.00 0 0 0 3
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
3 FIXED TABLE FULL X$NLS_PARAMETERS (cr=0 pr=0 pw=0 time=57 us)
select to_char(9,'9C')
from
dual
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 0 0 1
total 3 0.00 0.00 0 0 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
1 FAST DUAL (cr=0 pr=0 pw=0 time=2 us)
SELECT table_name,
DBMS_XMLGEN.getxmltype ('select count(*) c from ' || table_name).EXTRACT
('//text').getstringval
() tot
FROM dba_tables
WHERE table_name IN ('EMP', 'DEPT') AND owner = 'SCOTT'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.01 0.02 0 48 0 2
total 3 0.01 0.02 0 48 0 2
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50
Rows Row Source Operation
2 HASH JOIN (cr=42 pr=0 pw=0 time=2952 us)
2 MERGE JOIN CARTESIAN (cr=42 pr=0 pw=0 time=1206 us)
2 NESTED LOOPS OUTER (cr=42 pr=0 pw=0 time=478 us)
2 NESTED LOOPS OUTER (cr=36 pr=0 pw=0 time=421 us)
2 NESTED LOOPS OUTER (cr=30 pr=0 pw=0 time=379 us)
2 NESTED LOOPS OUTER (cr=30 pr=0 pw=0 time=365 us)
2 NESTED LOOPS (cr=22 pr=0 pw=0 time=312 us)
2 NESTED LOOPS (cr=16 pr=0 pw=0 time=272 us)
2 NESTED LOOPS (cr=8 pr=0 pw=0 time=172 us)
1 TABLE ACCESS BY INDEX ROWID USER$ (cr=2 pr=0 pw=0 time=56 us)
1 INDEX UNIQUE SCAN I_USER1 (cr=1 pr=0 pw=0 time=30 us)(object id 44)
2 INLIST ITERATOR (cr=6 pr=0 pw=0 time=111 us)
2 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=6 pr=0 pw=0 time=87 us)
2 INDEX RANGE SCAN I_OBJ2 (cr=4 pr=0 pw=0 time=54 us)(object id 37)
2 TABLE ACCESS CLUSTER TAB$ (cr=8 pr=0 pw=0 time=98 us)
2 INDEX UNIQUE SCAN I_OBJ# (cr=4 pr=0 pw=0 time=26 us)(object id 3)
2 TABLE ACCESS CLUSTER TS$ (cr=6 pr=0 pw=0 time=39 us)
2 INDEX UNIQUE SCAN I_TS# (cr=2 pr=0 pw=0 time=13 us)(object id 7)
2 TABLE ACCESS CLUSTER SEG$ (cr=8 pr=0 pw=0 time=37 us)
2 INDEX UNIQUE SCAN I_FILE#_BLOCK# (cr=4 pr=0 pw=0 time=21 us)(object id 9)
0 INDEX UNIQUE SCAN I_OBJ1 (cr=0 pr=0 pw=0 time=4 us)(object id 36)
2 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=6 pr=0 pw=0 time=33 us)
2 INDEX UNIQUE SCAN I_OBJ1 (cr=4 pr=0 pw=0 time=23 us)(object id 36)
2 TABLE ACCESS CLUSTER USER$ (cr=6 pr=0 pw=0 time=28 us)
2 INDEX UNIQUE SCAN I_USER# (cr=2 pr=0 pw=0 time=12 us)(object id 11)
2 BUFFER SORT (cr=0 pr=0 pw=0 time=716 us)
1 FIXED TABLE FULL X$KSPPI (cr=0 pr=0 pw=0 time=661 us)
1436 FIXED TABLE FULL X$KSPPCV (cr=0 pr=0 pw=0 time=1449 us)
select count(*) c
from
EMP
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 1 0 1
total 4 0.00 0.00 0 1 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
Rows Row Source Operation
1 SORT AGGREGATE (cr=1 pr=0 pw=0 time=96 us)
14 INDEX FULL SCAN EMP_IDX (cr=1 pr=0 pw=0 time=46 us)(object id 61191)
select metadata
from
kopm$ where name='DB_FDO'
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.00 0 2 0 1
total 3 0.00 0.00 0 2 0 1
Misses in library cache during parse: 0
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
1 TABLE ACCESS BY INDEX ROWID KOPM$ (cr=2 pr=0 pw=0 time=42 us)
1 INDEX UNIQUE SCAN I_KOPM1 (cr=1 pr=0 pw=0 time=22 us)(object id 365)
select count(*) c
from
DEPT
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 1 0 1
total 4 0.00 0.00 0 1 0 1
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 50 (recursive depth: 1)
ALTER SESSION SET sql_trace=FALSE
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Parsing user id: 50
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 5 0.00 0.00 0 0 0 0
Execute 5 0.00 0.00 0 0 0 1
Fetch 3 0.01 0.02 0 48 0 6
total 13 0.01 0.03 0 48 0 7
Misses in library cache during parse: 0
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 5 0.00 0.00 0 0 0 0
Execute 5 0.01 0.00 0 0 0 0
Fetch 7 0.00 0.00 0 4 0 21
total 17 0.01 0.00 0 4 0 21
Misses in library cache during parse: 0
9 user SQL statements in session.
1 internal SQL statements in session.
10 SQL statements in session.
Trace file: diesl10r2_ora_5440.trc
Trace file compatibility: 10.01.00
Sort options: default
1 session in tracefile.
9 user SQL statements in trace file.
1 internal SQL statements in trace file.
10 SQL statements in trace file.
10 unique SQL statements in trace file.
132 lines in trace file.
0 elapsed seconds in trace file.I only see a ratio of 1:9 for user- to internal SQL statements?
michaels> select * from v$version
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production -
Spawning multiple Processes in PL/SQL Block
Hi All
Does anyone know if it is possible within PL/SQL block to 'spawn' multiple versions of a procedure as parallel processes.
What I would like to do is something like
WHILE x = 'CONTINUE LOOP
load process1...load process2..load process3.
I could create a UNIX script to run the procedure as a background process multiple times but I would prefer to use PL/SQL solution if one exists.
Many thanks inadvanceHi Martin,
you should have a look into the package "dbms_Job". With the routines in this package it is possible to submit the execution of stored procedures by the Oracle job scheduler.
If you are in 10g you could alternatively use the "dbms_Scheduler" package.
Have a nice day.
Björn Hachmann -
System command from within PL/SQL on server ?
Hi
I know its a bit weird thought of executing an NT system command from within PL/SQL on server (UNIX).
Has anyone done something (silly me!) like it or knows any work-around to try something like it?
Thanks in advance.
Regards
PraveshCan you be more specific?
Generally to run system commands you utilize DBMS_PIPE to communicate with a listener on the platform that you're accessing. That listener picks up the pipe request and might either:
1. spawn a process to run the command
2. fork a process to run the command
3. run the command within its own application.
It sounds complex, but if review the DBMS_PIPE documentation and it's not too difficult -- presuming you know a language like C.
I believe there are other features in 8.1.5 and higher versions that enable you to run stored programs or COM objects...
Bill -
How to trace an ApEx page processes(anonymous PL/SQL) submited by any user?
Dear Friends;
can I trace an ApEx page processes (anonymous PL/SQL code step by step) submitted by any user?
could you explain in detail, please?
regards
Siya
Edited by: sak on Feb 3, 2012 1:07 AMHello
You can get user id using select v('APP_USER') FROM DUAL or simply :APP_USER.
Zulqarnain
MaxApex Hosting
http://www.maxapex.com -
Invoking BPEL Process through pl/sql is failing
Hi all,
I am trying to invoke BPEL process through PL/SQL and its throwing following error.
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><env:Fault xmlns="http://xmlns.oracle.com/pcbpel/adapter/file/ReadFile/"><faultcode xmlns="">null:Read_ptt</faultcode><faultstring xmlns="">Cannot figure out operation name. Bad SOAPAction or wsa:Action.</faultstring><faultactor xmlns="">initiate</faultactor></env:Fault></env:Body></env:Envelope>
Following is code I am using to invoke BPEL PROCESS
declare
soap_request varchar2(30000);
soap_respond varchar2(30000);
http_req utl_http.req;
http_resp utl_http.resp;
begin
soap_request:='<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header/>
<soap:Body xmlns:ns1="http://xmlns.oracle.com/pcbpel/adapter/file/ReadFile/">
--<ns1:Read_plt><ns1:input>leeg</ns1:input></ns1:Read_plt>
</soap:Body>
</soap:Envelope>';
http_req:= sys.utl_http.begin_request('http://localhost/orabpel/default/BPELProcess1/v2007_12_03__65618','POST','HTTP/1.1' );
sys.utl_http.set_header(http_req, 'Content-Type', 'text/xml') ;
sys.utl_http.set_header(http_req, 'Content-Length', length(soap_request)) ;
sys.utl_http.set_header(http_req, 'SOAPAction', 'initiate');
sys.utl_http.write_text(http_req, soap_request) ;
http_resp:= sys.utl_http.get_response(http_req) ;
sys.utl_http.read_text(http_resp, soap_respond) ;
sys.utl_http.end_response(http_resp) ;
dbms_output.put_line(soap_respond);
end;
Any help would be appriciated.
Thanks,
VipulHi,
Switching on or off a bpel is an admin job.
u can stop an application but not one bpel.
I doubt if there is any way to do it programatically.
Let us get other opinons
Regards -
Third Party Business Process Within Purchasing /IM(Without SD)
Hi Friends,
We are planning to implement third party order process within Purchasing to procure the office stationary materials for the business.
The problem here is how to deal with the materials returns to supplier after original invoice is processed?.
1. Requisition created
2. PO created in 30-Jan-2007
3. Material supplied and Goods Receipt done. in 31-Jan
4. Vendor submits invoice to Payable section and Invoice also processed
till 31st Jan-07
5. Now user would like to return the materials to vendor for wrong material or poor quality on <b>1st Feb</b>. Since invoice is already processed... how to account this returns in next invoice payment is the question.
I tried looking for the above business scenario(material returns) in various places, but no luck. Appreciate, if you could give me pdf relevant to above process or suggest possible solution.
Regards
KKHi Stev,
Many thanks for your prompt response. I do agree that this process should be done through normal PR/PO with account assignment for direct consumption's.
In my view, Third party through SD will have more advantage in billing the customer apart from vendor invoice. Without SD, we can still take the advantage of third Party process, in terns of user address management(mandatory) in the PR and analysis point of view. Conceptually they do serve the purpose more or less same within Purchasing without SD.
The problem here in the both the process is invoice processing, as huge amount of PR/PO will be raised for low value items ranging from $10 to $300. Vendor will be submitting the consolidated invoice by weekly or monthly. Since MIRO only provides PO creation date and not GR/Movements Posting date in the selection criteria, it would be quite difficult to include the GR reversals/returns, after the original invoice processed for the order created in previous period. Moreover, this will increase the workload on Accounts payables in entering invoices for small amount.
The above is the situation for explained case.
1. Invoice Processed for the Pur.Orders created in Jan-07(One inv against many po's)
2. Reversals/Returns of material taken place on 1st -Feb for the same order which is created and paid in Jan.
Only solution I could think of is to enable ERS and generate invoice GR based. This would cater for Invoice processing and credit memo for reversals/returns.
However, appreciate, if you could share your expertise to overcome the issue and give your valuable comments on the process.
Regards
Kumar -
Problem with getting back "synchronous" process result!!!
i have created the partner link to my synchronous process which is already on the server, along with the input and output variable for dealing with that particular process...
my input variable matches the xml schema of my synchronous process... when i expand the input variable node, i can see the elements which i'm trying to pass as the input to my synchronous server.
HOWEVER!!! there's a problem with my output variable, clicking expand on the node, it displays nothing (basically it's suppose to be in the format of the xml schema which i have specified).. hence i cannot work with the output of the asynchronous process...
cheers,
Shivek
how do i fix this problem..can you please provide little bit more details? where do you click output variable? are you clicking from bpel console debugger?
-
Calling Synchronous process in a loop
Hi
I am facing a problem while I am tring to call Synchronous process in a loop. I am having a parent process that fetch batches numbers (list of batches) and loop for each of them and call a child Synchronous process to do some activity.
the issue here is that the output variable on the process is taking the value that returns from the first batch call and keep repeating it for all the rest batches. I tried to initialize it to null every time I am entring the loop but strangly it has been overrided with the output variable of the first batch and then for the rest it just initialized to null and not had been overriden.
any body face this before or knows about it
thanks and best regards,
BaraaThis is Arun (working with Baraa in same Company)
Let me eloborate the situvation
Facing problem while I call a Sync process from an Async process using while loop.
When I call sync child multiple times from a parent process using a While loop the response msg from child process is not correct.
Meaning for instance let say
Parent process : P
Child processes : C1, C2, C3 (assuming the loop goes for three iteration)
The expected response msg of the individual process where
C1: 10000
C2: 999
C3 : (null)
But when I go through the audit of the parent process I could see all responses as 10000, meaning the response of the child process is not getting reflected in Parent process correctly
Whereas when I inspect individual child process response; I could see the correct values.
Note: I am using End Point Reference technique to call the child process
Any Idea.
Requirement:
Parameter: Source System Name
(this parameter decides which child to call, basically this will be the SERVICE on WSDL pointing to the child process)
A parent Async process has to call a Sync child process “n” number of times (“n” get derived at run time) WHILE loop
The parent will decide which child process to call at runtime (Dynamic call using EndPointReference)
Some thing like below:
<Set END POINT REFERENCE>
<WHILE>
Invoke Child (synchronize process)
<END LOOP> -
Calling an On Demand Process in PL/SQL Region without using AJAX
Hi!
I am trying to find a way to call an On demand Process in a PL/SQL Reports Region. The reason is that i need Reportings for about 20 Pages that look like the same but have different parameters. I already have some Processes that return SQL Statements and it works fine. But these Reportings are more complex and it's not possible to return it wirh a SQL Statement.
I have seen some solutions in this forum that used AJAX to call such a process. The problem is, that I'm not allowed to use AJAX because activeX is diabled. I tried it and it works but i need another way to solve this process call.
Thanks in advance
PhilippAt the moment I cannot say if your link can help. Right now the call of the On demand Process looks like this:
Inside annonymous PL/SQL Region:
<script type="text/javascript">
get = new htmldb_Get(null,'||:APP_ID||'.,'APPLICATION_PROCESS=F_REPORT_NAME',0);
gReturn = get.get();
document.write(gReturn);
</script> -
SEQUENCE Select within an SQL Query with an ORDER BY statement
Does anyone know why you cannot use an ORDER BY statement within an SQL query when also selecting from a SEQUENCE? My query was selecting production data as a result of a filtered search. I want to take the results of the filtered search and create a transaction. I have a sequence for generating transaction numbers where I select NEXTVAL. Since I could possibly obtain multiple, yet distinct, rows based upon my search criteria, I wanted to use an ORDER BY statement to simplify and order the resulting row(s).
I was able to get the SQL select with SEQUENCE.NEXTVAL to work without the ORDER BY, so I know that my SQL is correct. Thanks in-advance.Okay,
I understand. You want the sequence assigned first and the you want to ORDER BY. You
can do this using pipelined functions. See here:
CREATE OR REPLACE TYPE emp_rec_seq AS OBJECT (
seq NUMBER,
ename VARCHAR2 (20),
job VARCHAR2 (20),
sal NUMBER
CREATE OR REPLACE TYPE emp_tab_seq AS TABLE OF emp_rec_seq;
CREATE OR REPLACE FUNCTION get_emp_with_sequence
RETURN emp_tab_seq PIPELINED
IS
my_record emp_rec_seq := emp_rec_seq (NULL, NULL, NULL, NULL);
BEGIN
FOR c IN (SELECT dummy.NEXTVAL seq, ename, job, sal
FROM emp)
LOOP
my_record.seq := c.seq;
my_record.ename := c.ename;
my_record.job := c.job;
my_record.sal := c.sal;
PIPE ROW (my_record);
END LOOP;
RETURN;
END get_emp_with_sequence;after that, you can do a select like this:
SELECT seq, ename, job, sal
FROM TABLE (get_emp_with_sequence)
order by enamewhich will get you this:
SEQ ENAME JOB SAL
1053 BLAKE MANAGER 2850
1054 CLARK MANAGER 2450
1057 FORD ANALYST 3000
1062 JAMES CLERK 950
1055 JONES MANAGER 2975
1052 KING MANAGER 20000
1060 MARTIN SALESMAN 1250
1063 MILLER CLERK 1300
1064 DKUBICEK MANAGER 12000
1056 SCOTT ANALYST 3000
1058 SMITH CLERK 800
1061 TURNER SALESMAN 1500
1059 WARD SALESMAN 1250Denes Kubicek
http://deneskubicek.blogspot.com/
http://htmldb.oracle.com/pls/otn/f?p=31517:1
------------------------------------------------------------------- -
Looking to configure a Late payment process within Collections
I am looking to implement a follow-on late payment process within the Collections Management process for past due invoices. Has anyone done this before and if so any considerations or challenges to the process? Basically as invoices fall in arrears the specialist would have the ability to create a debit memo request in reference to the late invoice for a percentage of the open amount. This would be within the Process Receivables tab. It would go through an approval process and as approved would become a debit memo for the "late payment" with reference to the debit memo request.
Any thoughts?I would look at what you can achieve in the standard FI-AR Interest process.
I dont believe there is functionality in Collections Management for this. One of the main processes is to not update FI-AR from Collections Management.
You do have the ability to add function buttons into Collections Management (Process receivables) after Enhancement Package 5 -
This question sound funny. I just want to make sure this rule. In Oracle database before 10g, we can only use DML and transaction control code within PL/SQL block. We can not use DDL or other control languages within PL/SQL block. How about 10g? can I use DDL in PL/SQL block in 10g?
I have created a procedure to drop all materialized view. Drop object is DDL. I used a piece of code like this:
v_sql_stmt1 := 'DROP MATERIALIZED VIEW'||v_schema||'.'||x.mview_name;
EXECUTE IMMEDIATE v_sql_stmt1;
The procedure was compiled successfully. However, when I run this SP, it generate ORA-00905 missing keyword error on EXECUTE IMMEDIATE statement part. Is this caused by missing keyword in sql statement or DROP as DDL can not be used in PL/SQL block? If it is first one, what is the keyword for DROP MATERIALIZED VIEW statement?The versions of Oracle that run on this planet have been able to do DDL in PL/SQL for quite some time now. The DBAs who blasted off into space with you and worked in a vacuum the past however many years you feel you've been limited by this need to be replaced or re-introduced to Oracle.
For what it's worth, the error looks like you're missing a space.
Maybe you are looking for
-
Can no longer scroll to view my messages..anyone know how to fix this??
To view email - I can no longer srcoll using the two fingers on the pad to scroll my mail. Have to delete the previous message to see new ones. Need a FIX!
-
So as far as i know, to get the computer to run in lid closed mode you press f7 until you get video mirroring, the second mode i believe, close the display, then wake the computer with the external mouse or keyboard. I've done this, but almost as soo
-
Nonstock material PO value should not allow to change once it picked fromPR
Hi There, when create PO for non stock material it will pick price from PR to PO once it pick the value again it should not allow to change. so what ever value is there in PR same should be in PO also even if we try to change PO value system should n
-
Different pricing procedure in delivery
Dear All, In STO scenario we are sending material from mfg plant to Depots, Sales area defined for STO 1001,20,PP where till now we have used only one pricing procedure in Delivery(NL) & Billing (F8), but due to business requirement we want maintain
-
[solved] xfce keyboard shortcuts won't work, tried arch wiki solution
Keyboard shortcuts defined in the xfce's keyboard settings don't work, as described in the wiki: http://wiki.archlinux.org/index.php/Xfc - 7t_working When I kill xfce4-settings-helper the shortcuts work again. After restarting X the problem returns.