ORA-00947 strange
Hi allI have a query in a procedure as follows:
Select min (Ref. INNER_CODE REFERENCE_V_INNER_CODE), item.COMPONENT_V_ID bulk collect into highest_quality_table
starting T_ITEM, ref T_REFERENCE
where (point. ITEM_V_CODE, item.COMPONENT_V_ID) in
(select...)
and point. ITEM_V_QUALITY_LEVEL = REF. REFERENCE_V_CODE_NAME
Item.COMPONENT_V_ID group
Is compiled successfully if I use a locally defined type for highest_quality_table:
TYPE highest_quality_row_type IS RECORD (INNER_CODE T_REFERENCE. TYPE OF REFERENCE_V_INNER_CODE %, COMPONENT_V_ID T_COMPONENT.COMPONENT_V_ID%TYPE);
TYPE highest_quality_table_type IS TABLE OF THE highest_quality_row_type;
highest_quality_table highest_quality_table_type;
But then I tried to define this type at the level of the schema:
create or replace type as object highest_quality_row_type (INNER_CODE NVARCHAR2 (20), COMPONENT_V_ID NVARCHAR2 (8))
create or replace type highest_quality_table_type to table of highest_quality_row_type
After that, the query fails to compile with the strange ORA-00947 (not enough values).
No idea why it could happen?
Published by: 850271 on April 6, 2011 06:55
Because RECORD! = OBJECT. If you in bulk collect in the array of objects your SQL must select object of this type. Change Select this option for:
select highest_quality_row_type(min(ref.REFERENCE_V_INNER_CODE),item.COMPONENT_V_ID)
bulk collect
into highest_quality_table
from T_ITEM item,
T_REFERENCE ref
where (item.ITEM_V_CODE,item.COMPONENT_V_ID) in ( select ... )
and item.ITEM_V_QUALITY_LEVEL=ref.REFERENCE_V_CODE_NAME
group by item.COMPONENT_V_ID
/
SY.
Tags: Database
Similar Questions
-
ORA-00947: not enough values error collect in bulk
Hi guys,.
I'm trying to COLLECT in a PL/SQL table, but I get ORA-00947: not enough values error message, even if the table has 4 values and select 4 values. Am I missing something?
I have to add something to this?
I've included the types of database objects that I created on the database.
I have commented on the Original code and used the table DOUBLE just to make simple workout.
/*
CREATE or REPLACE TYPE Usage_Groups_for_coda_rec as
object
(Usage_Group_ID NUMBER (10),)
Coda_comment VARCHAR2 (45).
Amount NUMBER,
Deduction_amount NUMBER);
CREATE OR REPLACE
TYPE USAGE_GROUPS_FOR_CODA_TAB AS
TABLE OF Usage_Groups_for_coda_rec;
*/
declare
-CURSOR c_adj_roy_trans
-EAST
-SELECT DISTINCT rotr.on_behalf_of_soc_nbr, rotr.right_type
-OF royalty_transaction rumble
-WHERE rotr.ps_adjust_royalty_flg = cm_default.get_yes;
CURSOR c_adj_roy_trans
IS
SELECT '052', 'P '.
DOUBLE;
t_uge_Grp_for_coda_tab USAGE_GROUPS_FOR_CODA_TAB; -the type of table was created on the database
Start
FOR r_adj_roy_trans IN c_adj_roy_trans LOOP
-SELECT rotr.usage_group_id as Usage_Group_ID,
-cm_coda_account_default.get_canc_adj_coda_comment | '- CAE' as Coda_comment,
-SUM (NVL (rotr.gross_amt, 0) + NVL (rotr.reciprocal_deduction_amt, 0)) as an amount
-SUM (rotr.reciprocal_deduction_amt) as Deduction_amount
-COLLECT LOOSE t_uge_Grp_for_coda_tab
-OF royalty_transaction rumble
-WHERE rotr.ps_adjust_royalty_flg = cm_default.get_yes
- AND rotr.on_behalf_of_soc_nbr = r_adj_roy_trans.on_behalf_of_soc_nbr
- AND rotr.right_type = r_adj_roy_trans.right_type
-Rotr.usage_group_id group;
SELECT 6874534 as Usage_Group_ID,
"This is a test - CAE" as Coda_comment.
100 as an amount
50 as Deduction_amount
LOOSE COLLECTION t_uge_Grp_for_coda_tab
DOUBLE;
/*
IF l_uge_Grp_for_coda_tab. COUNT > 0 THEN
cm002p.std_coda_post_cashing_out_bulk (p_on_behalf_of_society_number = > r_adj_roy_trans.on_behalf_of_soc_nbr,)
p_right_type = > r_adj_roy_trans.right_type,
p_Usage_Groups_for_coda_tab = > t_uge_Grp_for_coda_tab,
p_reverse_posting_direction = > FALSE,
p_posting_override_direction = > NULL,
p_cohi_id = > NULL
);
END IF;
*/
END LOOP;
end;
Here's what you need to do:
SELECT Usage_Groups_for_coda_rec(6874534, "It is a test - CAE", 100, 50)
LOOSE COLLECTION t_uge_Grp_for_coda_tab
DOUBLE;
You try bulk collect into a collection of Usage_Groups_for_coda_recs, then you will need to make type compatible using the implicit of the type constructor.
-
ORA-00947: not enough values to choose from
Hi all
I created the type object and its type of nested table to hold the values.
But am getting error as follows:
Connected to Personal Oracle Database 10g Release 10.2.0.1.0 Connected as hr SQL> SQL> create or replace type t_obj as object 2 ( id number, 3 dt date 4 ); 5 / Type created SQL> create or replace type t_obj_nt is table of t_obj; 2 / Type created SQL> set serveroutput on SQL> SQL> declare 2 l_tab t_obj_nt; 3 4 begin 5 6 select level,(sysdate+ level) into l_tab 7 from dual connect by level < 5; 8 9 dbms_output.put_line(l_tab.count); 10 end; 11 / declare l_tab t_obj_nt; begin select level,(sysdate+ level) into l_tab from dual connect by level < 5; dbms_output.put_line(l_tab.count); end; ORA-06550: line 8, column 3: PL/SQL: ORA-00947: not enough values ORA-06550: line 7, column 3: PL/SQL: SQL Statement ignored SQL>
Concerning
SID
CREATE or REPLACE type t_obj
AS
object
(
ID NUMBER,
DT DATE);
CREATE or REPLACE type t_obj_nt
IS
TABLE OF t_obj;
-Option 1
DECLARE
l_tab t_obj_nt;
BEGIN
-You get several lines.
SELECT t_obj (level, (sysdate + level)) in BULK COLLECT INTO l_tab FROM dual CONNECT BY level<>
dbms_output.put_line (l_tab. (Count);
END;
-
Hello
I have a package body as shown below
CREATE OR REPLACE PACKAGE BODY DF AS
FUNCTION T24_GetCOPYBatchKeyAndDate (RECKEY VARCHAR2)
RETURN RTNVAL
IS
RTNVAL1 RTNVAL;
DELPOS INTEGER.
LISTSTRING VARCHAR2 (4000);
BEGIN
SELECT XMLRECORD IN LISTSTRING OF V_F_RO_COPY_KEYLIST WHERE RECID = RECKEY;LISTSTRING: = TRIM (LISTSTRING);
WHILE LENGTH (LISTSTRING) <>0
LOOP
DELPOS: = INSTR (LISTSTRING, ' ');
IF DELPOS = 0 THEN
DELPOS: = LENGTH (LISTSTRING) + 1;
END IF;
-SELECT SUBSTR (LISTSTRING, 9, DELPOS - 9) INTO RTNVAL FROM DUAL;
SELECT TO_DATE (SUBSTR (LISTSTRING, 1, 8), 'YYYYMMDD'), SUBSTR (LISTSTRING, 9, DELPOS - 9) IN THE DOUBLE RTNVAL1;
LISTSTRING: = SUBSTR (LISTSTRING, DELPOS + 1, LENGTH (LISTSTRING) - DELPOS);
END LOOP;
RETURN (RTNVAL1);
END T24_GetCOPYBatchKeyAndDate;
END DF;
/but I get compilation errors below is the error can someone let me know what is the problem here and earlier, I used this function as PIPILINED and PIPE_ROW (RTNVAL).
It was working fine now, I wanted to test this without pipeline fucntion.
SQL > SHOW ERRORS;
LINE/COL ERROR
-------- -----------------------------------------------------------------
19/5 PL/SQL: statement ignored
19/105 PL/SQL: ORA-00947: not enough values
SQL >I think you should do a
SELECT TO_DATE (SUBSTR (LISTSTRING, 1, 8), 'YYYYMMDD'), SUBSTR (LISTSTRING, 9, DELPOS - 9) BULK COLLECT INTO RTNVAL1 FROM DUAL;
that your target is an array, which must be initialized and expanded what is done by a transaction block.
HTH
-
ORA-00947 not enough values, why?
In this code, why do I get "ORA-00947 not enough of values, it has the same number of columns, just a select statement."
Help, please.
type list_employee_type is table of employee_tmp%rowtype; procedure search_by_jobId (jobId IN varchar2, list_employee_rtn OUT list_employee_type, success OUT boolean, exception_msg OUT varchar2) is begin select * into list_employee_rtn from employee_tmp where job_id = jobId ; end search_by_jobId;
>
still do not understand, can you please give me more details?
>
SQL does NOT include PL/SQL types. This is a PL/SQL type:type list_employee_type is table of employee_tmp%rowtype;
You can use in SQL:
select * into list_employee_rtn from employee_tmp where job_id = jobId
You must use a SQL type
And the full exception you was probably one like this:
>
ORA-06550: line 7, column 22:
PLS-00642: types of local collections not allowed in SQL queries
ORA-06550: line 7, column 40:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 7, column 8:
PL/SQL: SQL statement ignored
>
PLS-00642 is the exception that said you that you used the wrong type.Here are the types SQL based on the SCOTT. EMP table
-- type to match emp record create or replace type emp_scalar_type as object (EMPNO NUMBER(4) , ENAME VARCHAR2(10), JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE, SAL NUMBER(7, 2), COMM NUMBER(7, 2), DEPTNO NUMBER(2) ) / -- table of emp records create or replace type emp_table_type as table of emp_scalar_type /
Now you can use "emp_table_type" in a PL/SQL procedure, and in the select statement.
-
SQL error: ORA-00947 while using INSERT INTO
Hello
I work with an INSERT INTO statement that returns ORA-00947.
INSERT INTO prod (pId, a, b, c and d, e, f, g, h, i)
VALUES (SEQ_PROD. NEXTVAL, 1,.
(Select to_char (v.pdate, 'YYYY')
to_char(v.pdate,'MM')
d.prod
, ROUND (sum (v.f) / 10)
COUNT (*)
Of...
Group of to_char(v.pdate,'YYYY'), to_char(v.pdate,'MM'), d.prod
)
(0,0,0);
10 fields are mapped in 10 fields. The data types match. The sub-select statement works very well.
Any ideas?
SedsoINSERT INTO prod (pId,a,b,c,d,e,f ,g,h,i) select SEQ_PROD.NEXTVAL,1 a,b,c,d,e,f ,g,h,i FROM (select to_char(v.pdate,'YYYY') b, to_char(v.pdate,'MM') b, d.prod d, ROUND(sum(v.f)/10) e, COUNT(*) f,0 g,0 h,0 i from ... group by to_char(v.pdate,'YYYY'), to_char(v.pdate,'MM'), d.prod)
Try this please
-
PL/SQL: ORA-00947: not enough values error message
Hi all I get Error (25.63): PL/SQL: ORA-00947: not enough error message values when executing after the insert statement. I am new to Oracle SPs, if someone could help me solve the problem.
Insert in estimate (ID, mValue) values ('select (where pm.ID is null then 10))
of other pm.ID
End ID), m1.mID, (case when mValue < 1 and m1.mID in (1.7))
then mValue * 100
of another mValue
mValue end) of
Scott. Left outer join METRICS m1
Scott. (PROJECTMETRIC h m1.mID = pm.ID and pm.ID = 10)');The syntax to insert rows into a table of a subquery is as follows:
insert into table (col1, col2, ...) select ... , ..., .... from ..., .... where .... /
-
MapBuilder: Import of Shapefile in Oracle Spatial failed: ORA-00947
I'm trying to use the MapBuilder 11 g to import a .shp file.
I'm their import to a pre-existing table and column SDO_GEOMETRY.
I have two file types different .shp, 8307 SRID and 4326.
When you try to import a file any SRID 8307 Shapefiles, I get the message: ORA-00913 too many values for each record # tried to convert
When you try to import some SRID 8307 and SRID 4326 files, I get the message: ORA-00947: not enough values for each record # tried to convert
I was not able to import any .shp successfully yet.
Is there a problem with the .shp file, or is it another problem?
Thank you!It is possible that pre-existing table definitions differ from those in shapefiles. for example, the database table is something like
roads)
number of road_id
road_name varchar2 (64).
the sdo_geometry form)
While the shp and dbf file corresponding
road_id, road_name, road_length, form
Too many values errorInterchanging the two defs should give not enough values error
Load the shapefile into a new table. Does it work. If Yes, then copy the new table in that pre-existing and delete a new.
E.g. roads shapefiles loading in the new table roads_shp (road_id, road_name, road_length, shape)
Insert the roads select road_id, road_name, roads_shp form.
drop table roads_shp; -
DataExport problem-ODBC layer error: [21S 01] - ORA - 00947
Hello
I have a planning application from where I want to transfer data to Oracle DB in the table "t". I have 11 dimension in the planning application, so I created 12 columns in the table "t"(11 pour les membres de la dimension et le 1 col valeur) with the following script-"»
create table t)
a varchar2 (100),
b varchar2 (100),
c varchar2 (100),
d varchar2 (100),
e varchar2 (100),
f varchar2 (100),
g varchar2 (100),
h varchar2 (100),
I varchar2 (100),
j varchar2 (100),
k varchar2 (100),
number of l)
I created a wire protocol dsn. But when I run the following calcscript.
Difficulty (jan, AFA 08 budget)
DATAEXPORT 'DSN' "xz" "t" "tstschma", "password";
ENDFIX
then he demonstrated below - error
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Info (1021000)
Connection to SQL Server database is established
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Info (1012695)
DataExport cannot do insert of batch for the relational table. The driver ODBC or the RDBMS does not support the insert commands. Export SQL for registration by registration
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Info (1021013)
Layer ODBC error: [S 21, 01] == > [[DataDirect] [ODBC Oracle Wire Protocol driver] [Oracle] ORA-00947: not enough values]
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Info (1021014)
Layer ODBC error: Native [947] error Code
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Error (1012085)
Impossible to export the data to the SQL [t] table. Check the Essbase server log and the console of the system to determine the cause of the problem.
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Info (1021002)
SQL connection is released
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Warning (1080014)
Transaction [0 x 920001 (0x4a5a097a.0x7918)] abandoned due to the State [1012085].
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Info (1012579)
Total time elapsed Calc [datexprt.csc]: [0.062] seconds
[Mon Jul 13 00:04:10 2009] Local/essdb/Plan1/admin/Info (1013274)
Calculation executed
Please guide me if I am doing something wrong...
Thank you and best regards.Hello
Everything depends on you dense dimension used in your export, it will use one column for each Member.
For example, if the dense dimension on the export was time and you were doing an export from level 0 (Level0 time members are Jan: Dec)
So we should do a column for each dimension and 12 columns for each of the periods (Jan: Dec)The best way out is to export to a file first in a column, and you will see how the table should be addressed.
Columns must exactly match the exported data.
Take a look at this post, it something you can meet this way:- Re: DATAEXPORT command periods in columns in rare
See you soon
John
http://John-Goodwin.blogspot.com/ -
ORA-00947 enough values but enough of values is returned.
I know it sounds pretty obvious, but I am at a loss.
I created a package with some types, and everything has been very good compilation. However, when I ran the new feature, I got an error:
ORA-21700: object does not exist or is marked for deletion
After a little research, I realized that the types must be declared outside of the package.
As soon as I did it, I suddenly started getting error "not enough of values" on any of my. I compared the number of columns returned and the number of columns in the type, and they match.
Here is my code of type:
and this is one of the incriminated code snippets:CREATE OR REPLACE TYPE TSA_CUSTOM.Lost_Plan as object ( LP_Key number, -- The member key of the plan that is going away LP_Type varchar2(20), LP_Dept varchar2(12), LP_SubDept varchar2(12), LP_Class varchar2(12), LP_VendorName varchar2(50) ); CREATE OR REPLACE TYPE TSA_CUSTOM.Target_Plan as object ( Tgt_Key number, -- The member key of the plan that the Lost plan data will be moving to Tgt_Dept varchar2(12), Tgt_SubDept varchar2(12), Tgt_Class varchar2(12), Tgt_VendorName varchar2(50) ); CREATE OR REPLACE TYPE TSA_CUSTOM.Output_Plan as object ( LP_Result varchar2(8), -- Either 'MOVED' or 'DROPPED' LP_Key number, -- The member key of the plan that is going away LP_Type varchar2(20), LP_Dept varchar2(12), LP_SubDept varchar2(12), LP_Class varchar2(12), LP_VendorName varchar2(50), Tgt_Key number, -- The member key of the plan that the Lost plan data will be moving to Tgt_Dept varchar2(12), Tgt_SubDept varchar2(12), Tgt_Class varchar2(12), Tgt_VendorName varchar2(50) ); / -- table of lost plans CREATE OR REPLACE TYPE TSA_CUSTOM.Lost_Plans as table of tsa_custom.Lost_Plan; CREATE OR REPLACE TYPE TSA_CUSTOM.Target_Plans as table of tsa_custom.Target_Plan; CREATE OR REPLACE TYPE TSA_CUSTOM.Output_Plans as table of tsa_custom.Output_Plan; /
Any help would be appreciated.function Calc_Lost_Plan_Moves return tsa_custom.Output_Plans pipelined is -- define the lost plan recordset v_LP_Store tsa_custom.Lost_Plans; v_Tgt_Store tsa_custom.Target_Plans; v_Output_Store tsa_custom.Output_Plans; Begin -- Get all the vendor class lost plans select ep.ra_member_key , 'Vendor Class', ep.dept_cd, ep.subdept_cd, ep.class_cd, ep.vendor_name_id bulk collect into v_LP_Store from (select distinct ra_member_key , dept_cd, subdept_cd, class_cd, vendor_name_id, class_member_id from tsa_custom.v_ep_vendor_class) ep ,(select distinct 'CL'||class_hier_cd as class_cd, vndr_nm from mdm_publish.v_planning_master) mdm where ep.class_member_id = mdm.class_cd(+) and ep.vendor_name_id = mdm.vndr_nm(+) and mdm.class_cd is null;
Thank you!
JohnHello
v_LP_store is defined as an array of objects, then you will need to collect objects in there, not the columns in bulk:
select TSA_CUSTOM.Lost_Plan( ep.ra_member_key , 'Vendor Class' , ep.dept_cd , ep.subdept_cd , ep.class_cd , ep.vendor_name_id ) bulk collect into v_LP_Store from ...
I created a package with some types, and everything has been very good compilation. However, when I ran the new feature, I got an error:
ORA-21700: object does not exist or is marked for deletionSometimes, this error is resolved by simply disconnecting the session and reconnect.
After a little research, I realized that the types must be declared outside of the package.
Are you sure?
Packed types can be used to support the pipeline functions (defined in the same package).
Oracle will create transparent and manage objects corresponding SQL types.Edited by: odie_63 Dec 18. 2012 20:15
-
PL / SQL: ORA-00947: there are enough values
Why this error?INSERT INTO FUNCIONARIOS (nome, apelido, codigo, tipo, cnpj, cic, rg, ie, identifica_palm, data_nascimento, data_entrada, data_admissao, data_demissao, data_cadastro, estadocivil, e_mail, sexo, pesq_colaborador, senha) VALUES p_nome, p_apelido, p_codigo, p_tp_pes, p_cpfcnpj, p_cpfcnpj, p_rgie, p_rgie, p_palm, v_dt_nasc, v_dt_ent, v_dt_adm, v_dt_dem, v_dt_cad, p_estadocivil, p_e_mail, p_sexo, p_pesq_colaborador, p_senha);
You forgot the opening parenthesis
VALUES
* (* p_nome,
p_apelido,
p_codigo, -
View materialized, ORA-12008: error in the path of refresh materialized view
I want to refresh a materialized view, but I get an error ORA-12008.
Does anyone have an idea? I can't find any errors in my update statement.
CREATE MATERIALIZED VIEW scott.dummy_mv TABLESPACE test BUILD IMMEDIATE USING INDEX TABLESPACE idx_test REFRESH START WITH sysdate NEXT ROUND(SYSDATE)+5/24 WITH PRIMARY KEY ENABLE QUERY REWRITE AS SELECT KM.ID ID ,KM.USERNAME USERNAME ,KM.ABTID ABTID FROM my_table KM / scott@orcl>desc dummy_mv Name Null? Typ ----------------------------------------- -------- ---------------------------- ID NOT NULL NUMBER(4) USERNAME NOT NULL VARCHAR2(30) ABTID NOT NULL NUMBER(4) scott@orcl> BEGIN SYS.DBMS_JOB.REMOVE(6579); COMMIT; END; / DECLARE X NUMBER; BEGIN SYS.DBMS_JOB.SUBMIT ( job => X ,what => 'dbms_refresh.refresh(''"scott"."dummy_mv"'');' ,next_date => to_date('07.01.2009 05:00:00','dd/mm/yyyy hh24:mi:ss') ,interval => 'ROUND(SYSDATE)+5/24 ' ,no_parse => FALSE ); SYS.DBMS_OUTPUT.PUT_LINE('Job Number is: ' || to_char(x)); COMMIT; END; / scott@orcl>exec dbms_refresh.refresh('dummy_mv'); BEGIN dbms_refresh.refresh('dummy_mv'); END; * FEHLER in Zeile 1: ORA-12008: error in materialized view refresh path ORA-00947: not enough values ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 820 ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 877 ORA-06512: in "SYS.DBMS_IREFRESH", Zeile 683 ORA-06512: in "SYS.DBMS_REFRESH", Zeile 195 ORA-06512: in Zeile 1 scott@orcl>
dealer says:
I get the same error:scott@orcl>exec dbms_mview.refresh('dummy_mv','c'); BEGIN dbms_mview.refresh('dummy_mv','c'); END; * FEHLER in Zeile 1: ORA-12008: error in materialized view refresh path ORA-00947: not enough values ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 820 ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 877 ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 858 ORA-06512: in Zeile 1
I would first check "request" from the view of the DBA_SNAPSHOTS/DBA_MVIEWS dictionary information, if it reveals something obvious.
But it looks more like an internal error when processing the update. You can get more information on the follow-up to the session error. "Alter session set sql_trace = true;" before running the update should be sufficient. Then unplug and check the trace file generated error using "tkprof" and check the output or by searching manually "err =" in the trace file.
What 4 numbers of Oracle version do you use?
Kind regards
RandolfOracle related blog stuff:
http://Oracle-Randolf.blogspot.com/SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/ -
Inserting data from a query to an existing table
How do I change my code to make it work correctly? It currently compiles I think because the program believes that the size of v_stats_5d_1 can be different from c_stats_5d_1. I have these errors:
LINE/COL ERROR
-------- ------------------------------------
30/10 PL/SQL: statement ignored
30/23 PL/SQL: ORA-00947: not enough values
CREATE OR REPLACE PACKAGE IN THE PKG_RISK_MONITOR
PROCEDURE CREATE_STATS_5D)
P_CONTEXT_DATE IN VARCHAR2
);
END PKG_RISK_MONITOR;
/
CREATE OR REPLACE PACKAGE BODY PKG_RISK_MONITOR AS
PROCEDURE CREATE_STATS_5D)
P_CONTEXT_DATE IN VARCHAR2
)
IS
l_ct NUMBER;
CURSOR c_stats_5d_1
IS
SELECT MIND_ACCOUNTS. CLIENT_ID, MIND_ACCOUNTS. CLIENT_NAME, SUM (DATA. CREATED_TRANSACTIONS_NUMBER) AS SUM_CREATED_TRX_NUMBER, SUM (DATA. CREATED_refunds_NUMBER) SUM_CREATED_REFUNDS_NUMBER, SUM (DATA. CREATED_TRANSACTIONS_value * Conversion_rate) CREATED_TRX_EUR_VALUE, DATA. PROCESSING_DATE
OF (MIND_ACCOUNTS INNER JOIN DATA ON MIND_ACCOUNTS. ACCOUNT_ID = DATA. CURRENCY_conversion INNER JOIN MERCHANT_CID) ON THE DATA. CURRENCY = CURRENCY_conversion. CURRENCY
GROUP OF MIND_ACCOUNTS. CLIENT_ID, MIND_ACCOUNTS. CLIENT_NAME, DATA. PROCESSING_DATE
(DATA. PROCESSING_DATE > = TO_DATE (P_CONTEXT_DATE, 'dd-mm-yyyy')-4) and DATA. PROCESSING_DATE < = TO_DATE (P_CONTEXT_DATE, ' dd-mm-yyyy "")
;
v_stats_5d_1 "TMP_STATS_5D_1" % rowtype;
BEGIN
-Insert subquery data into an empty table
OPEN c_stats_5d_1.
LOOP
SEEK c_stats_5d_1 INTO v_stats_5d_1;
EXIT WHEN c_stats_5d_1% NOTFOUND;
INSERT INTO 'TMP_STATS_5D_1 '.
VALUES (v_stats_5d_1);
END LOOP;
END CREATE_STATS_5D;
END PKG_RISK_MONITOR;
/
DISPLAY ERRORS
THX. Managed to get there in the end:
CREATE OR REPLACE PACKAGE IN THE PKG_RISK_MONITOR
PROCEDURE CREATE_STATS_5D)
P_CONTEXT_DATE IN VARCHAR2
);
END PKG_RISK_MONITOR;
/
CREATE OR REPLACE PACKAGE BODY PKG_RISK_MONITOR AS
PROCEDURE CREATE_STATS_5D)
P_CONTEXT_DATE IN VARCHAR2
)
IS
l_ct NUMBER;
v_sql VARCHAR2 (1000);
BEGIN
-Determine whether the table exists.
Select count (*) in l_ct
from user_tables
where table_name = 'TMP_STATS_5D_1 ';
-Remove the table if it exists.
If l_ct = 1 then
run immediately "drop table TMP_STATS_5D_1;
end if;
v_sql: = q'[CREATE TABLE 'TMP_STATS_5D_1' AS
SELECT m.client_id,
m.client_name,
Sum (d.created_transactions_number) AS sum_created_trx_number,
Sum (d.created_refunds_number) AS sum_created_refunds_number,
Sum(d.created_transactions_value * conversion_rate) AS created_trx_eur_value,
d.processing_date
M 'MIND_ACCOUNTS '.
INNER JOIN 'DATA' m.account_id d = d.merchant_cid
INNER JOIN 'CURRENCY_CONVERSION' c ON d.currency = c.currency
WHERE (d.processing_date > = To_date ('] '))
|| P_CONTEXT_DATE |
q'[(', ' dd-mm-yyyy') (-4) AND d.processing_date]<=>=>
|| P_CONTEXT_DATE |
q'[',' dd-mm-yyyy ")"]
GROUP OF m.client_id, m.client_name, d.processing_date] ";
immediately run v_sql;
END CREATE_STATS_5D;
END PKG_RISK_MONITOR;
/
DISPLAY ERRORS
-
Get 'not enough values error' in bulk collect
I want to insert all the rows in the employees table in the tmp table which has the structure.
Purpose: Try just feature fired block to create a return to the top of a table.
Problem: My code is to not "enough of values" error please report if mistaken.
structure of the employees table:
SQL > desc employee;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYEE_ID NOT NULL NUMBER (6)
FIRST NAME VARCHAR2 (20)
LAST_NAME NOT NULL VARCHAR2 (25)
EMAIL NOT NULL VARCHAR2 (25)
PHONE_NUMBER VARCHAR2 (20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2 (10)
SALARY NUMBER (8.2)
COMMISSION_PCT NUMBER (2.2)
MANAGER_ID NUMBER (6)
DEPARTMENT_ID NUMBER 4
tmp table structure:
SQL > tmp desc;
Name Null? Type
----------------------------------------- -------- ----------------------------
EMPLOYE_ID NUMBER (6)
FIRST NAME VARCHAR2 (20)
LAST_NAME NOT NULL VARCHAR2 (25)
EMAIL NOT NULL VARCHAR2 (25)
PHONE_NUMBER VARCHAR2 (20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2 (10)
SALARY NUMBER (8.2)
COMMISSION_PCT NUMBER (2.2)
MANAGER_ID NUMBER (6)
DEPARTMENT_ID NUMBER 4
SQL > select * from tmp;
no selected line
Code:
declare
type rec is the employee table % rowtype
index by pls_integer;
a rec;
Start
Select * bulk collect in a
employees;
ForAll i in a.first... a.Last
Insert into tmp values (a (i));
end;
/
Result:
SQL > declare
2
3 type rec is the employee table % rowtype
4 index of pls_integer;
5 a rec;
6
7. start
8 remove tmp;
9 select * bulk collect in a
10 employees;
11 ForAll i in a.first... a.Last
12 insert into tmp values (a (i));
13 end;
14.
Insert into tmp values (a (i));
*
ERROR on line 12:
ORA-06550: line 12, column 13:
PL/SQL: ORA-00947: not enough values
ORA-06550: line 12, column 1:
PL/SQL: SQL statement ignored
Remove parentheses
insert into tmp values a(i);
or call the individual columns
insert into tmp( employee_id, first_name, ... ) values( a(i).employee_id, a(i).first_name, ... );
Justin
-
Trigger - use one to create primary key values
I'm stuck on a simple use to do a TRIGGER that fires when you add new rows to a table and want to Developer SQL to add the primary key value.
I seem to be able to relax, but it is not inserted the primary key but giving a SQL error: ORA-00947: not enough values.
Here's what I have.
CREATE TABLE HF_fishers
(
contact_id INT NOT NULL
, name VARCHAR (25)
, last_name VARCHAR (35)
PRIMARY KEY (contact_id)
);
CREATE SEQUENCES HF_fishers_seq.
Then I ran the following trigger:
CREATE
HF_fishers_seq_trigger RELAXATION
BEFORE INSERTING
ON HF_fishers
FOR EACH LINE
BEGIN
IF (: new.contact_id IS NULL)
THEN
: NEW.contact_id: = NVL (: NEW.contact_id)
HF_fishers_seq. NEXTVAL
);
END IF;
END HF_fishers_seq_trigger;
=============
Then I executed the following SQL statement that gives the error.
INSERT INTO HF_fishers VALUES('Jacob','Muller');
But if I do everything is good except that it defeats the purpose of relaxation.
INSERT INTO HF_fishers VALUES(1,'Jacob','Muller');
MySQL has a nice 'AUTO_INCREMENT' command, but from what I understand in Oracle, I need to set up a trigger to automatically increment a column/cell, which in this case I use for the PRIMARY KEY.
3003916 wrote:
OK Jaramillo, I tried as you wrote, but what would be an INSERT statement correct?
-After the code trigger of Jaramillo
INSERT INTO HF_fishers (first_name, last_name) values ("Jesse", "Owens"); -I have the trigger but he made the mistake of duplicate key.
INSERT INTO HF_fishers values (hf_fishers_seq.nextval, 'Jesse', "Owens"); -No trigger but get key duplicated,.
INSERT INTO HF_fishers VALUES(:NEW_contact_id,'Jesse','Ownes'); -works without the trigger but the "get links" dialog box appears. So not much 'automatic' on this issue,.
My mistake. Here is the modified version of the trigger. I removed the CONDITIONAL clause and comes to be a part of the body of the trigger.
So, I created the table, the sequence, the relaxation and ran the first two insert statements and it worked fine. The third one you have invites SQL + or any tool you use to enter a value if she sees the ":" colon as a variable binding. Colon only works in a trigger without asking for confirmation.
Here is the code and my exit I ran home
DROP TABLE hf_fishers CASCADE CONSTRAINTS PURGE; DROP SEQUENCE hf_fishers_seq; CREATE TABLE hf_fishers ( contact_id INTEGER NOT NULL ,first_name VARCHAR(25) ,last_name VARCHAR(35) ,PRIMARY KEY (contact_id) ); CREATE SEQUENCE hf_fishers_seq; CREATE OR REPLACE TRIGGER hf_fishers_seq_trigger BEFORE INSERT ON hf_fishers FOR EACH ROW BEGIN IF(:NEW.contact_id IS NULL) THEN :NEW.contact_id := hf_fishers_seq.NEXTVAL; END IF; END hf_fishers_seq_trigger; INSERT INTO hf_fishers(first_name, last_name) VALUES ('Jesse', 'Owens'); -- Works with the trigger INSERT INTO hf_fishers VALUES (hf_fishers_seq.nextval, 'Jesse', 'Owens'); --Works without using the trigger body code. SELECT * FROM hf_fishers; COMMIT;
The output
Deleted table.
Elapsed time: 00:00:00.05
Sequence has fallen.
Elapsed time: 00:00:00.02
Table created.
Elapsed time: 00:00:00.03
Order of creation.
Elapsed time: 00:00:00.02
Trigger created.
Elapsed time: 00:00:01.05
1 line of creation.
Elapsed time: 00:00:00.04
1 line of creation.
Elapsed time: 00:00:00.01
CONTACT_ID FIRST NAME LAST NAME
---------- ------------------------- -----------------------------------
1 Jesse Owens
2 Jesse Owens
2 selected lines.
Elapsed time: 00:00:00.04
Validation complete.
Elapsed time: 00:00:00.01
Maybe you are looking for
-
restoring iPhone "requires a more recent version of iOS.
iPhone running iOS 9.2.1 + 6. Saved on older MacBook 10.6.8 which is the latest version of the operating system will install running. Phone has been replaced earlier today from the Apple Store. Now try to simply restore the backup. Error message
-
decommissioning of the hp pavilion 2215dx windows 8 for windows 7 prof
f Decommissioning experience so far. The only problem I had seemed to come of my allowing the Windows 7 pro, install more than 150 updates, which took all day, and then the computer died on me! lol I took a breath, turned on the computer, press ESC a
-
The blue screen with stop continues to appear randomly and everything closed options.
using screen blure xp2000-The windows guard poop upward and it stops even the task manager.it destroyed my work and everything is open :( Can someone tell me how to stop this blue screen please?
-
Recover a program I accidentally deleted
I need help recovering a sound program I accidentally deleted, could someone tell me how I can get it back?
-
HP Envy 15 t-3200-dvd player does not, code 19
Hi, I just signed up get this question. I'm 15, I had a year ago, but the dvd - rom drive does not work. Whenever I inserted a dvd, the drive would go, but it would not be displayed in the Explorer. I went to Device Manager and it says that the regi