the selection of the PL/SQL nested block table error...
SQL > create type string_table is the table of the varchar (100);2.
Type of creation.
declare
v_names string_table: = string_table();
Start
v_names. EXTEND (3);
v_names (1): = "Name1"
v_names (2): = "Name2";
v_names (3): = 'name3 ';
dbms_output.put_line (v_names (1));
dbms_output.put_line (v_names (2));
dbms_output.put_line (v_names (3));
dbms_output.put_line (v_names. COUNT());
Select * from table (v_names);
end;
/
Select * from table (v_names);
*
ERROR on line 12:
ORA-06550: line 12, column 7:
PLS-00428: an INTO clause in this SELECT statement
Select * from table (v_names);
I guess, here you have tried to put the contents of the NT NT one another, or simply trying to print it.
But I don't think that INTO Clause is mandatory here.
Please check your modified code (w/o INTO) and the output:
DECLARE
TYPE string_table IS TABLE OF VARCHAR (100);
v_names string_table := string_table ();
v_test string_table := string_table ();
BEGIN
v_names.EXTEND (3);
v_names (1) := 'name1';
v_names (2) := 'name2';
v_names (3) := 'name3';
DBMS_OUTPUT.put_line ('Old collection - '||v_names (1));
DBMS_OUTPUT.put_line ('Old collection - '||v_names (2));
DBMS_OUTPUT.put_line ('Old collection - '||v_names (3));
DBMS_OUTPUT.put_line ('Old collection - '||v_names.COUNT ());
DBMS_OUTPUT.put_line (CHR(10));
/* SELECT * FROM TABLE (v_names); */
v_test := v_names;
DBMS_OUTPUT.put_line ('New collection -- '||v_test (1));
DBMS_OUTPUT.put_line ('New collection -- '||v_test (2));
DBMS_OUTPUT.put_line ('New collection -- '||v_test (3));
DBMS_OUTPUT.put_line ('New collection -- '||v_test.COUNT ());
DBMS_OUTPUT.put_line (CHR(10));
/* Printing using FOR LOOP */
FOR i IN v_test.FIRST..v_test.LAST
LOOP
DBMS_OUTPUT.put_line ('In FOR Loop --- '||v_test (i));
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error ' ||SQLERRM|| DBMS_UTILITY.format_error_backtrace);
END;
gives o/p:
Old collection - name1
Old collection - name2
Old collection - name3
Old collection - 3
New collection -- name1
New collection -- name2
New collection -- name3
New collection -- 3
In FOR Loop --- name1
In FOR Loop --- name2
In FOR Loop --- name3
See this link - http://docs.oracle.com/cd/E11882_01/appdev.112/e17126/tuning.htm#CIHGGBGF
Published by: Vanessa B on 26 December 2012 14:29
-modified code
Published by: Vanessa B on 26 December 2012 14:45
LOOP FOR-updated - added 'again' code
Tags: Database
Similar Questions
-
What are the changes to nested ESX?
-MattG
Our approach to the occultation of nested page tables has been completely rewritten. This should improve the performance of computers virtual nested vSMP and several VMs performance nested under the same hypervisor of comments. It should also reduce the memory overhead for nested virtualization.
AMD Bobcat and Bulldozer processors support has been improved.
Supported hypervisors of competitors has been improved.
In general, the performance and reliability have been improved.
-
Why nested block is not executed here?
I created a procedure that will populate the tables and their counts in a scheme from when you run this procedure. For pl/sql nested block demonstration purposes and also I will create a trigger to update this table. Here is my code.
create or replace procedure schema_tab_count as
c number;
Start
Declare
Table_exist exception;
pragma exception_init (Table_exist,-00955);
Start
run immediately ' create table schema_tab_cnt (table_name varchar2 (30), count of number (10))';
exception when Table_exist then
run immediately 'Truncate table schema_tab_cnt;
end;
because me in (select * from tab) loop
run immediately ' count (1) select "| i.tname in c;
insert into schema_tab_cnt values (i.tname, c);
end loop;
commit;
exception: when other then null;
end;
/
CAUTION: Procedure created with compilation errors.
SQL > sho err
Errors in PROCEDURE SCHEMA_TAB_COUNT:
LINE/COL ERROR
-------- -----------------------------------------------------------------
14/1 PL/SQL: statement ignored
14/13 PL/SQL: ORA-00942: table or view does not exist
SQL >
Since the error log, its clear that the code in the nested block is not running.
What is the reason and the solution for this?
Thank you.
Ok as you have stated this code is for DEMO purpose I am going to proceed further and fix your code. If you are going to use it for any actual production purpose then its a bad idea and you should not do it. Also do not use EXCEPTION WHEN OTHERS the way you have used. Its always certainly a bug. Always WHEN OTHERS exception must be followed by RAISE. The issue is with your insert statement. The table actually does not exist when you are compiling the code. So you need to make your insert statement as Dynamic SQL so that it is not validated during compilation. Like this. SQL> create or replace procedure schema_tab_count 2 as 3 c number; 4 begin 5 declare 6 table_exist exception; 7 pragma exception_init (table_exist, -00955 ) ; 8 begin 9 execute immediate 'create table schema_tab_cnt(table_name varchar2(30),count number(10))'; 10 exception 11 when table_exist then 12 execute immediate 'truncate table schema_tab_cnt'; 13 end; 14 15 for i in (select * from tab) 16 loop 17 execute immediate 'select count(1) from "' || i.tname || '"' into c; 18 execute immediate 'insert into schema_tab_cnt values(:1,:2)' using i.tname, c; 19 end loop; 20 21 commit; 22 end; 23 / Procedure created. SQL> exec schema_tab_count PL/SQL procedure successfully completed. SQL> select * from schema_tab_cnt; TABLE_NAME COUNT ------------------------------ ---------- BIN$+4sdomixCCXgRAAUTz6XRg==$0 12 BIN$+4sdomiyCCXgRAAUTz6XRg==$0 2 BIN$/BgKoshic2jgRAAUTz6XRg==$0 500000 DEPT 4 EFF_RATE_TMP 0 EMP 11 E_MAIL_LOG 0 LOGGER 0 SCHEMA_TAB_CNT 8 TEST_MIG 2 10 rows selected. SQL>
-
Error in the pl/sql block using associative arrays
Hello
I tried the following block of code using associative arrays.
and the error isDECLARE TYPE NumTab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; CURSOR c1 IS SELECT empno FROM emp; empnos NumTab; rows NATURAL := 10; BEGIN OPEN c1; FOR i in empnos.first..empnos.last LOOP /* The following statement fetches 10 rows (or less). */ FETCH c1 BULK COLLECT INTO empnos LIMIT rows; EXIT WHEN c1%NOTFOUND; DBMS_OUTPUT.PUT_LINE ( empnos.next(i)); END LOOP; CLOSE c1; END;
could you please let me know where I am going wrongDECLARE * ERROR at line 1: ORA-06502: PL/SQL: numeric or value error ORA-06512: at line 8
and please guide me where we use these associative arrays.
Thank youTry this
DECLARE TYPE NumTab IS TABLE OF emp%rowtype INDEX BY PLS_INTEGER; CURSOR c1 IS SELECT * FROM emp; empnos NumTab; rows INTEGER := 10; BEGIN OPEN C1; LOOP FETCH c1 BULK COLLECT INTO empnos LIMIT rows; EXIT WHEN c1%NOTFOUND; FOR i IN 1..empnos.count LOOP DBMS_OUTPUT.PUT_LINE(empnos(i).empno || '/' || empnos(i).ename); END LOOP; END LOOP; END;
-
SQL solution to the hierarchy of nested game difficulty
I have a good job pl/sql solution to my problem and I am just curious to know if there is an a sql
I have a structure of tree for example:
one
b and c
d e f
g h i j k
create table tree
(key primary number (6) ID)
, number (6) parent_id
, root_id number (6) not null
-, lft number 4 not null
-GTA 4 number not null
);
create the table tree_update
(key primary number (10) ID)
, lft number (10) not null
, number (10) of the GTA
);
Insert the values of Apple ('a', null, 'a');
Insert Apple values ('b', 'a', 'a');
Insert Apple values ('c', 'a', 'a');
Insert the values of the Apple trees (a ',' b', 'a');
Insert Apple values ('e', 'c', ' a');
Insert the values of the Apple trees ('f', 'c', ' a');
Insert the values of the Apple trees ('g' 'd', 'a' ");
Insert the values of the Apple trees ('h' 'd', 'a' ");
Insert the values of the Apple trees ('i', 'e', ' a');
Insert the values of the Apple trees ('j', 'f', ' a');
Insert the values of the Apple trees ('k', 'f', ' a');The product that uses it also uses 'left' and 'right' value to browse. In this way, that descendants of a node can be calculated using
Select *.
tree
where lft >: node_left
and GTA are: node_rgt;See http://en.wikipedia.org/wiki/Nested_set_model for more details
Unfortunately the lft and rgt value can get corrupt, especially during simultaneous updates in the rows in the tree. So I need to apply periodic corrections
I did it using the pl/sql recursive. It's my pl/sql:
create or replace procedure setLeftRight
(ParentId in full
CurrLeft in out integer
)
as
nLeft integer: = CurrLeft + 1;
Start
for r in
(select id
tree
where parent_id = ParentId
or (parent_id is null and ParentId is null)
order by id
)
loop
insert into tree_update
(id
lft
)
values
(r.id
nLeft,
);setLeftRight
(r.id
nLeft,
);
end loop;
Update tree_update
define the GTA = nLeft
where id = ParentId
return of the GTA + 1 in CurrLeft;
end setLeftRight;
/
Sho errand it is called with:
number of GTA var
exec: GTA: = 0
exec setLeftRight(null,:rgt)leaving the correct answers as
ID lft GTA
------- --- ---
a 22 1
2 9 b
3 8 d
4 5 g
6-7 pm
10 21 c
11 14 e
I have 12 13
f 15 20
16-19 j
17 18 k
Again, I am just curious to know if there is a sql solution. I can assign a sequential value to each line using the factoring of the subquery recursive and scope of research first, in both directions. But doing so, then join, then reassess the values lft and rgt seems heavy.
You should also note that rgt - lft = 2 x < number of descendants > + 1, if they are assigned in the order (which is not really necessary because one order is important). I use this to check my values before committing.
So is there a solution of elegant sql, in any version of db, but I am currently on 11.2.0.3.
Thank you
Ben
Hi, Ben.
Yes, you can do it in pure SQL. See the last answer in the following thread:
https://community.Oracle.com/thread/2603314
You don't need a table like tree_update just to cool left and GTA (and root_id, if it gets corrupted, too). You can use a MERGE statement to derive the correct values and update the table tree directly.
In the sample data that you have published, all values are strings, but all the columns are numbers.
You know exactly when the lft and rgt columns are getting corrupted?
If so, it would be more logical to fix this.
If you don't know when these columns are getting corrupted, so it seems that these columns would be useless, since you can be sure that the results based on these columns are accurate.
-
Ignore the error and continue the pl/sql block
Dear all,
Please help me to fix the script below.
I had an obligation to write a pl/sql that will handle the update instructions.
For example:
A table that contains 10 rows of data. Through pl/SQL block, I update the 10 rows (or a smaller number of lines).
Now, the scenario is by updating registration / line 4, oracle has met an error and then oracle leave pl/sql block and cancel the transaction.
My requirement here is, by updating the records, if oracle encounters an error, it must raise an error or ignore the record and continue to process records. Oracle wouldn't pl/sql block.
We are using oracle 10g.
Thank you
KODSAs has already been suggested, you might check DML ERROR LOGGING
-
Open the pl/sql block pop title request page
Hi all
Can someone show me the correct syntax for opening a page of the application in a window popup using
of htp.p of pl/sql with (parameters of the page.) or local variables of the pl/sql block?
And also how can force you a refresh of the page parent once the pop-up was closed.
Any help would be appreciated.
Kind regards
CleoHello
To generate a link to a pop-up window on your parent page:
htp.p(' <a href="javascript:callPopup('||:P1_ID|| ')" > ');
And add this in the header html on your parent page:
<script type="text/javascript" > function callPopup(recordId){ var url; url = 'f?p=&APP_ID.:POPUPPAGEALIAS:&APP_SESSION.::::P_RECORD_ID:' + recordId; w = open(url,"textarea","Scrollbars=1,resizable=1,width=800,height=600"); if (w.opener == null) w.opener = self; w.focus(); } </script >
And to refresh the page parent after the closure of the pop-up window, add to the html on your popup page header:
<BODY onUnload="javascript: window.opener.location.reload(true);">
-
Select dba_directories in the pl/sql procedure
Hello
I tried to do it in a procedure, but got an error:
-----
Select count (*) in the dba_directories ocount where directory_name = "DIR0001";
-----
error: table or view does not exist.
Someone suggest where we can find this table?
Thank you.This means that you don't have the right to select on this data dictionary view. And you shouldn't have it. Ask the ALL_DIRECTORIES view for all the directories that are accessible to the current user.
SY.
-
Return a pointer to extproc c to the pl/sql module
Hi all
I would like to get a pointer to a structure within a c module called from a pl/sql block.
Here is an example
The C module
#include < stdio.h >
typedef struct
{
gval int;
} sgval;
sgval myval;
int getval (void)
{
return (myval.gval);
}
int getvalfromadr (unsigned adr)
{
If (adr == (unsigned) & myval)
return 2;
on the other
return 5;
}
Sub setval (int val)
{
myVal.gval = val;
}
getadrval (void) unsigned
{
return (unsigned) & myval;
}
The library and the functions
create or replace the c_btree library under ' / home/oracle/btree.so';
/
create or replace procedure setval (val pls_integer) is
external
Library sys.c_btree
name "setval.
C language
Calling standard C;
/
create or replace function getval pls_integer return is
external
Library sys.c_btree
name "getval '.
C language
Calling standard C;
/
create or replace function getadrval return pls_integer is
external
Library sys.c_btree
name "getadrval".
C language
Calling standard C;
/
create or replace function getvalfromadr (adr pls_integer) return pls_integer is
external
Library sys.c_btree
name "getvalfromadr".
C language
Calling standard C;
/
And the test
Set serveroutput on
declare
str1 varchar2 (20);
VARCHAR2 (20) str2;
RC pls_integer: = 0;
ADR pls_integer;
Start
SETVAL (10); -Initialize the global variable in the c module
RC: = getval; -Get the value of the global variable
dbms_output.put_line (' rc ='|) RC);
-Try to get the address of the global variable in the c module
ADR: = getadrval;
dbms_output.put_line (' adr ='|) (ADR); --also got a negative number, probably the wrong type for this information?
-check if I address at, for sure not!
RC: = getvalfromadr (adr);
dbms_output.put_line (' rc ='|) RC); -return 5 as not equal.
end;
/
Execution of
PL/SQL procedure successfully completed. SQL > /rc = 10adr =-100263692rc = 5
What's wrong? What is the correct type should I use for this?
Thank you very much
jko
When I hear the ITO in memory it is nothing to do with the physical structure well known of ITO.
I mean the value in memory B * Tree that could store of complex structure for fast accessed directly integrated and usable with Sql and PL/Sql.
I have no problem to solve. just a few ideas and some time
OK - but the band fundamental question is WHY. Why did you choose to try to use the PL/SQL for this?
Why have no plans to use Java instead? It supports the "long" integer data type and has excellent variety and nested object support.
You can also access this Java code from other modules to 'share' the data and even to use Java in the database so that was really necessary.
-
Hi all;
I'm changing the dbid of the database, but not able to change it.
SQL > select dbid from v database $;
DBID
1356943142
SQL > shutdown immediate;
The database is closed.
The database is dismounted.
ORACLE instance stops.
SQL > bootable media.
ORACLE instance started.
Total System Global Area 608174080 bytes
Bytes of size 1268920 fixed
188744520 variable size bytes
415236096 of database buffers bytes
Redo buffers 2924544 bytes
Mounted database.
SQL >!
[oracle@oel5 ~] $ which nest
/U01/app/Oracle/product/10.2.0/Db_1/bin/NID
[oracle@oel5 ~] nest target $ = /.
DBNEWID: Release 10.2.0.4.0 - Production on Thu Oct 24 07:41:35 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to the database CLONE (DBID = 1356943142)
Connected to the server version 10.2.0
Control of database files:
/ u01/app/oracle/oradata/clone/control01. CTL
/ u01/app/oracle/oradata/clone/control02. CTL
/ u01/app/oracle/oradata/clone/control03. CTL
Change the ID of database CLONE database? (Y / [N]) = > Y
Proceed with the operation
Change the ID of 1356943142 to 1028450799 database
Control file /u01/app/oracle/oradata/clone/control01.ctl - modified
Control file /u01/app/oracle/oradata/clone/control02.ctl - modified
Control file /u01/app/oracle/oradata/clone/control03.ctl - modified
DataFile /u01/app/oracle/oradata/clone/system01.dbf - dbid changed
DataFile /u01/app/oracle/oradata/clone/undotbs01.dbf - dbid changed
DataFile /u01/app/oracle/oradata/clone/sysaux01.dbf - dbid changed
DataFile /u01/app/oracle/oradata/clone/users01.dbf - dbid changed
DataFile /u01/app/oracle/oradata/clone/example01.dbf - dbid changed
DataFile /u01/app/oracle/oradata/clone/temp01.dbf - dbid changed
Control file /u01/app/oracle/oradata/clone/control01.ctl - dbid changed
Control file /u01/app/oracle/oradata/clone/control02.ctl - dbid changed
Control file /u01/app/oracle/oradata/clone/control03.ctl - dbid changed
at least I'm waiting for 20 minutes... then I hit ctrl + c
NEST-00600: internal error - [28] [1013] [0] [0]
Change the database ID failed during validation - database is intact.
DBNEWID - complete with validation errors.
Once you issue the STARTUP SQLPlus MOUNT, OUTPUT of SQLPlus instead open a shell comand using the «!» (the host command) option, then run the command of nest. Your current SQLPlus session probably prevents closing of the database completed.
Kind regards
Bob
-
execute the dynamic sql statement
Hi all
CREATE TABLE XX_OFFICE_USER_IMP ( ID NUMBER, OFFICE VARCHAR2(10 BYTE), USER_NAME VARCHAR2(10 BYTE), BANK_ACCOUNT_ID NUMBER, TRANSFERED NUMBER )
Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (421,'0000','F0000',10029,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (422,'0000','F0000',10031,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (423,'0000','F0000',10033,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (424,'0000','F0000',10036,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (425,'0000','F0000',10037,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (426,'0000','F0000',10039,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (427,'0000','F0000',10041,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (428,'0000','F0000',10046,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (429,'0000','F0000',10048,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (430,'0000','F0000',10067,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (431,'0000','F0000',10072,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (432,'0000','F0000',10087,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (433,'0000','F0000',10092,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (434,'0000','F0000',10008,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (435,'0000','F0000',10012,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (436,'0000','F0000',10013,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (437,'0000','F0000',10014,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (438,'0000','F0000',10017,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (439,'0000','F0000',10019,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (440,'0000','F0000',10024,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (441,'0000','F0000',10025,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (442,'0000','F0000',10001,null); Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (443,'0000','F0000',10002,null);
CREATE TABLE XXBG_CASIER_CASH ( CASHIER VARCHAR2(32 BYTE), BANK_ACCOUNT_ID NUMBER(38,0) )
After execute the PL/SQL block I get the message:declare v_exe_grant varchar2(32767 char); begin for i in (select * from xx_office_user_imp where office = '0000') loop insert into XXBG_CASIER_CASH values (i.user_name, i.bank_account_id); v_exe_grant := 'create user ' || i.user_name || ' identified by ' || i.user_name || ';' || 'GRANT create session to ' || i.user_name || ';' || 'GRANT select on apps.XXBG_CE_STATEMENT_HEADERS_CASH to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.FND_USER TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.dFND_DESCR_FLEX_COL_USAGE_TL TO ' || i.user_name || ';' || 'GRANT select on apps.fnd_descr_flex_column_usages to ' || i.user_name || ';' || 'GRANT select on apps.fnd_descriptive_flexs to ' || i.user_name || ';' || 'GRANT select on apps.fnd_descriptive_flexs_tl to ' || i.user_name || ';' || 'GRANT select on ce.ce_statement_headers to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.fnd_doc_sequence_assignments TO ' || i.user_name || ';' || 'GRANT SELECT ON CE.CE_STATEMENT_HEADERS_S TO ' || i.user_name || ';' || 'GRANT EXECUTE ON APPS.XXBG_GET_NEXTVAL TO ' || i.user_name || ';' || 'GRANT SELECT ON CE.CE_STATEMENT_LINES TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.XXBG_CE_STATEMENT_LINES TO ' || i.user_name || ';' || 'GRANT select on apps.CE_BANK_ACCOUNTS to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.CE_BANK_BRANCHES_V TO ' || i.user_name || ';' || 'GRANT SELECT ON CE.XXBG_CASIER_CASH TO ' || i.user_name || ';' || 'GRANT EXECUTE ON APPS.XXBG_ST TO ' || i.user_name || ';' || 'GRANT select on ce.xxbg_ce_statement_lines_detail to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.ce_transaction_codes TO ' || i.user_name || ';' || 'GRANT select on ce.ce_statement_lines_s to ' || i.user_name || ';' || 'GRANT SELECT ON CE.XXBG_CE_STATEMENT_LINES_DET_SQ TO ' || i.user_name || ';' || 'GRANT select on apps.xx_pko_lines to ' || i.user_name || ';' || 'GRANT SELECT ON apps.xx_rko_lines TO ' || i.user_name || ';' || 'GRANT select on apps.XX_INVOICE_RELATIONS_CASH to ' || i.user_name || ';' || 'GRANT select on APPS.PO_VENDOR_SITES_ALL to ' || i.user_name || ';' || 'GRANT select on ap.AP_INVOICE_LINES_INTERFACE_S to ' || i.user_name || ';' || 'GRANT select on ap.AP_INVOICE_LINES_INTERFACE to ' || i.user_name || ';' || 'GRANT select on APPS.ap_distribution_set_lines_all to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.AP_INVOICES_INTERFACE_S TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.AP_INVOICES_INTERFACE TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.AP_DISTRIBUTION_SETS_ALL TO ' || i.user_name || ';' || 'GRANT select on apps.ce_lookups to ' || i.user_name || ';' || 'GRANT select on ar.HZ_CUST_SITE_USES_ALL to ' || i.user_name || ';' || 'GRANT select on ar.HZ_LOCATIONS to ' || i.user_name || ';' || 'GRANT select on ar.HZ_PARTIES to ' || i.user_name || ';' || 'GRANT select on ar.HZ_PARTY_SITES to ' || i.user_name || ';' || 'GRANT SELECT ON AR.HZ_CUST_ACCT_SITES_ALL TO ' || i.user_name || ';' || 'GRANT SELECT ON AR.HZ_CUST_ACCOUNTS TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.XXBG_CLAIMS_V TO ' || i.user_name || ';' || 'GRANT select on apps.xxbg_insis_agents_v to ' || i.user_name || ';' || 'GRANT select on ce.xxbg_cash_doc_types to ' || i.user_name || ';' || 'GRANT select on AP.AP_BANK_ACCOUNTS_ALL to ' || i.user_name || ';' || 'GRANT SELECT ON AP.AP_BANK_BRANCHES TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.FND_DESCR_FLEX_CONTEXTS TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.FND_DESCR_FLEX_CONTEXTS_TL TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.AP_SUPPLIERS to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.per_employees_x TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.fnd_doc_seq_categories_ap_v TO ' || i.user_name || ';' || 'GRANT SELECT ON APPS.AP_LC_INVOICE_TYPES_V to ' || i.user_name || ';' || 'GRANT SELECT ON ce.xxbg_ce_statement_lines_sq to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.XXBG_STATEMENT_HEADERS_CASH to ' || i.user_name || ';' || 'GRANT SELECT ON APPS.XXBG_INSIS_POLICY_V TO ' || i.user_name || ';' || 'GRANT insert ON ce.ce_statement_lines to ' || i.user_name || ';' || 'GRANT INSERT ON CE.XXBG_CE_STATEMENT_LINES_DETAIL TO ' || i.user_name || ';' || 'GRANT INSERT ON APPS.AP_INVOICES_INTERFACE TO ' || i.user_name || ';' || 'GRANT INSERT ON APPS.AP_INVOICE_LINES_INTERFACE TO ' || i.user_name || ';' || 'GRANT INSERT ON APPS.XX_RKO_LINES TO ' || i.user_name || ';' || 'GRANT INSERT ON APPS.XX_PKO_LINES TO ' || i.user_name || ';' || 'GRANT delete on ce.xxbg_ce_statement_lines_detail to ' || i.user_name || ';' || 'GRANT update on ce.XXBG_CE_STATEMENT_LINES_DETAIL to ' || i.user_name || ';' || 'GRANT DELETE ON CE.CE_STATEMENT_LINES TO ' || i.user_name || ';' || 'GRANT INSERT ON CE.CE_STATEMENT_HEADERS TO ' || i.user_name || ';' || 'GRANT update on CE.CE_STATEMENT_HEADERS to ' || i.user_name || ';' || 'GRANT update on ce.CE_STATEMENT_LINES to ' || i.user_name || ';' || 'GRANT select on apps.XX_AGENTS_NO_V to ' || i.user_name || ';' ; execute immediate v_exe_grant; update xx_office_user_imp set transfered = 1 where id = i.id ; v_exe_grant := ''; end loop; end; /
Any ideas? I think I call correct immediate execution.Error report: ORA-00911: invalid character ORA-06512: at line 79 00911. 00000 - "invalid character" *Cause: identifiers may not start with any ASCII character other than letters and numbers. $#_ are also allowed after the first character. Identifiers enclosed by doublequotes may contain any character other than a doublequote. Alternative quotes (q'#...#') cannot use spaces, tabs, or carriage returns as delimiters. For all other contexts, consult the SQL Language Reference Manual. *Action:
DB version: 11g
Unfortunately I can't provide you the sql code of the other tables to create their... Maybe you should try without all budgets... :)
Thanks in advance,
Bahchevanov.
Edited by: bahchevanov on 11 October 2012 06:14Bahchevanov wrote:
Any ideas?Sure. EXECUTE IMMEDIATE executes a unique statement when you try to run the job. So use:
execute immediate 'create user ' || i.user_name || ' identified by ' || i.user_name; execute immediate 'GRANT create session to ' || i.user_name; execute immediate 'GRANT select on apps.XXBG_CE_STATEMENT_HEADERS_CASH to ' || i.user_name; . . .
SY.
-
SQL query to avoid the PL/SQL
Hello
I'm doing below pl/sql block in a single stm SQL, let me know how could achieve us.
Here I use SELECT * FROM TEMP_ORDER WHERE DB_NAME = V_DBNAME which runs a cursor to get the separate database names.
This V_DBNAME could be avoided? and put everything in a single SQL?
(The PL/SQL block is not running properly because several rows are returned) I would be interested in the SQL solution.
create table TEMP_ORDER ( ORD1 VARCHAR2(25), ORD2 VARCHAR2(25), DB_NAME VARCHAR2(25) ) INSERT INTO TEMP_ORDER(ORD1,ORD2,DB_NAME) VALUES('A1','FIRST ORDER','DB1'); INSERT INTO TEMP_ORDER(ORD1,ORD2,DB_NAME) VALUES('A2','SECOND ORDER','DB2'); INSERT INTO TEMP_ORDER(ORD1,ORD2,DB_NAME) VALUES('A3','THIRD ORDER','DB1'); create table TEMP_PAYMENT ( PAY1 VARCHAR2(25), PAY2 VARCHAR2(25), DB_NAME VARCHAR2(25) ) INSERT INTO TEMP_PAYMENT(PAY1,PAY2,DB_NAME) VALUES('A1','FIRST PAYMENT','DB1'); INSERT INTO TEMP_PAYMENT(PAY1,PAY2,DB_NAME) VALUES('A2','SECOND PAYMENT','DB2'); INSERT INTO TEMP_PAYMENT(PAY1,PAY2,DB_NAME) VALUES('A3','THIRD PAYMENT','DB1'); create table TEMP_DELIVER ( DEL1 VARCHAR2(25), DEL2 VARCHAR2(25), DB_NAME VARCHAR2(25) ) INSERT INTO TEMP_DELIVER(DEL1,DEL2,DB_NAME) VALUES('A1','FIRST DELIVER','DB1'); INSERT INTO TEMP_DELIVER(DEL1,DEL2,DB_NAME) VALUES('A2','SECOND DELIVER','DB2'); INSERT INTO TEMP_DELIVER(DEL1,DEL2,DB_NAME) VALUES('A3','THIRD DELIVER','DB1'); --------------------------------- DECLARE V_DBNAME TEMP_ORDER.DB_NAME%TYPE; V_ORDER_NAME TEMP_ORDER.ORD2%TYPE; V_PAYMENT_NAME TEMP_PAYMENT.PAY2%TYPE; V_DELIVER_NAME TEMP_DELIVER.DEL2%TYPE; CURSOR DBCURSOR IS SELECT UNIQUE DB_NAME from TEMP_ORDER; BEGIN IF NOT DBCURSOR%ISOPEN THEN OPEN DBCURSOR; END IF; LOOP FETCH DBCURSOR INTO V_DBNAME; EXIT WHEN DBCURSOR%NOTFOUND; SELECT A.ORD2, B.PAY2, C.DEL2 INTO V_ORDER_NAME,V_PAYMENT_NAME,V_DELIVER_NAME FROM (SELECT * FROM TEMP_ORDER WHERE DB_NAME = V_DBNAME)A, (SELECT * FROM TEMP_PAYMENT WHERE DB_NAME = V_DBNAME)B, (SELECT * FROM TEMP_DELIVER WHERE DB_NAME = V_DBNAME)C WHERE A.ORD1 = B.PAY1 AND B.PAY1 = C.DEL1; DBMS_OUTPUT.put_line(V_ORDER_NAME || ':' || V_PAYMENT_NAME || ':' || V_DELIVER_NAME); END LOOP; CLOSE DBCURSOR; END;
Hello
Do you mean something like this?
SELECT a.db_name, a.ord2 || ':' || b.pay2 || ':' || c.del2 string FROM TEMP_ORDER A, TEMP_PAYMENT B, TEMP_DELIVER C WHERE A.ORD1 = B.PAY1 AND B.PAY1 = C.DEL1 AND a.db_name = b.db_name AND b.db_name = c.db_name; DB_NAME STRING ------- ------------------------------------------ DB1 FIRST ORDER:FIRST PAYMENT:FIRST DELIVER DB2 SECOND ORDER:SECOND PAYMENT:SECOND DELIVER DB1 THIRD ORDER:THIRD PAYMENT:THIRD DELIVER
I hope this helps.
Kind regards.
-
The query sql without prescription by will return same result on several tracks?
Hello
I have a sql without a prescription and I limit the number of rows to 100 max per rownum < 100. Now the question is, if the data set on which this sql is running, does not change, the sql returns the same result the performance of several?
For example, there are 150 lines and the sql returns 100 rows because of rownum < 100. Now running the same sql several times, I have the same set of 100 lines? or it could be 150? On the basis of these the kind of database engine and return data when no order by clause are provided?
Thank you for your time.
-HozyHi, Hozy,
Hozy says:
HelloI have a sql without a prescription and I limit the number of rows to 100 max per rownum< 100.="" now="" the="" question="" is,="" if="" the="" data="" set="" on="" which="" this="" sql="" runs,="" does="" not="" change,="" will="" the="" sql="" return="" the="" same="" result="" set="" on="" multiple="">
N ° if there is no ORDER BY clause, then there is no guarantee that the order will remain the same. If the table is small, the output will probably be the same thing, but you can't count on it.
I guess that you do not have a CONNECT BY query. CONNECT BY queries without ORDER BY clause or brothers and SŒURS of ORDER BY, the output is partially ordered.For example, there are 150 lines and the sql returns 100 rows due to rownum< 100.="" now="" on="" executing="" the="" same="" sql="" multiple="" times,="" will="" i="" get="" the="" same="" set="" of="" 100="" rows?="" or="" it="" could="" be="" any="" of="" the="" 150?="" on="" what="" bases="" these="" the="" database="" engine="" sort="" and="" return="" data="" when="" no="" order="" by="" clause="" is="">
No, you necessarily will not get the same 100 lines each time. ROWNUM reflects the order in which the establishment has recovered the lines.
Say you run the query at 11:00. Maybe do you a full table scan to obtain the data on the drive, and the order of the lines is determined by how it data happens to be on the disk. As the data is read from the disk, it is cached in memory.
Say you run the same exact query at 12:00, without changing the table. Instead of retrieve all data from the disk, Oracle will try to use the blocks that are cached in memory, which is not necessarily the way the blocks are stored on the disk. If some of the older blocks 11:00 to 12:00 (otherwise said, some, but not all, blocks are more in memory because memory was required for other purposes), then the items picked up at 11:00 can be recovered first at 12:00 and the lines that I have high ROWNUMs at 11:00 can get low ROWNUMs at 12:00. (See Matthew 7:30.)Again, you would never notice it on a small table. You can run this query
SELECT ename FROM scott.emp WHERE ROWNUM < 10;
a thousand times and get the same results every time. You will get the same results the 1001eme time? Probably, but not necessarily.
If you want the output to be in a particular order, to use an ORDER BY clause in the main query.
If you want ROWNUM to reflect a particular order, use a subquery with an ORDER BY clause and ROWNUM reference in the main query. -
Run the second sql statement only if the first sql statement is set to zero.
Hey guys I seem to have a mental block here. I have two sql statements. I would like to than the second to run only if the first sql statement is set to zero. I know that I can use PLsql but I would really like to see if I can do this with sql upward. Your answers are very much appreciated.
This is the first sql
second sql statementSelect ft.fund_code, ft.orgn_code, ft.acct_code, ft.amount, fb.owner_pidm, ft.prog_code from ftrbremb fb , ftcractg ft where fb.doc_code = 'TR000038' and fb.ftpbport_id = ft.ftpbport_id
How can I combine these two statements together so that when the first is null the second run. As a bonus, I want to get just the first line as well.Select ft.fund_code, ft.orgn_code, ft.acct_code, ft.amount, fb.owner_pidm, ft.prog_code from ftrbremb fb , ftcractg ft, ftprexps fx where fb.doc_code = 'TR000038' --and fb.ftpbport_id = ft.ftpbport_id and fx.ftrbremb_id = fb.id and ft.ftprexps_id = fx.id;
Any help would be greatly appreciated. I tried to accomplish with the case statement but it dosent everything seems to work for me.
Thank youMiguel,
the idea is simple: join the two queries (via the union of all) and to change the second part as to return only the rows if the first query returns no rows by changing the NOT EXISTS (first request). Hope I made it clear... ;)
-
How to test different Select into a PL/SQL block?
Hello
I'm relatively new to PL/SQL and I'm doing several int selects only one PL/SQL block. I am faced with the fact that if a single select statement returns no data, I have to go to the when exception DATA_NOT_FOUND.
Or, I would test selects different.
In an authentication script, I'm looking for a table for a USER ID (USERID) and an ID application, to check if a user is registered under this username for this APPLICATION.
There are different possibilities: 4 possibilities:
-Existing USER name or do not exist and
-Aplication ID found or not found for this particular USER ID.
I would test teas 4 possibilities to obtain the status of this user do regardin this application.
The problem is that if a select returns no rows, I'll not found exception data.
In the example below you can see that if no line is returned, with the exception
I would like to first of all make this statement:DECLARE P_USERID VARCHAR2(400) DEFAULT NULL; P_APPLICATION_ID NUMBER DEFAULT NULL; P_REGISTERED VARCHAR2(400) DEFAULT NULL; BEGIN SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ; :P39_TYPE_UTILISATEUR := 'USER_REGISTERED'; EXCEPTION WHEN NO_DATA_FOUND THEN :P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND'; END;
Do this if the user is found:SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID
etc...SELECT DISTINCT(USERID) INTO P_USERID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID AND APPLICATION_ID = :APP_ID ;
Basically, I don't want to go to the not found exception before you have tested the 4 possibilities.
Do you have a suggestion?
Thank you very much for your help!
ChristianIf you I had to check several conditions, this is how I would do:
DECLARE P_USERID VARCHAR2(400) DEFAULT NULL; P_APPLICATION_ID NUMBER DEFAULT NULL; P_REGISTERED VARCHAR2(400) DEFAULT NULL; BEGIN SELECT USERID , MAX(DECODE(application_id, :APP_ID, :APP_ID)) app_id_valid INTO P_USERID , P_APPLICATION_ID FROM ACL_EMPLOYEES WHERE USERID = :P39_USERID GROUP BY USERID IF P_APPLICATION_ID IS NULL THEN :P39_TYPE_UTILISATEUR := 'NOT REGISTERED TO APPLICATION_ID'; ELSE :P39_TYPE_UTILISATEUR := 'USER_REGISTERED'; END IF; EXCEPTION WHEN NO_DATA_FOUND THEN :P39_TYPE_UTILISATEUR := 'USER_NOT_FOUND'; END; /
not tested
C.
Maybe you are looking for
-
iTunes backup triggered a backup to iCloud?
Hello. While safeguarding my iPad on my Mac, I noticed that it ALSO supported it until iCloud. I always check the local time to the top and noted that the iCloud back until a marked like a minute before that I had done on my Mac. How is - it is possi
-
AO HAVE synchronized with the data processing
Hi all I'm building a pretty simple VI that should work in the following way: 1: acquire the data of two channels of AI with a sampling rate of 2000 Hz 2: process data: some time on average and the scaling of the output of the signal depends on the e
-
Reduced image recovery and differences in system recovery?
I bought Envy of HP dv7 - 7252 portable sr and before use of would like to learn the process of possible recovery of HP Recovery manager. Support document http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?lang=en&cc=us&taskId=120&prodSeri
-
Smartphones from blackBerry Curve 8310 - where is the mute button?
I have my Curve 8310 in a form-fitting of CaseMate case and he withdrew when a message arrived at the screen on the seizure in standby mode and press the Mute button to exit this mode. I can't find any info in the manual about the location the Mute b
-
Change the desktop shortcuts to open with correct file
Whenever I have create a shortcut on the desktop for a default program for another type of program. Basically, I can set so all of my shortcuts open with word, excel, google earth, ect.