Why launch SQL * Plus with / nolog
What is the difference between from SQL * as insqlplus sys as sysdba
compared to
sqlplus/nolog
Connect sys as sysdba
I can imagine that the second method prevents some log writing, but sometimes newspapers are useful. Is there more than that?
Thank you
Gregory
/ nolog does mean no logon, not no record.
One of the reasons to start sqlplus with / nolog is to hide the BONE connection credentials.
For example if you launch sqlplus with login as
sqlplus test/test@rman
if someone do ps. he will see
ps -ef|grep sql
oracle 29455 9100 0 09:32:55 pts/3 0:00 sqlplus test/test@rman
If you embedding the login into your SQL script and
start sqlplus with /nolog,
ps will only show
oracle 29460 9100 0 09:33:14 pts/3 0:00 sqlplus /nolog
Tags: Database
Similar Questions
-
not able to connect Toad/sql * plus with ebs R12.2
Dear experts,
I have a R12.2 EBS instance with linux 5 (32-bit), but trying to connect to the database using toad / sql * plus of the client machine. his mistake.
another instance ebs r12.1.1 with the work of database 11g very well,
Please suggest how I can fix it.
Database - 11.2.0.3.0
EBS - R12.2
OS - release of the Red Hat Enterprise Linux 5.5 Server (Tikanga)
concerning
pritesh Rodriguez
problem is solved.
using the id of doc metalink 291897.1.
concerning
pritesh Rodriguez
-
Coil in SQL * Plus with SQL statements
Hi guru,.
Greetings.
I work 10 R2 Solaris oracle
I have the file new.sql having count (*) select statements of 10000 +. I want the result with the sql statement in the coil. How?
New.SQL
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE;
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP;
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP_TR;
....
....
Coil new.txt
@new.sql
spool off
Spooled results is
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE;
COUNT (*)
----------
199
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP;
COUNT (*)
----------
220
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP_TR;
COUNT (*)
----------
0
but I'm getting plain County, I need select statement and respective numeration.
How to get it. could you help on this.
Thank you
REDA
Like this.
Select "double ==>" | Count (*) twice;
-
How to make the output of Sql Plus with an error Code
Dear members,
How can I define sql more exit with an error code.
We have a simultaneous host program. The executable is a shell script for this program. This sql script Shell script request which in turn gives call to a custom database package that I built.
The flow rate is:
-> SQL-> CUSTOM PACKAGE SCRIPT SHELL SCRIPT
Custom package has two PARAMETERS of the error indicator and the error message. If something fails in the package these two PARAMETERS is returned with a value.
So my sql script code looks like this:
WHENEVER SQLERROR EXIT 251
WHEN the OSERROR EXIT 251
Set serveroutput size 1000000
set linesize 32767
set verify off
set the position
Set feedback off
DECLARE
x_error_message VARCHAR2 (1000);
x_sql_message VARCHAR2 (1000);
x_exception EXCEPTION;
e_value NUMBER;
BEGIN
dbms_output.put_line ('Inside sql file');
XXpackage.xxproc (x_error_message, x_sql_message);
IF (x_error_message IS NOT NULL) AND (x_sql_message IS NOT NULL) THEN
RAISE x_exception;
END IF;
EXCEPTION
WHEN X_EXCEPTION THEN
e_value: = 1;
DBMS_OUTPUT. Put_line (' Exit Code: ' | e_value);
DBMS_OUTPUT. Put_line ('X_EXCEPTION: EXCEPTION IN SCRIPT xpoext04a.sql :'||) SQLERRM);
DBMS_OUTPUT. Put_line ('x_error_message is: ' | x_error_message);
DBMS_OUTPUT. Put_line ('x_sql_message is: ' | x_sql_message);
DBMS_OUTPUT. PUT_LINE (' ERROR IS: ' |) SQLERRM);
WHILE OTHERS THEN
e_value: = 252;
DBMS_OUTPUT. Put_line (' Exit Code: ' | e_value);
DBMS_OUTPUT. Put_line (' OTHER: EXCEPTION IN SCRIPT xpoext04a.sql :'||) SQLERRM);
DBMS_OUTPUT. Put_line ('x_error_message is: ' | x_error_message);
DBMS_OUTPUT. Put_line ('x_sql_message is: ' | x_sql_message);
DBMS_OUTPUT. PUT_LINE (' ERROR IS: ' |) SQLERRM);
END;
*/*
output
*/*
As you can see from above, if the two PARAMETERS have value, then it goes to an exception.
My problem is that if it goes with the exception of X_EXCEPTION, the sql is not come away with a mistake. I mean sql is not treat this case like a sqlerror.
How can do us more sql dating a sqlerror so that the host program must fail.
Thank you
Sandeep
Published by: user340 on July 28, 2009 12:51
Published by: user340 on July 28, 2009 12:57the plu sql is not come away with a mistake. I mean sql is not treat this case like a sqlerror.
This is because there is no error. You handled the exception.
You can try adding a STIMULUS; at the end of your exception section. This re-triggers the exception so sql liked to see it.
-
SQL Plus - guest user with: "do you want to continue?
I am running a script, PL/SQL using SQL more. In the middle of the script, I would essentially like to have the following logic:
Request to the user: "do you want to continue?
IF the user types 'Y', continue with script (run update instructions)
ELSE IF
types user 'n' end script
What is the best way to do it? Thank you!You cannot ask for PL/SQL code. The PL/SQL code runs in a process on the database server and can interface with the end front of the customer.
You must use a front-end interface for this apart from any PL/SQL code. SQL * Plus offers a basic intervention, but you would be better using a good front-end such as Application Express, .NET, Java etc. or maybe even a Windows command/batch file. -
Why PL/SQL procedures does not allow users to enter data dynamically at run time?
Dear all,
I tried to do a procedure that will search for a group of approval in our database that matches.
(1) the number of levels
(2) the number of users by each level
(3) the id of users by level
entered by the user.
I tried various methods to receive user input dynamically at run time, but in vain.
Finally finished my procedure allowing the user to enter the parameters and then executes the procedure, to which these parameters are passed as arguments. (1 variable for the number of levels and 2 userdefinedarrays with the number of users by level and level respectively)
Why PL/SQL procedures does not allow users to enter data dynamically at run time?
Thanks in advance,
Séverine Suresh
HEY, Sebastian,
3035408 wrote:
Hello Sir,
My question is that if I'm going to say, the number of levels 5, is there any way by which, at runtime, the procedure prompts me to enter at the start of the number of users per level. Now as soon as I get the number of users per level can I do the procedure ask me to enter the nicknames of the members of each level. I mean, something like a invite.
Thank you
Séverine Suresh
There is no way to do it in SQL or PL/SQL, because not SQL PL/SQL is a way to get user input. User interaction is a job for your front end, like Zlatko tool suggested in response to #5. If your front end tool is SQL * Plus, you can use the substtitution variables, as Jarkko showed in response #6.
-
Unable to see the tilde characters correctly in SQL * Plus window BACK
Hello
I have a tilde character display problem in SQL * more correctly.
The environment is: Oracle 10.2.0.5 Server (Yes, I know, it is longer supported, but it is not possible to update now).
Database settings:
SQL > select * from nls_database_parameters by parameter.
PARAMETER VALUE ------------------------------ ----------------------------------------
NLS_CALENDAR GREGORIAN NLS_CHARACTERSET WE8MSWIN1252 NLS_COMP BINARY NLS_CURRENCY ? NLS_DATE_FORMAT RR. MR. DD NLS_DATE_LANGUAGE Portuguese NLS_DUAL_CURRENCY ? NLS_ISO_CURRENCY Portugal NLS_LANGUAGE Portuguese NLS_LENGTH_SEMANTICS BYTE NLS_NCHAR_CHARACTERSET AL16UTF16 NLS_NCHAR_CONV_EXCP FAKE NLS_NUMERIC_CHARACTERS ,. NLS_RDBMS_VERSION 10.2.0.5.0 NLS_SORT WEST_EUROPEAN NLS_TERRITORY Portugal NLS_TIME_FORMAT HH24:MI:SSXFF NLS_TIME_TdZ_FORMAT TZR HH24:MI:SSXFF NLS_TIMESTAMP_FORMAT RR. MR. DD HH24:MI:SSXFF NLS_TIMESTAMP_TZ_FORMAT RR. MR. DD HH24:MI:SSXFF TZR 20 selected lines.
Data are inserted and displayed correctly by the application (Oracle Forms 6 - Yes, I know it is old and not supported more :-)))
The only problem is that I can't view "tilde one" or "o tilde" correctly when you use SQL * Plus window BACK directly connected to the database. Other accented characters appear very well (acute accents a, for example).
If I use the SQL Windows * more available in point 10.2 so all the characters appear correctly.
NLS_LANG and code page are correct.
SQL > host chcp
Active code page: 850
SQL > host % NLS_LANG Echo%
AMERICAN_AMERICA.we8pc850
SQL > select * from nls_session_parameters by parameter.
VALUE OF THE PARAMETER
------------------------------ ----------------------------------------
NLS_CALENDAR GREGORIAN
BINARY NLS_COMP
NLS_CURRENCY $
NLS_DATE_FORMAT DD-MON-RR
NLS_DATE_LANGUAGE PORTUGUESE
NLS_DUAL_CURRENCY $
NLS_ISO_CURRENCY AMERICA
NLS_LANGUAGE AMERICAN
NLS_LENGTH_SEMANTICS BYTES
NLS_NCHAR_CONV_EXCP FAKE
NLS_NUMERIC_CHARACTERS.,.
NLS_SORT BINARY_AI
NLS_TERRITORY AMERICA
NLS_TIME_FORMAT HH.MI. SSXFF AM
NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR
NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR
17 selected lines.
Bad displays data:
SQL > select notes to atj_disc_cong where Ref = 645; -See attached screenshot Snap1.jpg
However, the data is stored correctly:
SQL > select dump (notes) in the atj_disc_cong where Ref = 645;
DUMP (NOTES)
--------------------------------------------------------------------------------
Typ = 1 Len = 21: 231,32,227,225,224,226,32,233,232,234,32,237,236,32,243,245,242,224,32,250,249
Also, if I copy the wrong characters has resulted in Word, they appear very well (that is, I get a tilde correctly a)
No idea why they are not display correctly in SQL * more?
Thank you
The data is stored correctly, as shown in the PICTURE, even if you really do not have the data expected if I'm only guessing.
The problem is most likely with the police. Your command prompt is implemented with code 850 (WE8PC850), but the police page seems to be in the code page 437 (US8PC437). You should change the font to a non-raster font or change page codes and NLS_LANG to the code page 437.
Note, do not define NLS_LANG in system properties, because it affects so Oracle Forms. Set only in the command prompt given.
Thank you
Sergiusz
-
A question on the impact of SQL * PLUS SERVEROUTPUT Optionconcernant v$ sql
Hello everyone,
I would like to ask a question about SQL * Plus SET SERVEROUTPUT option on / off and its impact on queries on views such as v$ sql and v$ session. This is the problemSQL> SELECT * FROM v$version; BANNER ------------------------------------------------------------------------------ Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production SQL> OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64
In fact I define three variables in SQL * Plus to store sidcolumns, serial # and prev_sql_id of session $ v in order to be used later, several times in various other queries, while I work always in the current session.
So, here's how
Now let's say I want to run the following query as the last SQL statement is executed within my current sessionSET SERVEROUTPUT ON; -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files SET SQLBLANKLINES ON; VARIABLE mysid NUMBER VARIABLE myserial# NUMBER; VARIABLE saved_sql_id VARCHAR2(13); -- So first I store sid and serial# for the current session BEGIN SELECT sid, serial# INTO :mysid, :myserial# FROM v$session WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId'); END; / PL/SQL procedure successfully completed. -- Just check to see the result SQL> SELECT :mysid, :myserial# FROM DUAL; :MYSID :MYSERIAL# ---------- ---------- 129 1067 SQL>
According to the reference of database Oracle® 11 g Release 2 (11.2) description of session $ vSELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;
http://docs.Oracle.com/CD/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]
column prev_sql_id includes the sql_id of the last executed sql statement for the sid and serial data which, in the case of my example, it will be the above mentioned query SELECT on the employees table. So right after the SELECT statement on the employees table I have run the following
The value of sql_id, I'm supposed to find all the information on the sliders for my SELECT statement and also its value sql_text in v$ sql. Here is what I get when I query v$ sql on the stored sql_idBEGIN SELECT prev_sql_id INTO :saved_sql_id FROM v$session WHERE sid = :mysid AND serial# = :myserial#; END; / PL/SQL procedure successfully completed. SQL> SELECT :saved_sql_id FROM DUAL; :SAVED_SQL_ID -------------------------------- 9babjv8yq8ru3 SQL>
So instead ofSELECT child_number, sql_id, sql_text FROM v$sql WHERE sql_id = :saved_sql_id; CHILD_NUMBER SQL_ID SQL_TEXT ------------ -------------- ------------------------------- 0 9babjv8yq8ru3 BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;
get the next value for the value of sql_textSELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;
Which is of course not what I expected to find in v$ sql for the given sql_id.BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);
After a little googling, I found the next thread on OTN forum, where it was suggested (well, I think that may not be exactly the same problem) to disable SERVEROUTPUT.
Problem with dbms_xplan.display_cursor
It was exactly what I did
After that, I repeated the procedure as a whole and this time everything worked pretty much as expected. I checked SQL * more documentation for SERVEROUTPUTSET SERVEROUTPUT OFF
and also the page of v$ session, yet I don't find nothing indicating that SERVEROUTPUT should be operated off every time that views such as v$ sql, v $session
are queired. I don't really understand the link in what concerns the impact that can have on the other or better say rather, why is there an impact
Could someone kindly do a few details?
Thanks in advance,
Kind regards
Dariyoosh>
and also the page of v$ session, yet I don't find nothing indicating that SERVEROUTPUT should be operated off every time that views such as v$ sql, v $session
are queired. I don't really understand the link in what concerns the impact that can have on the other or better say rather, why is there an impactHi Dariyoosh,
SET SERVEROUTPUT ON has the effect of dbms_output.get_lines running after each statement. Not only related to the system view.Below is what Tom Kyte is explained in this page:
Now, sqlplus sees this feature and says "Hey, it wouldn't be nice for me to empty the buffer to the screen for the user? Thus, they added the command SQLPlus "set serveroutput we" which does two things
(1) he tells SQLPLUS you would like run dbms_output.get_lines after each statement. You would like to make this network rounded up after each call. You want that this additional load will take place (think of a script of installation with hundreds / thousands of statements to run - maybe, just maybe you don't want this extra call after each call)
(2) SQLPLUS automatically calls the API dbms_output "activate" to activate the buffering which is in the package.
Kind regards.
Al -
ORA-12154 error using SQL PLUS
I have no problems connecting using SQL Developer, but I'm having issues using SQL Plus or command prompt. I also set the Oracle_home and SID and still it fails with the following message. Is there anything I can check?
ORA-12154: TNS could not resolve the connect identifier
The same account and tnsnames work well using SQL Developer.BSK wrote:
Here's the info. Not sure why only SQL MORE fails to solve the connection identifier when the SQL Developer works very well.tnsnames.ora
B51 =
(DESCRIPTION =
(SDU = 32768)
(ADDRESS = (PROTOCOL = TCP (PORT = 1527))(HOST = hostname.com))
(CONNECT_DATA =
(SERVICE_NAME = B51)
)
)SQLNET.ora
sqlnet.ora # Network Configuration file: C:\oracle\product\11.2.0\client_1\network\admin\sqlnet.ora
# Generated by Oracle configuration tools.# This file is actually generated by netca. But if customers can opt for
# install 'Software Only', this file does not exist and without the native
authentication #, they will not be able to connect to the database on NT.SQLNET. AUTHENTICATION_SERVICES = (NTS)
NAMES. DIRECTORY_PATH = (TNSNAMES, EZCONNECT)
That's what I'm trying:
view the results at the bottom
sqlplus username/passwd@'hostname.com:1527/B51'
-
30EA2 - SQL Developer Vs Index SQL/Plus functional on column Date
I just spotted this while using EA3.2, but it may also exist on other versions, I will consider. I'm on a 9i 9.2.0.7 box, but will see if I can recreate on an instance of 10 or 11
The question is, if I create a shadow table
CREATE TABLE paul_test
(
CREATION_DATE DATE,
DATE of creation_date2,
last_updsate_date DATE,
date of last_updsate_date2
)
;
If I then create a functional index on creation_date via SQL Dev:
create index pt_idx1 on paul_test (nvl (creation_date, ' 01-JAN-4000'));
and create a functional index on creation_date2 via SQL more
create index pt_idx2 on paul_test (nvl (creation_date2, ' 01-JAN-4000'));
What I see when you perform a describe table statement and looking at the index or when querying ALL_IND_EXPRESSIONS on the table TABLE_NAME is the following:
SQL Dev index is: NVL("CREATION_DATE",'01-JAN-4000')
The Index of over SQL is: NVL ('CREATION_DATE2', TO_DATE ('4000-01-01 00:00:00 ',' yyyy-mm-dd hh24:mi:ss'))))
Why are they not compatible?
If I then fill up with 1 million rows and fill creation_date/creation_date2 with enough data to make no small enough value I then collect statistics on the table and explain the plans of selects on creation_date/creation_date2 via SQL dev. and SQL Plus what I see, it's different
-Select
NVL SELECT (creation_date, ' 01 - JAN - 4000 "")
OF eagadev.paul_test
where nvl (creation_date, ' 01-JAN-4000') = ' 01-JAN-4000';
SQL Dev explain Plan
Use PT_IDX1
More SQL explain Plan:
SQL > SELECT count (1)
2 FROM eagadev.paul_test
3 where nvl (creation_date, ' 01-JAN-4000') = ' 01-JAN-4000';
COUNT (1)
----------
100
Execution plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer = CHOOSE (cost = 30 card = 1 bytes = 8)
1 TRI 0 (AGGREGATE)
2 1 INDEX (LINE SCAN) OF "PT_IDX1" (NO ONE) (cost = 30 Ca
RD = 5825 bytes = 46600)
Statistics
----------------------------------------------------------
14 recursive calls
0 db block Gets
8 compatible Gets
0 physical reads
Redo size 60
224 bytes sent via SQL * Net to client
276 bytes received via SQL * Net from client
2 SQL * Net back and forth to and from the client
0 sorts (memory)
0 sorts (disk)
1 rows processed
-Select2
SELECT count (1)
OF eagadev.paul_test
where nvl (creation_date2, ' 01-JAN-4000') = ' 01-JAN-4000';
SQL Dev explain the Plan:
FULL analysis
More SQL explain Plan:
SQL > SELECT count (1)
2 FROM eagadev.paul_test
3 where nvl (creation_date2, ' 01-JAN-4000') = ' 01-JAN-4000';
COUNT (1)
----------
100
Execution plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer = CHOOSE (cost = 28 card = 1 bytes = 8)
1 TRI 0 (AGGREGATE)
2 1 INDEX (LINE SCAN) OF "PT_IDX2" (NO ONE) (cost = 28 Ca
RD = 5825 bytes = 46600)
Statistics
----------------------------------------------------------
14 recursive calls
0 db block Gets
8 compatible Gets
0 physical reads
Redo size 60
224 bytes sent via SQL * Net to client
276 bytes received via SQL * Net from client
2 SQL * Net back and forth to and from the client
0 sorts (memory)
0 sorts (disk)
1 rows processed
The select on creation_date2 says plan is different between Dev SQL and SQl Plus. SQL Dev does not seem to be implicitly convert the '' 01-JAN-4000 in a date.
Their behaviour are not the same?Then the problem may be due to different configurations of NLS between SQLPlus and SQLDeveloper, try to check the date format configured NLS in SQLPlus and SQLDeveloper.
You can change the date format in SQLDeveloper, NLS of:
Tools-> preferences - ZDatabase-> NLS
-
Several SQL statements with zero executions in the region of SQL
Hello
one of my databases has a large number of statements in the SQL box with zero executions. Some of them analyzed several times without a single run. Why the database stores these statements and how to avoid or reduce them?
My problem is that the only time or zero time sql statements take the largest part of the area of sql:
-sql statement and only once and without executing sql statements
Select
Count (1) num_sql_total,.
sum (decode (executions, 1, 1, 0)) num_one_use_sql,.
sum (decode (executions, 0, 1, 0)) num_no_use_sql,.
Sum (RUNTIME_MEM) / 1024/1024 mb_used,.
sum (decode (executions, sharable_mem, 1, 0)) / 1024/1024 mb_for_one_use_sql,.
sum (decode (executions, 0, sharable_mem, 0)) / 1024/1024 mb_for_no_use_sql
Of
GV$ sqlarea
where
RUNTIME_MEM > 0;
NUM_SQL_TOTAL NUM_ONE_USE_SQL NUM_NO_USE_SQL MB_USED MB_FOR_ONE_USE_SQL MB_FOR_NO_USE_SQL 23318
8739
8027
1420,95619106293
381,41183757782
530,999855041504
Concerning
Thomas
This is not unusual. Another app could analyze for example hard the most often used SQLs in upstairs app - making benefit of further processing (in theory) of sweet analysis when you use these SQLs.
In fact, I remember reading something to this effect as a performance for some factor or another Oracle document or note?
So unless you have serious questions of shared pool, why bother with these sliders? What would be the problem?
-
Connect SQL Developer, SQL * Plus can't
I installed Oracle Database Development VM VM: VM VirtualBox for developers & lt; / title & gt; & lt; meta name = & quot; Title & quot; content = & quot; VM VirtualBox for developers & q...
Added two adapters, one as a host-only, as NAT.
We add a few entries tnsnames.ora for network database servers.
Developer SQL inside the VM can connect to all three databases: XE, remote_db1 and remote_db2.
SELECT * FROM Dual using a remote connection returns the data immediately.
SQL * Plus inside the VM can connect to XE, but not to a remote server. It hangs just for awhile and finally back: ORA-12545: Connect failed because target host or object does not exist
Outside of the virtual machine (on the host), Developer SQL (database connection Type) and SQL (sqlplus connection string) can connect to all three systems.
What is going on?
Brian Tkatch wrote:
SQL * Plus inside the VM can connect to XE, but not to a remote server. It hangs just for awhile and finally back: ORA-12545: Connect failed because target host or object does not exist
Sounds like the hostname resolution failed.
A host name must be resolved to an IP address. If you use a host name in the TNS connection string, you need to make sure that it can be resolved to an IP address. With the help of the ping
command is an easy way to determine if the host name is resolved. Some listeners (such as remote control and headphones RAC), accepts a connection client and in response redirect the client to a different hostname (and port). For example, a remote listener can serve 10 cases (each with a different service name). The client connects, asking servcice5. The listener redirects the customer to hostname ora-Server5 on port 1521. The customer now tries to connect to ora-Server5, to resolve the hostname to an IP address and then make the call to connect.
If the listener can redirect the customer to a new host name - and the customer must be able to resolve the host name. The error that you get so don't always relates to the connection initial listener. It can also occur when the client driver follows the redirect to the listener and attempt a new connection to a new host.
-
Hi all!
I learn PL/SQL on the book by Steve Bobrovsky (specified below, sample comes from it) and I have a question.
In the procedure of the below specified program used a currentElement integer variable to get the reference to the line in the nested table of data type % ROWTYPE.
Meanwhile, the program itself uses a common FOR... LOOP counter I have.
When I substituted a global variable of INTEGER type such for... The LOOP counter, an APEX have returned an error "ORA-01403: no data found.DECLARE TYPE partsTable IS TABLE OF parts%ROWTYPE; tempParts partsTable := partsTable(); CURSOR selectedParts IS SELECT * FROM parts ORDER BY id; currentPart selectedParts%ROWTYPE; currentElement INTEGER; PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS BEGIN DBMS_OUTPUT.PUT_LINE(' '); DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT); currentElement := p_collection.FIRST; FOR i IN 1 .. p_collection.COUNT LOOP DBMS_OUTPUT.PUT('Element #' || currentElement || ' is '); IF tempParts(currentElement).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.'); ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(currentElement).id || ' DESCRIPTION: ' || tempParts(currentElement).description); END IF; currentElement := p_collection.NEXT(currentElement); END LOOP; END printParts; BEGIN FOR currentPart IN selectedParts LOOP tempParts.EXTEND(2); tempParts(tempParts.LAST) := currentPart; END LOOP; printParts('Densely populated', tempParts); FOR i IN 1 .. tempParts.COUNT LOOP IF tempParts(i).id is NULL THEN tempParts.DELETE(i); END IF; END LOOP; FOR i IN 1 .. 50 LOOP DBMS_OUTPUT.PUT('-'); END LOOP; printParts('Sparsely populated', tempParts); END; /
When I tried to manage this code in SQL * Plus, the following picture emerged:DECLARE TYPE partsTable IS TABLE OF parts%ROWTYPE; tempParts partsTable := partsTable(); CURSOR selectedParts IS SELECT * FROM parts ORDER BY id; currentPart selectedParts%ROWTYPE; PROCEDURE printParts(p_title IN VARCHAR2, p_collection IN partsTable) IS BEGIN DBMS_OUTPUT.PUT_LINE(' '); DBMS_OUTPUT.PUT_LINE(p_title || ' elements: ' || p_collection.COUNT); FOR i IN 1 .. p_collection.COUNT LOOP DBMS_OUTPUT.PUT('Element is '); IF tempParts(i).id IS NULL THEN DBMS_OUTPUT.PUT_LINE('an empty element.'); ELSE DBMS_OUTPUT.PUT_LINE('ID: ' || tempParts(i).id || ' DESCRIPTION: ' || tempParts(i).description); END IF; END LOOP; END printParts; BEGIN FOR currentPart IN selectedParts LOOP tempParts.EXTEND(2); tempParts(tempParts.LAST) := currentPart; END LOOP; printParts('Densely populated', tempParts); FOR i IN 1 .. tempParts.COUNT LOOP IF tempParts(i).id is NULL THEN tempParts.DELETE(i); END IF; END LOOP; FOR i IN 1 .. 50 LOOP DBMS_OUTPUT.PUT('-'); END LOOP; printParts('Sparsely populated', tempParts); END; /
What's not in the code (or what I did not understand)? Help please!Densely populated elements: 10 Element is an empty element. Element is ID: 1 DESCRIPTION: Fax Machine Element is an empty element. Element is ID: 2 DESCRIPTION: Copy Machine Element is an empty element. Element is ID: 3 DESCRIPTION: Laptop PC Element is an empty element. Element is ID: 4 DESCRIPTION: Desktop PC Element is an empty element. Element is ID: 5 DESCRIPTION: Scanner -------------------------------------------------- Sparsely populated elements: 5 DECLARE * ERROR at line 1: ORA-01403: no data found ORA-06512: at line 14 ORA-06512: at line 35
Your error occurs because you are dealing with a sparsely populated collection and using an index for items that do not exist.
For collections of the low density of population, you must iterate through using FIRST and THEN as modeled not from 1 to COUNT.
The crucial difference between your code and the example is:
tempParts(i)
Which, as you have demonstrated, doesn't work very well (!) if there is no item (i).
The code example is a little unusual in my opinion.
currentElement := p_collection.FIRST; FOR i IN 1 .. p_collection.COUNT LOOP ... currentElement := p_collection.NEXT(currentElement); END LOOP;
It works, but it's an unusual way to iterate through a collection of rare which is perhaps most often done like this:
currentElement := p_collection.FIRST; WHILE(currentElement IS NOT NULL) LOOP ... currentElement := p_collection.NEXT(currentElement); END LOOP;
Which is perhaps less open to confusion.
In the end, the distinction between
tempParts(currentElement).id
and
tempParts(i).id
is crucial.
-
Out of the queue of SQL * Plus for Excel
I'm out of the queue of SQL * Plus for Excel. The code I use is down. I want that all white space to carve when I open the updated file waiting in Excel. How can I ensure this?
I was reading on the SET TRIM command, but it says that it does not affect the output queued. (http://ss64.com/ora/syntax-sqlplus-set.html)
Is there a way to NOT display whitespace at the beginning and the end of a column in SQL * more? In other words, if I shoot a single column of a record, and a data element is only 3 characters in length, I want to be also 3 characters instead of extending over 40 characters across the width of the column.
The column for your troubleshooting information
IDNUMBER is NUMBER (12)
FIRST is VARCHAR2 (40)
The LAST is VARCHAR2 (60)
Code
SET LINESIZE 100
SET PAGESIZE 0
SET MARKUP HTML PREFORMAT ON
set colsep,
coil c:\prospects.csv
Select '' perspective ID"', '" First"',""finally" "from dual;
Select to_char (p.idnumber), p.first, prospect_view p.last p where idnumber = 164515;
spool offDataHandle wrote:
I'm out of the queue of SQL * Plus for Excel. The code I use is down. I want that all white space to carve when I open the updated file waiting in Excel. How can I ensure this?I was reading on the SET TRIM command, but it says that it does not affect the output queued. (http://ss64.com/ora/syntax-sqlplus-set.html)
TRIM affects the expressions in your SELECT clause. It has nothing to do with the padding of SQL * Plus adds to align the columns upwards.
Is there a way to NOT display whitespace at the beginning and the end of a column in SQL * more? In other words, if I shoot a single column of a record, and a data element is only 3 characters in length, I want to be also 3 characters instead of extending over 40 characters across the width of the column.
Here's a way to make the main request:
SELECT TO_CHAR (idnumber) || ',' || first || ',' || last FROM prospect_view WHERE idnumber = 164515 ;
This will include spaces only if they occur in first or last. Depending on your data and your requriements, you may need to use the FILLING (first) instead of the first, and/or TRIM (finally) instead of the last.
Using this technique, it does not matter what is COLSEP: the query produces a single column.
Use the SQL * more order
SET TRIMSPOOL ON
to keep SQL * more add space after this single column.
-
Call the PL/SQL procedure with in out parameter of OIC clob
Hello
For a few days, I am facing a problem. I have to call the pl/sql procedure with colb parameter out. I use c ++ and OIC (don't ask me why :)).
I use a pl/sql problem test procedure:
create or replace function Test (longField outside clob) return number is
Number of result;
Start
longField: = 'prefix ';
Result: = 12;
Return (result);
end Test;
So I do all the stuff with the connection to the DB,
I prepare the statement: "start: res: = test(:param); end; »
So I OCIHandleAlloc (m_pCtx-> hpEnv,
(void *) & m_hpStatement,.
OCI_HTYPE_STMT,
0,
(NULL);
and
OCIStmtPrepare (m_hpStatement,
m_pCtx-> hpErr,
(...),
(...),
OCI_NTV_SYNTAX,
OCI_DEFAULT);
Before the binding I prepare parameters. For a clob I devote to the lob Locator:
OCIDescriptorAlloc ((dvoid *) m_pCtx-> hpEnv, (dvoid *) & m_pLobLocator,)
(ub4) OCI_DTYPE_LOB (size_t) 0, (dvoid *) 0);
OCILobEnableBuffering (m_pCtx-> hpContext, m_pCtx-> hpErr, (OCILobLocator *) m_pLobLocator);
that I bind parameters using OCIBindByName and OCIStmtExecute statement execution.
I get an error
---------------------------
Microsoft Visual C++
---------------------------
Unhandled exception in... (ORAOCIEI11. (DLL): 0xC0000005: Access Violation.
My question is: is it possible to call the pl/sql procedure with parameter BEAK clob?
If Yes, what steps I need to do to succeed?
Thank you for your response.Hello
Of course, it is possible :)
Show that you are your piece of code that is binding.
Are you sure you had correctly the lob descriptor in the call to bind?
Maybe you are looking for
-
new tab load always looking for safe norton.
whenever I click on the + sign to open a new tab, I get automatically connected to search for Norton Safe.
-
Satellite A350 to problem 7 - ATI Catalyst Windows upgrade
Recently bought an A350 and just installed Windows7 Home Premium upgrade.During the upgrade instructs to remove the ATI Catalyst Install Manager then reinstall it later. But where to go? I lost about 30mm to each side of my screen display and audio s
-
iPhone keep asking for activation after 6s choose to start
It continues to launch activation active end screen. More information: -After activation and Welcome to iPhone screen see the place and after choosing to begin, he will return to Hello and ask to activate again. -J' have entered the iCloud password c
-
HP Probook s 4540: cannot activate Windows after Format
I have a HP probook 4530 s. I just reformat the hard drive and tried to reinstall Windows 7 Pro, which is what has been installed before the format. Using the product key that I got using Magic Jellybean, it will not activate Windows. I had Microsoft
-
connecting two routers, different ISP
I have a BEFSR41 on Charter broadband, to 20 MB, and a WRT54GL connected to AT & T DSL at 1.5 MB. I would like the AT & T DSL to be my "rescue" if my broadband fails; but here they are on the same network, so that I can connect as and share resource