ROWID from a PLSQL procedure
Hi guys,.I have a tabular presentation that allows the user to update and create lines.
My form updates and creates a box for a warehouse system amounts.
What I want to do is when the user creates a new box with a quantity of 10 to be able to call a package that I wrote to save this transaction in my table of transactions and when a box is reduced from 10 to 5, for example still create a transaction to call my package.
What I am struggling with is how to move in the BOX_ID of tables in my procedure with the ID of the row in the tabular form that I've updated / created.
For updating the amount of box I have the transaction must be able to get the amount of previous and new box Qty.
For example
To create:
New line added to the database with a quantity of 5. Spend this new rowid and new box Qty in my procedure that will take care of the creation of the transaction.
For an update:
Old value 10, new value 5. Pass the rowid, old and new values in my procedure, which will be responsible for the creation of the transaction.
The user could, in theory, add and update multiple records at once before they click on the submit"" button. I tried using triggers in the table, but I prefer to do in form as much as possible.
Hope that make sense,
PS - I use APEX v4.0
I create a simple demonstration of what I am seeking to achieve is to:
http://Apex.Oracle.com/pls/Apex/f?p=17551:8
user guest1 name
password demo
There are 3 lines in the form, if the user changes the value of an area from 500 to 100, I want the form forward to my procedure the box stood at 500 and was reduced to 100 for this box_id.
I also useful to call the procedure when a new box is created in the amount of this new box.
Thanks in advance,
Chris
I'd say it's something that you should in a trigger (which would happen when I use the SQL workshop to insert a line...), but anyway:
You can create your own insertion procedure, such as:
Insert the rowid return table_x (val1, val2, val3) in l_rowid. And then use l_rowid to call your procedure. (or the box_id instead of the rowid, whatever you prefer)
Tags: Database
Similar Questions
-
Business event does not trigger the PLSQL procedure... What should do?
We need to call a plsql procedure when the workflow approval GL ended with approval. I thought I could do it by customizing the relevant business event.
We are on EBS 12.1.3 with RDBMS: 11.2.0.3.0.
I see the event oracle.apps.gl.Journals.journal.approve company has been disabled currently. I've enabled and created a subscription for her. Subscription was a PLSQL procedure. Currently, for objective test only thing it does is to insert a row in a table.
Parameters of the subscription to corporate events:
System: ORDEBS. SYSTEM.COM
Triggering event
Source type: Local
Event filter: oracle.apps.gl.Journals.journal.approve
Execution condition
Phase: 100
Status: enabled
Rule data: Message
Action type: custom
Error on: stop blocking and cancellation
Action
Rule of PL/SQL function: XX_GL_APPROVE_BE_PKG. Get_Attributes
Priority: normal
Documentation (not sure what value to give the latter. I went with the values below).
Owner: Name of the company
Tag owner: custom Schema
Using query I can see the event company is called when occurs below approval (an added line each time approval that has happened). But I don't see all the lines in the table where to insert a line. What could go wrong? How can I make sure that the procedure was called?
Select * from WF_DEFERRED where corrid'art = 'APPS:oracle.apps.gl.Journals.journal.approve. '
Procedure:
CREATE OR REPLACE PACKAGE BODY APPS. XX_GL_APPROVE_BE_PKG
AS
PROCEDURE Get_Attributes
IS
BEGIN
INSERT INTO xx.xx_test_table VALUES (' to BE');
COMMIT;
END Get_Attributes;
END XX_GL_APPROVE_BE_PKG;Hello
This OWNER_TAG represents an actual application under license, as "DNF" without the quotes. The business event system will send subscriptions for licensed products.
Also, in order to detect any other possible errors please add a subscription of type error. In this way the BES will catch the error and will notify SYSADMIN of this failure, it's not silent. You can use this link to see how: https://blogs.oracle.com/oracleworkflow/entry/defining_business_events_with_synchronous
Kind regards
Alejandro
-
PLSQL procedure with the ORA-01858: a non-digit character was found where
Hi friends,
I'm pretty much back to the plsql programming. I am creating the plsql procedure that basically accepts the values of variables and controls difference of two columns if she's even if different it inserts values into the temporary table GTT_S_DOC_QUOTE, and then inserts data into another table in s_doc_quote please help me or correct my procedure.
Since I'm getting below error ORA-01858: a non-digit character was found here where waiting a digital .my procedure is as below.
CREATE OR REPLACE PROCEDURE QUOTE_STS)
ROW_ID_IN GGATE_CT. GTT_S_DOC_QUOTE. ROW_ID % TYPE,
STAT_CD_IN GGATE_CT. GTT_S_DOC_QUOTE. STAT_CD % TYPE,
PREV_STS_CD_IN GGATE_CT. GTT_S_DOC_QUOTE. PREV_STS_CD % TYPE,
BU_ID_IN GGATE_CT. GTT_S_DOC_QUOTE. BU_ID % TYPE,
CREATED_IN GGATE_CT. GTT_S_DOC_QUOTE. CREATED % TYPE,
X_CRRNT_TOT_AGRD_RMS_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_TOT_AGRD_RMS % TYPE,
X_CRRNT_TOT_BLCKD_RMS_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_TOT_BLCKD_RMS % TYPE,
X_CRRNT_TOT_PCKDUP_RMS_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_TOT_PCKDUP_RMS % TYPE,
X_CRRNT_TOT_PCKDUP_AVGRT_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_TOT_PCKDUP_AVGRT % TYPE,
X_CRRNT_TOT_BLCKD_AVGRT_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_TOT_BLCKD_AVGRT % TYPE,
X_CRRNT_CNTRCT_SR_REVN_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_CNTRCT_SR_REVN % TYPE,
X_CRRNT_CNTRCT_FD_REVN_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_CNTRCT_FD_REVN % TYPE,
X_CRRNT_CNTRCT_BEV_REVN_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_CNTRCT_BEV_REVN % TYPE,
X_CRRNT_CNTRCT_RM_REVN_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_CNTRCT_RM_REVN % TYPE,
X_CRRNT_USD_EXCHNG_RT_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_USD_EXCHNG_RT % TYPE,
X_CRRNT_CNTRCT_OTHR_REVN_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_CNTRCT_OTHR_REVN % TYPE,
X_CRRNT_CNTRCT_RSRC_REVN_IN GGATE_CT. GTT_S_DOC_QUOTE. X_CRRNT_CNTRCT_RSRC_REVN % TYPE,
LAST_UPD_IN GGATE_CT. GTT_S_DOC_QUOTE. LAST_UPD % TYPE)
BEGIN
IF (PREV_STS_CD == STAT_CD) then
END if;
INSERT INTO GTT_S_DOC_QUOTE)
ROW_ID,
STAT_CD,
PREV_STS_CD,
BU_ID,
CREATED,
X_CRRNT_TOT_AGRD_RMS,
X_CRRNT_TOT_BLCKD_RMS,
X_CRRNT_TOT_PCKDUP_RMS,
X_CRRNT_TOT_PCKDUP_AVGRT,
X_CRRNT_TOT_BLCKD_AVGRT,
X_CRRNT_CNTRCT_SR_REVN,
X_CRRNT_CNTRCT_FD_REVN,
X_CRRNT_CNTRCT_BEV_REVN,
X_CRRNT_CNTRCT_RM_REVN,
X_CRRNT_USD_EXCHNG_RT,
X_CRRNT_CNTRCT_OTHR_REVN,
X_CRRNT_CNTRCT_RSRC_REVN,
LAST_UPD
)
VALUES ('ROW_ID_IN',
"STAT_CD_IN,"
"PREV_STS_CD_IN,"
"BU_ID_IN,"
"CREATED_IN,"
"X_CRRNT_TOT_AGRD_RMS_IN,"
"X_CRRNT_TOT_BLCKD_RMS_IN,"
"X_CRRNT_TOT_PCKDUP_RMS_IN,"
"X_CRRNT_TOT_PCKDUP_AVGRT_IN,"
"X_CRRNT_TOT_BLCKD_AVGRT_IN,"
"X_CRRNT_CNTRCT_SR_REVN_IN,"
"X_CRRNT_CNTRCT_FD_REVN_IN,"
"X_CRRNT_CNTRCT_BEV_REVN_IN,"
"X_CRRNT_CNTRCT_RM_REVN_IN,"
"X_CRRNT_USD_EXCHNG_RT_IN,"
"X_CRRNT_CNTRCT_OTHR_REVN_IN,"
"X_CRRNT_CNTRCT_RSRC_REVN_IN,"
'LAST_UPD '.
);
INSERT INTO S_DOC_QUOTE_CT
(ROW_ID_OUT, STAT_CD_OUT, PREV_STS_CD_OUT, BU_ID_OUT, CREATED_OUT, X_CRRNT_TOT_AGRD_RMS_OUT, X_CRRNT_TOT_BLCKD_RMS_OUT, X_CRRNT_TOT_PCKDUP_RMS_OUT, X_CRRNT_TOT_PCKDUP_AVGRT_OUT,
X_CRRNT_TOT_BLCKD_AVGRT_OUT, X_CRRNT_CNTRCT_SR_REVN_OUT, X_CRRNT_CNTRCT_FD_REVN_OUT, X_CRRNT_CNTRCT_BEV_REVN_OUT, X_CRRNT_CNTRCT_RM_REVN_OUT, X_CRRNT_USD_EXCHNG_RT_OUT, X_CRRNT_CNTRCT_OTHR_REVN_OUT,
SELECT X_CRRNT_CNTRCT_RSRC_REVN_OUT ROW_ID), STAT_CD, PREV_STS_CD, BU_ID, CREATED, X_CRRNT_TOT_AGRD_RMS, X_CRRNT_TOT_BLCKD_RMS, X_CRRNT_TOT_PCKDUP_RMS, X_CRRNT_TOT_PCKDUP_AVGRT,.
X_CRRNT_TOT_BLCKD_AVGRT, X_CRRNT_CNTRCT_SR_REVN, X_CRRNT_CNTRCT_FD_REVN, X_CRRNT_CNTRCT_BEV_REVN, X_CRRNT_CNTRCT_RM_REVN, X_CRRNT_USD_EXCHNG_RT, X_CRRNT_CNTRCT_OTHR_REVN,
GGATE_CT X_CRRNT_CNTRCT_RSRC_REVN. GTT_S_DOC_QUOTE;
COMMIT;
end if;
end QUOTE_STS;I was wondering why I get this error even if I stated the PREV_STS_CD
What line do you think that you said PREV_STS_ID on? As far as I can see that the IF statement is the first mention of it in your code. My guess is that you mean PREV_STATS_ID_IN (goes the same for STAT_CD / STAT_CD_IN).
If you write
IF prev_sts_cd_in = stat_cd_in THEN NULL; END IF; do_something_here;
then "do_something_here" will be processed regardless of the IF condition. I think what you probably wanted was something like
IF prev_sts_cd_in = stat_cd_in THEN NULL; ELSE do_something_here; END IF;
Is it possible for the prev_sts_cd and the stat_cd null? The test above would not handle this.
Also, as others have mentioned, the first INSERT statement attempts to insert the strings like "ROW_ID_IN" you probably want to use the value of the ROW_ID_IN parameter, which is the reason why you get the error ORA-01858. I'm guessing here of course, but I took out the quotes.
That would make your code something like this:
CREATE OR REPLACE PROCEDURE quote_sts ( row_id_in ggate_ct.gtt_s_doc_quote.row_id%TYPE , stat_cd_in ggate_ct.gtt_s_doc_quote.stat_cd%TYPE , prev_sts_cd_in ggate_ct.gtt_s_doc_quote.prev_sts_cd%TYPE , bu_id_in ggate_ct.gtt_s_doc_quote.bu_id%TYPE , created_in ggate_ct.gtt_s_doc_quote.created%TYPE , x_crrnt_tot_agrd_rms_in ggate_ct.gtt_s_doc_quote.x_crrnt_tot_agrd_rms%TYPE , x_crrnt_tot_blckd_rms_in ggate_ct.gtt_s_doc_quote.x_crrnt_tot_blckd_rms%TYPE , x_crrnt_tot_pckdup_rms_in ggate_ct.gtt_s_doc_quote.x_crrnt_tot_pckdup_rms%TYPE , x_crrnt_tot_pckdup_avgrt_in ggate_ct.gtt_s_doc_quote.x_crrnt_tot_pckdup_avgrt%TYPE , x_crrnt_tot_blckd_avgrt_in ggate_ct.gtt_s_doc_quote.x_crrnt_tot_blckd_avgrt%TYPE , x_crrnt_cntrct_sr_revn_in ggate_ct.gtt_s_doc_quote.x_crrnt_cntrct_sr_revn%TYPE , x_crrnt_cntrct_fd_revn_in ggate_ct.gtt_s_doc_quote.x_crrnt_cntrct_fd_revn%TYPE , x_crrnt_cntrct_bev_revn_in ggate_ct.gtt_s_doc_quote.x_crrnt_cntrct_bev_revn%TYPE , x_crrnt_cntrct_rm_revn_in ggate_ct.gtt_s_doc_quote.x_crrnt_cntrct_rm_revn%TYPE , x_crrnt_usd_exchng_rt_in ggate_ct.gtt_s_doc_quote.x_crrnt_usd_exchng_rt%TYPE , x_crrnt_cntrct_othr_revn_in ggate_ct.gtt_s_doc_quote.x_crrnt_cntrct_othr_revn%TYPE , x_crrnt_cntrct_rsrc_revn_in ggate_ct.gtt_s_doc_quote.x_crrnt_cntrct_rsrc_revn%TYPE , last_upd_in ggate_ct.gtt_s_doc_quote.last_upd%TYPE ) IS BEGIN IF prev_sts_cd_in = stat_cd_in THEN NULL; ELSE INSERT INTO gtt_s_doc_quote ( row_id , stat_cd , prev_sts_cd , bu_id , created , x_crrnt_tot_agrd_rms , x_crrnt_tot_blckd_rms , x_crrnt_tot_pckdup_rms , x_crrnt_tot_pckdup_avgrt , x_crrnt_tot_blckd_avgrt , x_crrnt_cntrct_sr_revn , x_crrnt_cntrct_fd_revn , x_crrnt_cntrct_bev_revn , x_crrnt_cntrct_rm_revn , x_crrnt_usd_exchng_rt , x_crrnt_cntrct_othr_revn , x_crrnt_cntrct_rsrc_revn , last_upd ) VALUES ( row_id_in , stat_cd_in , prev_sts_cd_in , bu_id_in , created_in , x_crrnt_tot_agrd_rms_in , x_crrnt_tot_blckd_rms_in , x_crrnt_tot_pckdup_rms_in , x_crrnt_tot_pckdup_avgrt_in , x_crrnt_tot_blckd_avgrt_in , x_crrnt_cntrct_sr_revn_in , x_crrnt_cntrct_fd_revn_in , x_crrnt_cntrct_bev_revn_in , x_crrnt_cntrct_rm_revn_in , x_crrnt_usd_exchng_rt_in , x_crrnt_cntrct_othr_revn_in , x_crrnt_cntrct_rsrc_revn_in , last_upd ); INSERT INTO s_doc_quote_ct ( row_id , stat_cd , prev_sts_cd , bu_id , created , x_crrnt_tot_agrd_rms , x_crrnt_tot_blckd_rms , x_crrnt_tot_pckdup_rms , x_crrnt_tot_pckdup_avgrt , x_crrnt_tot_blckd_avgrt , x_crrnt_cntrct_sr_revn , x_crrnt_cntrct_fd_revn , x_crrnt_cntrct_bev_revn , x_crrnt_cntrct_rm_revn , x_crrnt_usd_exchng_rt , x_crrnt_cntrct_othr_revn , x_crrnt_cntrct_rsrc_revn , last_upd) SELECT row_id , stat_cd , prev_sts_cd , bu_id , created , x_crrnt_tot_agrd_rms , x_crrnt_tot_blckd_rms , x_crrnt_tot_pckdup_rms , x_crrnt_tot_pckdup_avgrt , x_crrnt_tot_blckd_avgrt , x_crrnt_cntrct_sr_revn , x_crrnt_cntrct_fd_revn , x_crrnt_cntrct_bev_revn , x_crrnt_cntrct_rm_revn , x_crrnt_usd_exchng_rt , x_crrnt_cntrct_othr_revn , x_crrnt_cntrct_rsrc_revn , last_upd FROM ggate_ct.gtt_s_doc_quote; END IF; END quote_sts;
-
Describe the Table inside the PLSQL procedure
Dear all,
I write a procedure which takes tablename as input and displays these columns in the table as output. How to describe a table within a plsql procedure. Also how to display columns, because each table will have a different number of columns. Please suggest.
Thank you and best regards,
MaheshHello
You can have a procedure like thisCREATE OR REPLACE PROCEDURE retrieve_tab_cols_prc(l_table_name VARCHAR2,l_owner_name varchar2) AS CURSOR TAB_COL_CURSOR IS select * from all_tab_cols where table_name = l_table_name and owner = l_owner_name ORDER BY column_id; BEGIN FOR CUR_REC IN TAB_COL_CURSOR LOOP dbms_output.put_line(CUR_REC.COLUMN_ID||' : '||CUR_REC.COLUMN_NAME); END LOOP; END retrieve_tab_cols_prc; Procedure created. SQL> begin 2 RETRIEVE_TAB_COLS_PRC('EMP','SCOTT'); 3 end; 4 / 1 : EMPNO 2 : ENAME 3 : JOB 4 : MGR 5 : HIREDATE 6 : SAL 7 : COMM 8 : DEPTNO
-
I have an external PLSQL procedure that dynamically creates a report out of the HTML tags that I then called an anonymous block APEX PLSQL. I'm making bad images with the following code:
in the external procedure. How do you get around that? (NOTE: the procedure is too big to store directly in the APEX)....
' < style td = "width: auto;" "padding: 0px 5px 0px ' > '. spc_rec. SPC_VIABILITY_STATUS. "< table > ' |
"< style td =" width: auto; " text-align: left; "padding: 0px 5px 0px" > ' | spc_rec. SPC_VIABILITY_REASON. "< table > ' | TD > < img src = "" #IMAGE_PREFIX #check2.gif "alt =" "/ > < table > '"
....
Thanks in advance
PaulP
Hi Paul,.
You can use the global variable of the APEX package below to get the image prefix in pl/sql. Of course, your procedure should be in APEX, schema analysis application.
APEX_APPLICATION. G_IMAGE_PREFIX
Kind regards
Hari
-
PLSQL procedure error "component must be reported.
Hello
Greetings
I need to write a PLSQL procedure to compare the data between two different requests (through the collection), but in the face of an error
VERSION - Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
EXAMPLE OF CODE-
CREATE or REPLACE procedure V_test
type v_record is (record
CUSTOMER_TYPE varchar2 (10),
PRODUCT_CATEGORY varchar2 (10),
PRODUCT_DESC varchar2 (40));
type v_tst1 is table of v_record INDEX OF pls_INTEGER;
V_TEST1 v_tst1;
type v_tst2 is table of v_record INDEX OF pls_INTEGER;
V_TEST2 v_tst2;
Start
Select CUSTOMER_TYPE, b.PRODUCT_CATEGORY, c.PRODUCT_DESC
BULK COLLECT INTO V_TEST1
of a, b, c
where a.PRODUCT_CATEGORYD = b.PRODUCT_CATEGORY and a.PRODUCT = c.PRODUC
CUSTOMER_TYPE, PRODUCT_CATEGORY, PRODUCT_DESC group;
Select CUSTOMER_TYPE, PRODUCT_CATEGORY, PRODUCT_DESC
BULK COLLECT INTO VAS_TEST2
d
Group of CUSTOMER_TYPE, b.PRODUCT_CATEGORY, c.PRODUCT_DESC;
BECAUSE me in V_TEST1. FIRST... V_TEST1. LAST
LOOP
FOR j IN V_TEST2. FIRST... V_TEST2. LAST
loop
If VAS_TEST1. CUSTOMER_TYPE (i) = VAS_TEST2. CUSTOMER_TYPE (j) then
If VAS_TEST1. PRODUCT_CATEGORY (i) = VAS_TEST2. PRODUCT_CATEGORY (j) then
insert into v_tab values (sysdate, V_TEST1. CUSTOMER_TYPE (i), V_TEST1. PRODUCT_CATEGORY (i), V_TEST1. PRODUCT_DESC (i));
commit;
end if;
end if;
END LOOP;
END LOOP;
END;
/
ERROR - "PLS-00302: component 'CUSTOMER_TYPE' must be declared '.
Thank you in advance to suggest corrections or alternatives
-
ORA-01445 error: cannot select ROWID from where sample, a join without a view
Hi all
I get an error when I created a VO based EO with standard Table (forced) jtf_notes_vl
It gives me the error ORA-01445: cannot select ROWID from where sample, a join without key preserved table view
the Table has the ROW_ID as Primery key
Thanks in advanceHello
Creation of an EO-based the rowid as primary key is usually the cause of this error as is not recommended to use the rowid as the primary key. Try to use jtf_note_id as the primary key.
Furthermore, why are you using NAV it is seen for the creation of EO. If I remember correctly, there is a JTF_NOTES_B and JTF_NOTES_TL table that you can use.
Thank you
AJ -
Manage the SQLCODE in Plsql procedure
Hello
can you tell me how I can manage the sqlcode for each sql statement and continue the treatment?
For example, I read a table and write the data in another table.
If I get an error of key double pears (IE already entered folders) I would write a log table and read the next record.
The Exception Management stop the process and does not continue reading.
Thank you
-When you transform data between table1 and table2, duplicates will be captured in error_log table with the key that splits to, message error oracle error number, try to run the statements below and understand the process and let me know for any information.
@@@@@@@
create table table1 (tabl1_column number); -primary table
create table table2 (tabl2_column unique number); -Secondary table
create table error_log (duplicate_key number, error_code varchar2 (100), error_message varchar2 (100)); -error log table
Insert into table1 values (1);
Insert into table1 values (1);
Insert into table1 values (2);
Insert into table1 values (3);
script:
====
create or replace procedure sp_sample
as
v_error_msg varchar2 (100): = null;
v_error_code varchar2 (100): = null;
Start
for rec loop (select tabl1_column from table1)
Start
insert into table2 (tabl2_column) values (rec.tabl1_column);
exception when others then
v_error_msg: = sqlerrm;
v_error_code: = sqlcode;
Insert in error_log (duplicate_key, error_code, error_message) values(rec.tabl1_column,v_error_code,v_error_msg);
commit;
end;
end loop;
end;
/
Execute the statement:
===============
Set serveroutput on;
exec sp_sample;
/
Check the result:
==============
Select * from table1;
Select * from table2;
Select * from error_log;
-
Droping a table from within a procedure by passing the name of the Table as an Argument
HII All
I want to remove a table from a procedure dynamically passing the table name as a parameter of a procedure manual
to do this, I wrote the following procedure
CREATE OR REPLACE PROCEDURE DEL_TAB (TAB_NAME IN VARCHAR2) AS
V_TAB_NAME VARCHAR2 (10);
V_STMT VARCHAR2 (50);
BEGIN
V_TAB_NAME: = TABLE_NAME;
V_STMT: = 'DROP TABLE' | V_TAB_NAME;
RUN IMMEDIATELY 'V_STMT ';
DBMS_OUTPUT. PUT_LINE(V_TAB_NAME||) e TABLE DELETED ');
END DEL_TAB;
but whenever I'm execute it gives me an error
ERROR on line 1:
ORA-06550: line 1, column 15:
PLS-00357: Table, view or sequence of reference 'A' not allowed in this context
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Please tell me the solution...
Thanks in advance
Alisson
Why do you want to implement this procedure? If you want to remove a table just issue the DROP of stand-alone statement. Why write a procedure for this? Also you must understand the difference between REMOVE and DROP in the context of RDBMS. You either use them which is incorrect. DELETION is to remove rows from a table and DROP is to remove the database table.
And with regard to your problem
> RUN IMMEDIATELY 'V_STMT ';
This should be
immediately run v_stmt;
You closed the V_STMT variable is in single quotes. You must remove the apostrophes.
-
Cannot create the plsql procedure, fails at the cursor
He was a working procedure that would take ID and then copy the data from the source to the destination parameter parameter. Now I would like to have the NAME as a parameter, I changed the code to accommodate the new settings. But I'm not able to create the procedure. I get error 3-CURSOR (in bold red). I would really appreciate if someone can take a look and let me know what the problem is.
Thanks in advance
3 errors
1 PLS-00103: encountered the symbol "CUR_V_HSP_COLUMN_DETAIL" during the expected in the following way:
:= . ( @ % ;
The symbol ': = ' was replaced by 'CUR_V_HSP_COLUMN_DETAIL' continue.
2 PLS-00103: encountered the symbol "NUMBER" when expecting one of the following conditions:
(
The symbol "(" was substituted for "NUMBER" to continue.
3 PLS-00103: encountered the symbol "NUMBER" when expecting one of the following conditions:
(
CREATE or REPLACE procedure EPM_PLAN_PLANSAMP. Copy_Details_test1 - Arguments
( IN VARCHAR2, HSP_object in_From_Version_Name.) Object_name - Version of
in_From_Scenario_Name IN VARCHAR2, HSP_object. Object_name - scenarios of
in_From_Year_Name IN VARCHAR2, HSP_object. Object_name - year from
in_To_Version_Name IN VARCHAR2, HSP_object. Object_name - Version to
in_To_Scenario_name IN VARCHAR2, HSP_object. Object_name - scenarios
in_To_Year_Name IN VARCHAR2 - HSP_object. Object_name - year to
)
IS
number of v_From_Object_Id; -Version of
number of s_From_Object_Id; -Scenarios of
number of y_From_Object_Id; -The year of
number of v_To_Object_Id; -Version to
number of s_To_Object_Id; -Scenarios to
number of y_To_Object_Id; -The year to
BEGIN
Select object_id in v_From_Object_Id
of hsp_object
where type_objet = 35
and object_name = in_from_version_name;
Select object_id in s_From_Object_Id
of hsp_object
where type_objet = 31
and object_name = in_from_scenario_name;
Select object_id in y_From_Object_Id
of hsp_object
where type_objet = 38
and object_name = in_from_year_name;
Select object_id in v_To_Object_Id
of hsp_object
where type_objet = 35
and object_name = in_to_version_name;
Select object_id in s_To_Object_Id
of hsp_object
where type_objet = 31
and object_name = in_to_scenario_name;
Select object_id in y_To_Object_Id
of hsp_object
where type_objet = 38
and object_name = in_to_year_name;
-Select Details of support for the current Version
CURSOR Cur_V_HSP_COLUMN_DETAIL (cV_From_Object_Id in NUMBER, cS_From_Object_Id number) IS
Select DETAIL_ID in the EPM_PLAN_PLANSAMP. HSP_COLUMN_DETAIL where DIM5 = cV_From_Object_Id AND DIM1 = cS_From_Object_Id;
li_DETAIL_ID NUMBER;
Li_Next_DETAIL_ID NUMBER;
FETCH_STATUS NUMBER: = 0;
v_step_name varchar2 (200);
v_rec_cnt number: = 0;
number of v_cnt;
v_err varchar2 (2000);
-----------------------------------------Begin Copy Version ---------------------------
BEGIN
-Removed next version if already exists
v_step_name: = 'delete the HSP_COLUMN_DETAIL_ITEM ";
Remove from HSP_COLUMN_DETAIL_ITEM
Where DETAIL_ID in (Select DETAIL_ID from HSP_COLUMN_DETAIL
Where = v_To_Object_Id AND DIM1-DIM5 = s_To_Object_Id);
v_cnt: = number of lines sql %;
insert into t_copy_supporting_dtls_log values (v_step_name, v_cnt, 1, sysdate, 'success');
v_step_name: = 'delete the HSP_COLUMN_DETAIL ";
Remove from HSP_COLUMN_DETAIL
where = v_To_Object_Id AND DIM1-DIM5 = s_To_Object_Id;
v_cnt: = number of lines sql %;
insert into t_copy_supporting_dtls_log values (v_step_name, v_cnt, 1, sysdate, 'success');
Open Cur_V_HSP_COLUMN_DETAIL (v_From_Object_Id, s_From_Object_Id);
v_step_name: = "Insert";
LOOP
Look FOR Cur_V_HSP_COLUMN_DETAIL IN li_DETAIL_ID;
WHEN the OUTPUT Cur_V_HSP_COLUMN_DETAIL % NOTFOUND;
-Find the next detail_id
Select Max (DETAIL_ID) + 1 IN HSP_COLUMN_DETAIL Li_Next_DETAIL_ID;
-Insert in the Table HSP_COLUMN_DETAIL
Insert into HSP_COLUMN_DETAIL (DETAIL_ID, PLAN_TYPE, DIM1, DIM2, DIM3, DIM4, DIM5, 6,
DIM7, DIM8, DIM9, DIM10, DIM11, DIM12, DIM13, DIM14, DIM15,
DIM16, DIM17, DIM18, DIM19, DIM20)
Select Li_Next_DETAIL_ID, PLAN_TYPE, S_To_Object_Id, DIM2, DIM3, DIM4, V_To_Object_Id, 6.
DIM7, DIM8, DIM9, DIM10, DIM11, DIM12, DIM13, DIM14, DIM15,
DIM16, DIM18, DIM19, DIM17, DIM20
Of HSP_COLUMN_DETAIL
Where DETAIL_ID = li_DETAIL_ID;
v_rec_cnt: = v_rec_cnt + sql rowcount %;
-Insert in the Table HSP_COLUMN_DETAIL_ITEM
Insert into HSP_COLUMN_DETAIL_ITEM (DETAIL_ID, VALUE, POSITION, GENERATION, OPERATOR, LABEL)
Select VALUE, POSITION, GENERATION, OPERATOR, Li_Next_DETAIL_ID, LABEL
From HSP_COLUMN_DETAIL_ITEM where DETAIL_ID = li_DETAIL_ID;
v_rec_cnt: = v_rec_cnt + sql rowcount %;
END LOOP;
Close Cur_V_HSP_COLUMN_DETAIL;
insert into t_copy_supporting_dtls_log values (v_step_name, v_rec_cnt, 1, sysdate, 'success');
commit;
exception when others then
Rollback;
v_err: = substr (sqlerrm, 1, 2000);
insert into t_copy_supporting_dtls_log values (v_step_name, 0, -1, v_err, sysdate);
commit;
END;
END;
/
You DECLARE the cursor before using it.
-
How can I find a large amount of data from a stored procedure?
How can I find a large amount of data to a stored procedure in an effective way?
For example do not use a cursor to go through all the lines and then assign values to variables.
Thanks in advance!>
How can I find a large amount of data to a stored procedure in an effective way?For example do not use a cursor to go through all the lines and then assign values to variables.
>
Leave the query to create the object back to you.Declare a cursor in a package specification than the result set gives you desired. And to declare a TYPE in the package specification which returns a table composed of % rowtype to this cursor.
Then use this type as the function's return type. Here is the code example that shows how easy it is.
create or replace package pkg4 as CURSOR emp_cur is (SELECT empno, ename, job, mgr, deptno FROM emp); type pkg_emp_table_type is table of emp_cur%rowtype; function get_emp( p_deptno number ) return pkg_emp_table_type pipelined; end; / create or replace package body pkg4 as function get_emp( p_deptno number ) return pkg_emp_table_type pipelined is v_emp_rec emp_cur%rowtype; begin open emp_cur; loop fetch emp_cur into v_emp_rec; exit when emp_cur%notfound; pipe row(v_emp_rec); end loop; end; end; / select * from table(pkg4.get_emp(20)); EMPNO ENAME JOB MGR DEPTNO ---------- ---------- --------- ---------- ---------- 7369 DALLAS CLERK2 7902 20 7566 DALLAS MANAGER 7839 20 7788 DALLAS ANALYST 7566 20 7876 DALLAS CLERK 7788 20 7902 DALLAS ANALYST 7566 20
If you return a line an actual table (all columns of the table) so you don't need to create a cursor with the query a copy you can just declare the type like this % rowtype tables table.
create or replace package pkg3 as type emp_table_type is table of emp%rowtype; function get_emp( p_deptno number ) return emp_table_type pipelined; end; / create or replace package body pkg3 as function get_emp( p_deptno number ) return emp_table_type pipelined is begin for v_rec in (select * from emp where deptno = p_deptno) loop pipe row(v_rec); end loop; end; end; /
-
Can get us data back from a stored procedure in a select query?
Hello
Suppose I have a function GetSum(x,y) that returns the sum of two numbers x and y. We can call this function from a function sql like this:
But it's possible thanks to a stored procedure? for example, can I call a stored procedure from a select query, as I did above code?select GetSum(4,5) SUM from dual;
bootstrap wrote:
Hello
Suppose I have a function GetSum(x,y) that returns the sum of two numbers x and y. We can call this function from a function sql like this:select GetSum(4,5) SUM from dual;
But it's possible thanks to a stored procedure?
NO!
-
HII... Experts,
I am facing a problem in writing a procedure. Please help me with the correct code.
My question is...
Suppose that I ve data type.
MAP
MAO
RAN
RAM
ROLLAND
TA5
SAS
SAM
(MB). Like this.
The procedure should be like that, he must have counters on meter of para and para. When I give value RAN as a parameter, it will show RAO and RAM as a parameter as the closest two letters ' no out is'm ' and 'o' in the English alphabet. Same for all words.
The code of procedure for her.
Help, please.
Concerning
S RnHello
Soumya.RN wrote:
HII... Experts,I am facing a problem in writing a procedure. Please help me with the correct code.
My question is...
Suppose that I ve data type.
MAP
MAO...We'll call the table where these data are stored table_x and we'll call the abstract of the column
The procedure should be like that, he must have counters on meter of para and para. When I give value RAN as a parameter, it will show RAO and RAM as output parameter
You mean that he must return to "ROLAND" and "RAM" 2 separate settings. Cramming 2 values in a variable is not a good idea.
as the closest two letter 'no am' and 'o' in the English alphabet. Same for all words.
If the input parameter is 'MAR '? I assume that the procedure must return 'MAP' and 'RAM', since they are really closest values in the table.
If the input parameter is "AAA", which comes before the first abbr in the table? I guess you want NULL to the neighbor earlier.The code of procedure for her.
Soemthing like:
CREATE OR REPLACE PROCEDURE nearest_2 ( in_abbr IN table_x.abbr%TYPE , out_abbr_before OUT table_x.abbr%TYPE , out_abbr_after OUT table_x.abbr%TYPE ) AS BEGIN SELECT MAX (abbr) INTO out_abbr_before FROM table_x WHERE abbr < in_abbr; SELECT MIN (abbr) INTO out_abbr_after FROM table_x WHERE abbr > in_abbr; END nerarest_2; /
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
Explain, using specific examples, how you get these results from these data. If the problem includes parameters after a few different parameters and the desired results, the same sample for each data.
Always tell what version of Oracle you are using. -
Select the data from collections plsql
Hi all
I'm not a developer but working as a DBA, so not very familiar with pl/sql, always crossed with documentation and could lead to a solution of my problem. I need advice from expert here.
Problem: I am writing in a kind of special program plsql for surveillance of certain lots, I know that we have much option to do the same db/grid control including... etc but for some
the reason I have to do this, use only plsql.
Requirement: my requirement is to select data in the plsql table and then have the opportunity to ask questions again and again. I prefer not to go to table, rather than directly from plsql...
I wrote below the code for the sample, bulk data in collection type collection and can print using the loop.
Declare
TS type is table v$ session % rowtype index by pls_integer;
tsess ts.
Start
Select * bulk collect into tsess from v$ session;
I'm looping 1.tsess.count
dbms_output.put_line (tsess (i) .terminal);
end loop;
end;
/
But is it possible same collection (tsess in the example above) can be queried using a select as ' select * from table (Tsess) "I searched the net and found this can be done using create type at the database level.» But my problem is that I can't create any object in the database as being it's a production one.
I was looking as if is it possible even can be accomplished... as cast / multiset... However, I could not get it through.
your help would be appreciated!
Kind regardsI don't think you should use the tables here, only SQL, take a look at the factors of subquery and will indicate if it is not enough...
Published by: BrendanP on February 12, 2012 03:07 for an example:
I understand you want to "Refresh" of data that you already have the database purely to be able to use the SQL such as ORDER BY in multiple ways. Here's how you can do it in the original SQL for a particular example, where you query v$ sql time control processor and disk reads separately (I tested it but the result won't be good look here, so omitting it):
WITH v AS ( SELECT Substr (sql_text,1,500) sql_text, cpu_time/1000000 cpu_seconds, disk_reads, buffer_gets, executions, CASE WHEN rows_processed != 0 THEN Round( buffer_gets / Nvl (Replace (rows_processed, 0, 1) ,1)) END Buffer_gets_rows_proc, Round (buffer_gets / Nvl (Replace (executions, 0, 1), 1)) Buffer_gets_executions, elapsed_time / 1000000 elapsed_second, module FROM v$sql s) SELECT 'CPU' order_by, cpu_seconds order_val, sql_text, cpu_seconds, disk_reads, buffer_gets, executions, buffer_gets_rows_proc, buffer_gets_executions, elapsed_second, module FROM v UNION SELECT 'Disk reads', disk_reads, sql_text, cpu_seconds, disk_reads, buffer_gets, executions, buffer_gets_rows_proc, buffer_gets_executions, elapsed_second, module FROM v ORDER BY order_by, order_val DESC
-
Migrating from Oracle stored procedures to MySQL?
I was told that MySQL Workbench will accomplish this.
If so, do you have the docs for this?I'm sorry, but this forum is only to help in migrations from foreign to an Oracle database databases. When you need assistance for migrating from Oracle to MySQL procedure so if please check MySQL support or visit their web site: http://www.mysql.com/products/workbench/ and their forum.
Maybe you are looking for
-
I just started having this extra window that says: "RECOMMENDED updates! It is recommended to install the software to make sure that your browser is the latest version. Please update to continue. "The link says: Rvzr - a.akamaihd.NET. I'm a little re
-
How to connect without a password?
For Macbook Air I followed the steps in the other response. Went to system preferences Users & groups DIN clicked the lock to open it. The problem I have is that my automatic sign says is turned off and it's gray outside. Doesn't let me change it. So
-
How | I stop the box Smart Web Printing from popping up. Whenever I try to open anything the SWP box open axking me to insert the disc that I did not. I don't have this SWP came BU today has started and I can't get rid of him. | I deleted the SWP of
-
Compaq dc5800: 1801 H.P. Microcode update error; message at startup
I bought this computer used as what a year ago, whenever I start it, I get this message "1801 microcode update error H.P.. Can anyone suggest me how I can remeady this situation. Thank you.
-
windows ssd 8.1 migration
Hello. I recently migrated my boot Windows 8.1 of the original 2 TB Seagate drive in my 810 Phoenix-130qe to a Samsung 250 GB SSD using migration data from Samsung app. After the migration, I placed the SSD in the position of the original boot driv