Update records using Pl/Sql procedure
Hi
I have wriitten a stored procedure to update the Organisation_Name in a table based on the Full_Org_Nm of an another table.
Though the procodure got executed sucessfully but it is not updating the records.
I even tried executing the procedure by writing Execute <Procedure name>,the database got hanged.
Please find my procedure below.
Create or Replace
PROCEDURE UPDT_ISSUE_USR_ROLE
As
Cursor cur_user_role Is
Select a.org_id,a.user_id
from prts_user a,issue_user_role b
where a.user_id=b.user_id;
v_rows_processed Number:=0;
Begin
For rec in cur_user_role Loop
update Issue_user_role
set User_org_nm=(Select full_org_nm from VW_Org where org_id=rec.org_id)
Where Issue_User_Role.rowid in
(select issue_user_role.rowid
FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
Where Issue_User_Role.Issue_Id=Issue.Issue_id
And Issue_User_Role.Issue_id=issue_workflow.issue_id
And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
And Issue.Issue_id=Issue_workflow.Issue_Id
And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And issue_workflow.primry_workflow_flag='Y'
And issue_user_role.user_id = rec.user_id
And issue.issue_status_id in (1636,50738,275,50737,2090)
And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
End Loop;
COMMIT;
dbms_output.enable;
dbms_output.put_line('There were '||v_rows_processed||' rows updated');
End;
Please let me know where i am wrong.
Thanks in advance.
Cheers
Hi Blushadow
Now if i want to update say only 10 records at a time what should i put into my Proc?
Please go thru my Proc below..
CREATE OR REPLACE PROCEDURE PRTS.UPDT_ISSUE_USR_ROLE
As
Cursor cur_user_role Is
Select a.org_id,a.user_id
from prts_user a,issue_user_role b
where a.user_id=b.user_id;
upd_rec cur_user_role%rowtype;
v_rows_processed Number:=0;
Begin
Open cur_user_role;
Loop
Fetch cur_user_role into upd_rec;
If cur_user_role%NOTFOUND
Then
Exit;
Else
update Issue_user_role
set User_org_nm=(Select full_org_nm from VW_Org where org_id=upd_rec.org_id)
Where Issue_User_Role.rowid in
(select issue_user_role.rowid
FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
Where Issue_User_Role.Issue_Id=Issue.Issue_id
And Issue_User_Role.Issue_id=issue_workflow.issue_id
And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
And Issue.Issue_id=Issue_workflow.Issue_Id
And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And issue_workflow.primry_workflow_flag='Y'
And issue_user_role.user_id = upd_rec.user_id
And issue.issue_status_id in (1636,50738,275,50737,2090)
And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
If Mod (v_rows_processed,v_rows_processed)=10
then
COMMIT;
End if;END IF;
End Loop;
Commit;
dbms_output.enable(1000000);
dbms_output.put_line('There were '||v_rows_processed||' rows updated');
Close cur_user_role;
End;
I would appreciate if you can let me know any other alternative way to meet this requirment.
Cheers
Vineet
Similar Messages
-
Reading Text file & Updating table using PL SQL Procedure
Guys, I am trying to read data from a large text file which
contains tab delimited data. Based on success of validations, I
have to insert/update data in to table(s). Does any one has any
sample procedure to read data (tab delimted/comma seperated)
from a text file and write to database table? Your help is
greatly appreciated!Is there any particular reason why you're not using SQL*Loader
for this? Otherwise you would seem to be re-inventing the wheel.
rgds, APC -
Display data in log file using PL/SQL procedure
Just as srw.message is used in Oracle RDF Reports to display data in log file in Oracle Apps, similarly how it is possible to display data in log file using PL/SQL procedure?
Please also mention the syntax too.Pl post details of OS, database and EBS versions.
You will need to invoke the seeded FND_LOG procedure - see previous discussions on this topic
Enable debug for pl/sql
https://forums.oracle.com/forums/search.jspa?threadID=&q=FND_LOG&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
HTH
Srini -
How to insert BLOB datatype image using PL/SQL Procedure and SQL Loader
Hi,
How to insert an image into database using PL/SQL Procedure and also how to insert using SQL Loader. Please help by giving sample code and process description.
Thanks,
Vijay Vhttp://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:232814159006
-
Retrive perticular mail using PL-SQL procedure
Hi all,
Anyone knows, how to retrive mails from outlook using PL-SQL procedure?
Thanks and Regards
NilayThe Java library needed by UTL_TCP is not created properly. You may just run $ORACLE_HOME/rdbms/admin/initplsj.sql as SYS to install it:
cd $ORACLE_HOME/rdbms/admin
sqlplus sys/<sys-password> @initplsj.sql -
How can i return object from oracle in my java code using pl/sql procedure?
How can i return object from oracle in my java code using pl/sql procedure?
And How can i returned varios rows fron a pl/sql store procedure
please send me a example....
Thank you
nullyes, i do
But i can't run this examples...
my problem is that i want recive a object from a PL/SQL
//procedure callObject(miObj out MyObject)
in my java code
public static EmployeeObj callObject(Connection lv_con,
String pv_idEmp)
EmployeeObj ret = new EmployeeObj();
try
CallableStatement cstmt =
lv_con.prepareCall("{call admin.callObject(?)}");
cstmt.registerOutParameter(1, OracleTypes.STRUCT); // line ocurr wrong
//registerOutParameter(int parameterIndex, int sqlType,String sql_name)
cstmt.execute();
ret = (EmployeeObj) cstmt.getObject(1);
}//try
catch (SQLException ex)
System.out.println("error SQL");
System.out.println ("\n*** SQLException caught ***\n");
while (ex != null)
System.out.println ("SQLState: " + ex.getSQLState ());
System.out.println ("Message: " + ex.getMessage ());
System.out.println ("Vendor: " + ex.getErrorCode ());
ex = ex.getNextException ();
System.out.println ("");
catch (java.lang.Exception ex)
System.out.println("error Lenguaje");
return ret;
Do you have any idea? -
Update record using SQL statement
I have VB6.0 and Oracle 10G Express Edition in Windows 2000 Server. My procedure in VB 6.0 can't update record in the table using SQL statement, and the Error Message is " Missing SET keyword ".
The SQL statement in VB6.0 look like this :
General Declaration
Dim conn as New ADODB.Connection
Dim rs as New ADODB.Recordset
Private Sub Command1_Click()
dim sql as string
sql = " UPDATE my_table " & _
" SET Name = ' " & Text3.Text & " ' " & _
" AND Unit = ' " & Text2.Text & " ' " & _
" WHERE ID = ' " & Text1.Text & " ' "
conn.Execute (sql)
Private Sub Form Load()
Set conn = New ADODB.Connection
conn.Open "Provider=MSDASQL;" & "Data Source=my_table;"& "User ID =marketing;" & "Password=pass123;"
I'm sorry about my language.
What's wrong in my SQL statement, I need help ........ asap
Best Regards,
/Harso AdjieThe syntax should be
UPDATE TABLE XX
SET FLD_1 = 'xxxx',
FLD_2 = 'YYYY'
WHERE ...
'AND' is improperly placed in the SET. -
How to update by using PL/SQL Records
Hi,
I want to update EMP table columns ename and empno only
from other existing table TEST_EMP
EMP table contains 14 rows.TEST_EMP table contains 3 rows.
I need to update first three rows in EMP table.
TEST_EMP DATA IS:
ENAME EMPNO
E1 1001
E2 1002
E3 1003
Following code i written to update EMP table.
DECLARE
type r is record(id emp.empno%type,
name emp.ename%type);
r1 r;
BEGIN
select ename,empno into r1 from test_emp;
FOR i IN r1.FIRST .. r1.LAST
LOOP
update emp2
set ename=r1(i).ename,
empno=r1(i).empno
WHERE empno = l_rc (i).empno;
end loop;
commit;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (SQLERRM (SQLCODE));
END;
ERROR OCCURRED:
ORA-06550: line 9, column 14:
PLS-00302: component 'FIRST' must be declared
ORA-06550: line 9, column 2:
PL/SQL: Statement ignored
I should use PL/SQL Record to update Table This is Mandatory.
pls guide me.
Regards,
Venkat.> I want to update EMP table columns ename and empno only
from other existing table TEST_EMP
Why use PL/SQL and why use cursors?
You are running a SELECT on the source table via the SQL engine and pulling that data from the db buffer cache into PL/SQL variables.
Then you take that very same data, and push that back to the SQL engine using an UPDATE.
So if you need to update 10KB worth of data, it means pulling 10KB from the SQL engine into the PL engine.. and then pushing 10KB of data from the PL engine back to the SQL engine.
Not only pushing and pulling - you need your code to switch continually between the PL and SQL engines to do this.
Now imagine doing it for 10MB of data.. or 1GB of data.. or more.
Does it sound like your approach is effective? Does it sounds like it will perform well? Does it sound like it will scale?
The basic rule for Oracle development is:
Maximize SQL. Minimize PL/SQL (or Java or C#, etc). -
Unable to update BPEL workflow task using pl/sql procedure
All,
I am on a project which involves APEX/BPEL integration. There is a need to update a workflow task created using pl/sql block of code.
This uses the out of the box TaskQueryService webservice calls and I am getting the below exception.
7,380> <ERROR> <default> <::>
<2009-11-02 04:21:37,380> <ERROR> <default> <::> Cipher decryption error.
<2009-11-02 04:21:37,380> <ERROR> <default> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
<2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
ORABPEL-00007
As an alternative I tried to call the procedure from a Java client and it throws the same exceptions (the workflow context is gotten from the Java API call
workflowContext = taskQueryService.authenticate(WF_MANANAGER_UN, WF_MANANAGER_PW, null, worklistUser);),
however updating the Task from Java using the ora.bpel library API's works perfectly fine.
But the client's requirement is to update taskoutcome from pl/sql.
Please find the exceptions and the code below............. your help is much appreciated.
Procedure Code and details exceptions below...........:
REATE OR REPLACE PROCEDURE PR_UPDATE_TASK_FLOW (P_CONTEXT VARCHAR2, P_TASK_ID VARCHAR2)
AS
soap_respond VARCHAR2(30000);
http_req UTL_HTTP.REQ;
http_resp UTL_HTTP.RESP;
launch_url VARCHAR2(240);
l_task_id varchar2(200) := '01647e0505013d7c:25e029b2:124ae1076ef:-7d29';
l_context varchar2(2000) := '9xReYA5T2NJegzDAVBQl8qNFjFxETMKVK6Y7L5Tz+ZmEG/Mu3BIfABrZG4UeLDlSqqFy/nvYWsjhPoDR+qdgoMBgfEhokt93rPOA/tChlGcI2lOCp5ww0FqKdjii99QFjOjO3c9Vqwghax2h+IvK0hWshBja0lecuc05epm6gpiHt3FFKILOMXbmZ6nR3P+eRAhWsTR7B6FBnw3Xr5QOHQ==';
l_endpoint_url VARCHAR2(200);
l_bpel_action VARCHAR2(100);
l_soap_envelop VARCHAR2(2000) := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://xmlns.oracle.com/bpel/workflow/taskService">
<updateOutcomeOfTasks xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">
<workflowContext xmlns="http://xmlns.oracle.com/bpel/workflow/common">
<token xmlns="http://xmlns.oracle.com/bpel/workflow/common">P_CONTEXT</token>
</workflowContext>
<taskId xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">P_TASK_ID</taskId>
<outcome xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">COMPLETE</outcome>
</updateOutcomeOfTasks>
</soap:Body>
</soap:Envelope>';
BEGIN
HTTP_REQ:= UTL_HTTP.BEGIN_REQUEST
TRIM('http://soaapn1.mrc.co.la.ca.us:7777/integration/services/TaskService/TaskServicePort')
,'POST'
,'HTTP/1.1'
UTL_HTTP.SET_HEADER(http_req, 'Content-Type', 'text/xml') ;
UTL_HTTP.SET_HEADER(http_req, 'Content-Length', LENGTH(l_soap_envelop)) ;
UTL_HTTP.SET_HEADER(http_req, 'SOAPAction', 'updateOutcomeOfTasks');
UTL_HTTP.WRITE_TEXT(http_req, l_soap_envelop) ;
http_resp:= UTL_HTTP.GET_RESPONSE(http_req) ;
UTL_HTTP.READ_TEXT(http_resp, soap_respond) ;
UTL_HTTP.END_RESPONSE(http_resp) ;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line(sqlerrm);
END PR_UPDATE_TASK_FLOW;
EXCEPTION MESSAGE:
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> ORABPEL-30504
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service.
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service for user {0}. {1}
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Check the underlying exception and correct the error. Contact oracle support if error is not fixable.
7,380> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Cipher decryption error.
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
<2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
ORABPEL-00007All,
I am on a project which involves APEX/BPEL integration. There is a need to update a workflow task created using pl/sql block of code.
This uses the out of the box TaskQueryService webservice calls and I am getting the below exception.
7,380> <ERROR> <default> <::>
<2009-11-02 04:21:37,380> <ERROR> <default> <::> Cipher decryption error.
<2009-11-02 04:21:37,380> <ERROR> <default> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
<2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
ORABPEL-00007
As an alternative I tried to call the procedure from a Java client and it throws the same exceptions (the workflow context is gotten from the Java API call
workflowContext = taskQueryService.authenticate(WF_MANANAGER_UN, WF_MANANAGER_PW, null, worklistUser);),
however updating the Task from Java using the ora.bpel library API's works perfectly fine.
But the client's requirement is to update taskoutcome from pl/sql.
Please find the exceptions and the code below............. your help is much appreciated.
Procedure Code and details exceptions below...........:
REATE OR REPLACE PROCEDURE PR_UPDATE_TASK_FLOW (P_CONTEXT VARCHAR2, P_TASK_ID VARCHAR2)
AS
soap_respond VARCHAR2(30000);
http_req UTL_HTTP.REQ;
http_resp UTL_HTTP.RESP;
launch_url VARCHAR2(240);
l_task_id varchar2(200) := '01647e0505013d7c:25e029b2:124ae1076ef:-7d29';
l_context varchar2(2000) := '9xReYA5T2NJegzDAVBQl8qNFjFxETMKVK6Y7L5Tz+ZmEG/Mu3BIfABrZG4UeLDlSqqFy/nvYWsjhPoDR+qdgoMBgfEhokt93rPOA/tChlGcI2lOCp5ww0FqKdjii99QFjOjO3c9Vqwghax2h+IvK0hWshBja0lecuc05epm6gpiHt3FFKILOMXbmZ6nR3P+eRAhWsTR7B6FBnw3Xr5QOHQ==';
l_endpoint_url VARCHAR2(200);
l_bpel_action VARCHAR2(100);
l_soap_envelop VARCHAR2(2000) := '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://xmlns.oracle.com/bpel/workflow/taskService">
<updateOutcomeOfTasks xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">
<workflowContext xmlns="http://xmlns.oracle.com/bpel/workflow/common">
<token xmlns="http://xmlns.oracle.com/bpel/workflow/common">P_CONTEXT</token>
</workflowContext>
<taskId xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">P_TASK_ID</taskId>
<outcome xmlns="http://xmlns.oracle.com/bpel/workflow/taskService">COMPLETE</outcome>
</updateOutcomeOfTasks>
</soap:Body>
</soap:Envelope>';
BEGIN
HTTP_REQ:= UTL_HTTP.BEGIN_REQUEST
TRIM('http://soaapn1.mrc.co.la.ca.us:7777/integration/services/TaskService/TaskServicePort')
,'POST'
,'HTTP/1.1'
UTL_HTTP.SET_HEADER(http_req, 'Content-Type', 'text/xml') ;
UTL_HTTP.SET_HEADER(http_req, 'Content-Length', LENGTH(l_soap_envelop)) ;
UTL_HTTP.SET_HEADER(http_req, 'SOAPAction', 'updateOutcomeOfTasks');
UTL_HTTP.WRITE_TEXT(http_req, l_soap_envelop) ;
http_resp:= UTL_HTTP.GET_RESPONSE(http_req) ;
UTL_HTTP.READ_TEXT(http_resp, soap_respond) ;
UTL_HTTP.END_RESPONSE(http_resp) ;
EXCEPTION WHEN OTHERS THEN
dbms_output.put_line(sqlerrm);
END PR_UPDATE_TASK_FLOW;
EXCEPTION MESSAGE:
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> ORABPEL-30504
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service.
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Internal Error in Verification Service for user {0}. {1}
<2009-11-02 04:21:37,379> <ERROR> <default.collaxa.cube.services> <::> Check the underlying exception and correct the error. Contact oracle support if error is not fixable.
7,380> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Cipher decryption error.
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::>
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at com.collaxa.cube.util.DESService.decrypt(DESService.java:74)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> at oracle.bpel.services.workflow.verification.impl.VerificationService.decryptString(VerificationService.java:2112)
<2009-11-02 04:21:37,380> <ERROR> <default.collaxa.cube.services> <::> ... 33 more
<2009-11-02 04:21:37,381> <ERROR> <oracle.bpel.services.workflow> <::> Cipher decryption error.
Failed to decrypt cipher text with transformation "DESede/ECB/PKCS5Padding"; exception reported is Input length (with padding) not multiple of 8 bytes.
ORABPEL-00007 -
DBI Reports Using PL/SQL Procedure
Hi all,
Is there anyone who worked on Creating a DBI report using a PL/SQL Procedure.
I want to customize a Report that is using Data Source as of type PL/SQL Procedure.
Please Reply to me If anyone has any Idea on this..
Thanks in Advance..Hi Blushadow
Now if i want to update say only 10 records at a time what should i put into my Proc?
Please go thru my Proc below..
CREATE OR REPLACE PROCEDURE PRTS.UPDT_ISSUE_USR_ROLE
As
Cursor cur_user_role Is
Select a.org_id,a.user_id
from prts_user a,issue_user_role b
where a.user_id=b.user_id;
upd_rec cur_user_role%rowtype;
v_rows_processed Number:=0;
Begin
Open cur_user_role;
Loop
Fetch cur_user_role into upd_rec;
If cur_user_role%NOTFOUND
Then
Exit;
Else
update Issue_user_role
set User_org_nm=(Select full_org_nm from VW_Org where org_id=upd_rec.org_id)
Where Issue_User_Role.rowid in
(select issue_user_role.rowid
FROM issue_user_role,issue,issue_workflow,Issue_step_dtl_wrkflw
Where Issue_User_Role.Issue_Id=Issue.Issue_id
And Issue_User_Role.Issue_id=issue_workflow.issue_id
And Issue_User_Role.Workflow_compnt_id=Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID
And Issue_User_Role.Workflow_compnt_id=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And Issue_User_Role.Issue_id=Issue_Step_Dtl_wrkflw.Issue_Id
And Issue.Issue_id=Issue_workflow.Issue_Id
And Issue.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_workflow.Issue_id=Issue_Step_Dtl_Wrkflw.Issue_id
And Issue_Workflow.CURR_STEP_WORKFLOW_COMPNT_ID=Issue_Step_Dtl_wrkflw.Workflow_compnt_id
And issue_workflow.primry_workflow_flag='Y'
And issue_user_role.user_id = upd_rec.user_id
And issue.issue_status_id in (1636,50738,275,50737,2090)
And issue_step_dtl_wrkflw.Issue_step_status_id in (61248,61249,61250));
v_rows_processed :=v_rows_processed + SQL%ROWCOUNT;
If Mod (v_rows_processed,v_rows_processed)=10
then
COMMIT;
End if;END IF;
End Loop;
Commit;
dbms_output.enable(1000000);
dbms_output.put_line('There were '||v_rows_processed||' rows updated');
Close cur_user_role;
End;
I would appreciate if you can let me know any other alternative way to meet this requirment.
Cheers
Vineet -
Hello
I will explain the scenario:
In our java web page, we are using three text boxes to enter "Part number,Description and Aircraft type". Every time the user no need to enter all these data. The person can enter any combination of data or only one text box. Actually the output data corresponding to this input entries is from five Oracle table. If we are using a single query to take data from all the five tables, the database will hang. So I written a procedure "SEARCH1",this will accept any combination of values (for empty values we need to pass NULL to this procedure) and output data from all the five tables. When I executing this procedure in SQL editor, the execution is very fast and giving exact result. I used "dbms_output.put_line" clause for outputing multiple records in my procedure. The output variables are "Serial No, part Number, Description, Aircraft type,Part No1,Part No2,Part No3,Part No4". I want to use the same procedure "SEARCH1" for outputing data in java web page.The passing argument I can take from the text box provided in java web page. I am using jdbc thin driver to connect our java web page to Oracle 9i database.
Note1 : If any combination of search item not available, in procedure itself I am outputing a message like "Part Number not found". Here I am using four words ("Part" is the first word,"Number" is the second,"Not" s the third, and "found" is the fourth) for outputing this message.Is it necessary to equalise number of words I am using here to the record outputing eight variable?
Our current development work is stopped because of this issue. So any one familier in this field,plese help me to solve our issue by giving the sample code for the same scenario.
My Email-id is : [email protected]
I will expect yor early mail.
With thanks
Pramod kumar.Hello Avi,
I am trying to solve this issue by using objects. But the following part of code also throwing some warning like "PLS-00302: component must be declared". Plese cross check my code and help me to solve this issue.
drop type rectab;
create or replace type rectype as object(PartNo varchar2(30),Description varchar2(150),AIrcraft_type varchar2(15),status_IPC varchar2(30),status_ELOG varchar2(30),status_SUPCAT varchar2(30),status_AIRODWH varchar2(30));
create or replace type rectab as table of rectype;
create or replace package ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab);
end ioStructArray;
create or replace package body ioStructArray as
procedure testsch2(pno in varchar2,pdes in varchar2,air in varchar2,orec in out rectab) is
mdescription varchar2(150);
mpartnum varchar2(30);
mpno varchar2(30);
mdes varchar2(150);
mair varchar2(15);
mstat varchar2(1);
cursor c1 is select partnum,description,aircraft_type from master_catalog where partnum=mpno and aircraft_type=mair and description like ltrim(rtrim(mdes))||'%';
cursor c2 is select partnum from ipc_master where partnum=mpartnum;
cursor c3 is select partnum from fedlog_data where partnum=mpartnum;
cursor c4 is select partnum from superparts where partnum=mpartnum;
cursor c5 is select part_no from supplier_catalog where part_no=mpartnum;
mpno1 varchar2(30);
mpno2 varchar2(30);
mpno3 varchar2(30);
mpno4 varchar2(30);
mpno5 varchar2(30);
maircraft_type varchar2(15);
mstat1 varchar2(30);
mstat2 varchar2(30);
mstat3 varchar2(30);
mstat4 varchar2(30);
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
if mpno is not null and mdes is not null and mair is not null then
begin
mstat:='N';
mpno:=pno;
mdes:=pdes;
mair:=air;
for i in c1 loop
mstat:='N';
mstat1:='N';
mstat2:='N';
mstat3:='N';
mstat4:='N';
mpno1:=i.partnum;
mpartnum:=i.partnum;
mdescription:=i.description;
maircraft_type:=i.aircraft_type;
for j in c2 loop
mpno2:=j.partnum;
end loop;
for k in c3 loop
mpno3:=k.partnum;
end loop;
for l in c4 loop
mpno4:=l.partnum;
end loop;
for m in c5 loop
mpno5:=m.part_no;
end loop;
if mpno2=mpartnum then
mstat1:=mpno2;
end if;
if mpno3=mpartnum then
mstat2:=mpno3;
end if;
if mpno4=mpartnum then
mstat3:=mpno4;
end if;
if mpno5=mpartnum then
mstat4:=mpno5;
end if;
if mpno1=mpartnum then
mstat:='Y';
orec.PartNo:=mpno1;
orec.Description:=mdescription;
orec.AIrcraft_type:=maircraft_type;
orec.status_IPC:=mstat1;
orec.status_ELOG:=mstat2;
orec.status_SUPCAT:=mstat3;
orec.STATUS_AIRODWH:=status_AIRODWH;
end if;
end loop;
end;
end if;
end testsch2;
end ioStructArray;
Expecting your early reply.
With thanks
Pramod kumar. -
Use PL/SQL procedure to guard against malformed CSV files before upload
Hi all,
In my CSV upload utility, I've implemented error checking procedures, but they are invoked only AFTER data has been uploaded to temp table. This doesn't catch the following sample scenarios:
1. The CSV is malformed, with some rows shifted due to fields and separators missing here and there.
2. User has chosen a wrong CSV to upload (most likely number of fields mismatch)
I'm wondering if it is a good idea to have procedure to read in the CSV, scan each line, count the number of fields (null fields but with delimiters showing the field exist is ok) for each record. If every single record matches the required number of fields for that table, then the CSV is ok, and the insert from external table to temp table is allow. This will ensure at least the CSV file has a valid matrix size for the target table, but rest of error checking is left until after temp table is populated.
One of my concerns is, I specify "missing field values are null" in the external table parameters, which is necessary since not all fields are required. Does this specification causes a row with missing trailing separators still considered valid? If so then the stored procedure must be programmed to omit such a case.
What do you think? Many thanks.Hi, Cuauhtemoc Amox
Thank you for your advice. I have set web adi using PL SQL interface.
I have decided to go futher
i have a procedure like that
procedure delete_old_data ( p_id in number, p_description in varchar2)
as
begin
begin
if g_flag ='N' then
delete from xx_test;
g_flag='Y';
else null;
end if;
end;
insert into xx_test (p_id,p_descriptiom);
end;
G_FLAG is a global variable with default value ='N' in my package. When web_adi upload
first row from excel sheet, then procedure delete all data from table and change g_flag to 'Y'.
All other rows uploads succesfully; it works fine.
But when user change data in excel sheet and try to upload second time. DELETE_OLD_DATA procedure doesnt work in proper way.
I have found what problem is. when user use same template and try to upload data several times there is same SESSION_ID in database.
i.e. g_flag ='Y' when user try to upload second time. But when user log off and create template again it is work properly.
My question is: How i can different upload attempts? May be there is some id for each upload proccess.
if i can use this ID in my procedure user will have opportunity to use same template.
Thank you -
Updated records using Dynamic FORMS_DDL
Hello everybody:
I need help for you guys. I'm working with Form9i and created a push button that when I press it, it should be updated some record depending of some conditions. I read that with dynamics FORMS_DDL, I can able to perform it, but when I put the below code in the âWHEN-BUTTON-PRESSEDâ trigger I get an âErrorâ that meaning that the forms was not success. Please, somebody tell me where is the error. Thanks.
if (:CONTROL_BTN.CHK_FINAL = 'N') then
forms_ddl('update aapt_checklists
set achk_reviewed_date = ' || :CONTROL_BTN.DATE_LETTER ||
' where achk_item in (select achk_item
from aapt_checklists, aapt_reviews
where ' || :global.where_updated ||
' and achk_reviewed_date is null
and achk_1st_notification_date is null
and arev_seq = achk_arev_seq)
and achk_1st_notification_date is null
and achk_reviewed_date is null');
end if;
if (form_success) then
message('OK');
else
message('Error');
end if;You don't need dynamic SQL for that. Here is what you can do (Note the new v_fmt variable, and the update SQL below):
DECLARE
def_where varchar2(500) := NULL;
v_month varchar2(2) := :CONTROL_BLOCK.Q_MONTH;
v_day varchar2(2) := :CONTROL_BLOCK.Q_DAY;
v_year varchar2(4) := :CONTROL_BLOCK.Q_YEAR;
v_fmt varchar2(10);
v_date varchar2(20) := NULL;
PROCEDURE check_date (in_date IN varchar2) IS
al_id Alert;
al_button Number;
temp_date date := NULL;
BEGIN
temp_date := to_date(in_date, 'MM/DD/YYYY');
EXCEPTION
when others then
al_id := Find_Alert('CFG_ERROR');
Set_Alert_Property(al_id, alert_message_text, 'You have selected an Invalid Date');
al_button := Show_Alert( al_id );
raise FORM_TRIGGER_FAILURE;
END;
BEGIN
-- Criteria entered as MM/DD/YYYY
if (v_month <> '00') and (v_day <> '00') and (v_year <> '0000') then
v_date := v_month||'/'||v_day||'/'||v_year;
v_fmt := 'MM/DD/YYYY';
check_date (v_date);
-- Criteria entered as MM/DD
elsif (v_month <> '00') and (v_day <> '00') and (v_year = '0000') then
v_date := v_month||'/'||v_day;
v_fmt := 'MM/DD';
check_date (v_date||'/'||'2000'); -- Hardcoded 2000 to check all possible MM/DD combos including Leap Year
def_where := ' to_char(arev_appl_received_date, ''MM/DD'') = ''' || v_date || '''';
-- Criteria entered as MM/YYYY
elsif (v_month <> '00') and (v_day = '00') and (v_year <> '0000') then
v_date := v_month||'/'||v_year;
v_fmt := 'MM/YYYY';
def_where := ' to_char(arev_appl_received_date, ''MM/YYYY'') = ''' || v_date || '''';
-- Criteria entered as MM
elsif (v_month <> '00') and (v_day = '00') and (v_year = '0000') then
v_date := v_month;
v_fmt := 'MM';
def_where := ' to_char(arev_appl_received_date, ''MM'') = ''' || v_date || '''';
-- Criteria entered as DD/YYYY
elsif (v_month = '00') and (v_day <> '00') and (v_year <> '0000') then
v_date := v_day||'/'||v_year;
v_fmt := 'DD/YYYY';
def_where := ' to_char(arev_appl_received_date, ''DD/YYYY'') = ''' || v_date || '''';
-- Criteria entered as DD
elsif (v_month = '00') and (v_day <> '00') and (v_year = '0000') then
v_date := v_day;
v_fmt := 'DD';
def_where := ' to_char(arev_appl_received_date, ''DD'') = ''' || v_date || '''';
-- Criteria entered as YYYY
elsif (v_month = '00') and (v_day = '00') and (v_year <> '0000') then
v_date := v_year;
v_fmt := 'YYYY';
def_where := ' to_char(arev_appl_received_date, ''YYYY'') = ''' || v_date || '''';
end if;
update aapt_checklists
set achk_reviewed_date = :CONTROL_BTN.DATE_LETTER
where achk_item in
in (select achk_item
from aapt_checklists, aapt_reviews
where to_char(arev_appl_received_date,v_fmt) = v_date
and achk_reviewed_date is null
and achk_1st_notification_date is null
and arev_seq = achk_arev_seq)
and achk_1st_notification_date is null
and achk_reviewed_date is null;
--Condition for updated records in aapt.checklists table
:global.where_updated := def_where;
--Only when "INCOMPLETE - NEED ADD'L INFO" Status is selected
def_where := def_where || ' and arev_status = 1427';
END; -
Working on a set of records in PL/SQL procedure
Hi,
I have three tables - Cash, Charge and Cash_Application.
The table structures are:
Cash: This table holds all payments made by customers by date by account_reference. Columns are:
cash_id number(22) Primary Key,
receipt_date date,
account_reference_number varchar2(13),
cash_amount number(22,2)
Charge: This table holds all the charges raised against the products(Water, Sewerage, etc) provided by Water system to the customers. Columns are:
charge_id number(22) Primary Key,
activity_date date,
account_reference_number varchar2(13),
billable_amount number(22,2)
charge_type number(22)
Cash_Application: This table holds combination of cash_id and charge_id for an account_reference with the cash_amount received for each charge. Columns are:
cash_application_id number(22) Primary Key,
fk_cash_id number(22),
fk_charge_id number(22),
account_reference_number varchar2(13),
applied_amount number(22,2)
Cash_Application table is to be loaded from Cash and Charge tables; the match being Account_Reference_number and amounts from the table.
Following are the Cash Allocation rules:
1. The earliest cash will be allocated to the earliest charge
2. If an account has an opening balance, it will be allocated first. Charge_Type for opening balance is zero in Charge table
3. If there is more than one charge records on the same date, then cash will be allocated in porportion to billable_amount for each charge.
There are two possibilities .... either billable_amount for each charge will become zero .... after allocating the cash or cash will be insuffiecient for sum(billable_amount) for an account_reference on a particular date. In first case, if some more charges exist for the account, cash will be applied to those charges. In second case, new cash record will be brought in from cash table and it will be allocated proportionally to remaining charges.
4. Any cash that remains after fully allocating all the charges on the account for all days, will remain un-allocated.
Please provide some pointers on how this can be done using PL/SQL.
An example to elaborate the points above:
Charge
Charge_id Account_Ref Amount Activity_Date Charge_Type
1 X 50 21-Jan 0
2 X 100 23-Jan 1
3 X 50 23-Jan 2
4 X 10 23-Jan 3
5 X 1 23-Jan 4
Cash
Row Amount Account_ref Receipt_Date
1 80 X 20-Jan
2 60 X 25-Jan
Cash Application
Cash_Application_Id CashID ChargeID Amount Account_Ref
1 1 0 50 X
2 1 1 18.63 X
3 1 2 9.32 X
4 1 3 1.86 X
5 1 4 0.19 X
6 2 1 37.27 X
7 2 2 18.63 X
8 2 3 3.73 X
9 2 4 0.37 X
81.37 ChargeAmount remaining after allocating cash1 to charge1
40.68 ChargeAmount remaining after allocating cash1 to charge2
8.14 ChargeAmount remaining after allocating cash1 to charge3
0.81 ChargeAmount remaining after allocating cash1 to charge4
Regards,
Suwarna PatkiHi Suwarna,
Forgive me, I didn't take the time to digest your problem fully.
At first glance I'd suggest you want to investigate 'analytic functions' in the SQL reference.
For example,
SELECT amount,
SUM (amount) OVER (PARTITION BY date ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
FROM transactions
ORDER BY date
d. -
How to use pl/sql procedure or function as part of validate the entity obj?
Hi,
we are migrating from oracle forms to jdeveloper 11g.
I have a req. that,i wanted to use oracle pl/sql procedure to validate a attribute in an entity created with ADF BC?
Is it possible to implement this?
And how to show the error message from pl/sql procedure?
Regards
Murali.Hi,
It is possible by using a method validator for the entity attribute.
Create a transient attribute 'X'.
In the validation section of the attribute to be validate, choose method validator.
In the Error Message tab set error message as {0}.
Below the value for tokentoken should source.X (X is the transient attribute name)
In the java code of method validator, call the stored procedure and set the value of transient attribute X with the error message from SP.
Use setX("ErrorMessage").
Regards,
Srinidhi
Maybe you are looking for
-
How can I print a month calendar without the times of day from the day calendar
The obvious way to put items into iCal is via the day calendar. But I want to print the calendar as one month to a page and there I do not want the times of day.
-
Cannot see my previous purchases
I purchased a new Mac book pro and was trying to use tethering from my iphone 3gs. The thethering worked but while I was doing it the Mac Book updated the software on the Iphone. resulting all my photos and contacts on the Iphone are now lost. Intere
-
Consistency of sequence.curval
Hi Folks, I have a Table llike this (simplified example): CREATE SEQUENCE tab1_seq START WITH 1 INCREMENT BY 1 MAXVALUE 99999999999999 NOCYCLE CACHE 20 CREATE TABLE tab1 ( id NUMBER(14) PRIMARY KEY, name VARCHAR2(16) NOT NULL, val1 NU
-
IPad3-iTunes won't display album covers-freezes
iTunes locks up on my iPad 3 and does not display Album covers. All else works fune. I have restored as a new iPad and iTunes is fine. Unfortunately, after loading apps from iTunes back on, iTunes begins to again have same problem.
-
My JMS cannot dequeue the aq in DB (Exception JMS-120)
When debug throw the statement receiveNoWait(),it throw out exception JMS-120 dequeue failed,who can tell me why? My method as below: public void test() QueueConnectionFactory qcfact; QueueConnection qconn; QueueSession session; Queue queue