PL/SQL code input bug
the code below requests for entry oncewhenever consequtive I have run this code, I am not most requested for entry. the code uses rather the entry I provided the 1st time
I ran this code.
How to get around this problem?
Thanks :)
--------------------------------------------------------------------
declare
v_first_name student.first_name%type;
v_last_name student.last_name%type;
Start
If manage_students.id_is_good (& v_id)
then
manage_students.find_sname (& & v_id, v_first_name, v_last_name);
DBMS_OUTPUT. Put_line (' student no.: ' | & & v_id |' is ' | v_last_name | ',' | v_first_name);
on the other
DBMS_OUTPUT. Put_line (' student no.: ' | & & v_id |) 'is not in the comic book");
end if;
end;
/
Place the script in a sql file
accept v_id number prompt "Enter ID: "
declare
v_first_name student.first_name%type;
v_last_name student.last_name%type;
begin
if manage_students.id_is_good(&&v_id)
then
manage_students.find_sname(&&v_id, v_first_name, v_last_name);
DBMS_OUTPUT.PUT_LINE('Student No. : '||&&v_id||' is '||v_last_name||', '||v_first_name);
else
DBMS_OUTPUT.PUT_LINE('Student No. : '||&&v_id||' is not in the DB');
end if;
end;
/
undefine v_id
and run it...
Tags: Database
Similar Questions
-
I am getting fake SQL code when generating types in JDevelper 11.1.1.3.0.
Process:
1. create a new application: Test
2. create a new project: Project1
3. create the database offline: ECIS
4. create a contact schema
5 create a type:
CREATE OR REPLACE TYPE HAS_REASON_OF_CETYPE AS OBJECT
(
has_reason_of varchar2 (36)
)
6 create a table based on the previous type type:
CREATE OR REPLACE TYPE HAS_REASON_OF_CETYPE_LIST
AS THE contact.has_reason_of_cetype TABLE;
7. generate SQL script. Results:
CREATE THE HAS_REASON_OF_CETYPE_LIST TYPE
AS_REASON_OF_CETYPE_LIST <-this is the wrong code
AS THE contact.has_reason_of_cetype TABLE;
/
CREATE THE HAS_REASON_OF_CETYPE TYPE
AS_REASON_OF_CETYPE AS OBJECT <-fact here too
(
has_reason_of varchar2 (36)
)
/
I have not seen this error with type names in our project, or this error in the previous version. Someone has seen this before and knows a way around it?
Published by: user13324293 on July 20, 2010 11:48It's a regression in the PS2 (11.1.1.3.0) during our generation of DDL has been rewritten. The problem, in a nutshell, is that while determining if the generated DDL must precede the name of the object with a differnet scheme, there are some erroneous (simpler) made of string manipulation. So if the name (or schema.name) in the source contains the token of what follows (ie the ACE or IS) has the problem. This problem is fixed in 11.1.2.0.0 and 11.1.1.4.0 streams.
There are two possible solutions.
You can use instead OF as in the above case (in the STATE does not appear in the name) or simply change the case of ACE so that it is not the same as in the name - that is to say use "beneath", 'As' or 'Sub '.
I hope this helps.
Pete - team JDeveloper DB
-
want to understand the stages of executing pl/sql code
Hello all;
I want to know the logic of programming for the pl/sql code, what I have written;
because I was late yesterday to resolve the simple error.
> > It's link https://forums.Oracle.com/thread/2565867
OK now that I have written my code same lineup, but few changes:
now it's working. as I said above, I want to know the programming logic "flow of execution steps" of pl/sql code
1 DECLARE
2 a number: = 10;
3 number of b: = 20;
Number 4 c;
5 procedure findmin (x IN number, are there in numbers, number of Z OUT) IS
6 BEGIN
7 < < BLOCK1 > >
8 x if you can
9 z: = x;
10 other
11 z: = y;
12 end if;
13 END;
BEGIN 14
15 < < BLOCK2 > >
16 findmin(a, b, c);
17 DBMS_OUTPUT. Put_line (c);
18 * END;
19.
10
PL/SQL procedure successfully completed.
> > Is this process flow? > >
1. the declaration part.
2 during playback findmin online no 5 then control passes to the line not 16.
3. after receving input values, control passes back to 5
4. then compiler executes the code accordingly.
Question: how many compiler Oracle will execute code written?
8f953842-815B-4D8C-833d-f2a3dd51e602 wrote:
1. the declaration part.
2 during playback findmin online no 5 then control passes to the line not 16.
3. after receving input values, control passes back to 5
4. then compiler executes the code accordingly.
Question: how many compiler Oracle will execute code written?
1. any declaration section is processed in order to declare and allocate the space/memory etc. Including declaring the procedure in scope in memory (the procedure is not executed)
2 execution block to get the code begins with the first statement after BEGIN
3. the procedure is called in memory with the parameters passed to it.
4. when the procedure completes execution returns to the statement in the main execution block, after the procedure call.
Note:
The compiler is not executing code, it compiles just in memory or stored in the database (depending on whether it is an anonymous block or the stored procedure / package etc..)
The code isn't really jump 'line by line', because at the time when it is run, it is compiled down to a pcode (or native code if this is allowed), and which may contain several intermediate statements to run the underlying process. The compiled code however keep track of line numbers of source code of error for the purposes of statement internally.
-
Result passage of PL/SQL code for the page element
Hello
I have created a process in after the header to fill data to the page of the form elements. The pl/sql code is like bellows. Then I got the error message:
ORA-06502: PL/SQL: digital or value error: character number conversion
My question is that I do not see the difference in format between the page element and block pl/sql variables (e.g. : P31_STUDY_ID vs v_P31_STUDY_ID), they are either numeric or text field (in fact I have hidden field, but don't see conversion back to the digital field solved the problem). And don't see needs to set the format mask. Is there another way to detect the column that causes the problem, or if there is a syntax error with my assignment (from the variable element on the page)? Thank you very much!
============================
Declare
number of v_P31_STUDY_ID;
number of v_P31_STUDY_SITE_ID;
v_P31_STUDY_SITE_NAME VARCHAR2 (255);
v_P31_STUDY_SITE_NUM varchar2 (10);
number of v_P31_STUDY_SITE_NAME_NUM_ID;
number of v_P31_STUDY_SITE_OPEN_STATUS;
v_p31_comments VARCHAR2 (255);
Start
Select
tbl_study_site.study_id,
tbl_study_site.study_site_id,
study_site_name,
study_site_num,
STUDY_SITE_NAME_NUM_ID,
STUDY_SITE_OPEN_STATUS,
Comments
in
v_P31_STUDY_ID,
v_P31_STUDY_SITE_ID,
v_P31_STUDY_SITE_NAME,
v_P31_STUDY_SITE_NUM,
v_P31_STUDY_SITE_NAME_NUM_ID,
v_P31_STUDY_SITE_OPEN_STATUS,
v_p31_comments
of tbl_study_site, tbl_study_site_attrib
where tbl_study_site.study_id =: p30_study_name
and tbl_study_site.study_site_id = tbl_study_site_attrib. STUDY_SITE_ID
and tbl_study_site_attrib. STUDY_SITE_ATTRIB_ID =: P31_STUDY_SITE_ATTRIB_ID;
: P31_STUDY_ID: = v_P31_STUDY_ID;
: P31_STUDY_SITE_ID: = v_P31_STUDY_SITE_ID;
: P31_STUDY_SITE_NAME: = v_P31_STUDY_SITE_NAME;
: P31_STUDY_SITE_NUM: = v_P31_STUDY_SITE_NUM;
: P31_STUDY_SITE_NAME_NUM_ID: = v_P31_STUDY_SITE_NAME_NUM_ID;
: P31_STUDY_SITE_OPEN_STATUS: = v_P31_STUDY_SITE_OPEN_STATUS;
: P31_COMMENTS: = v_p31_comments;
end;
=============================
Identify the root cause. He's always on the format of the column, there is an error. Thanks for your help.
-
Apex - disable the button using PL/SQL code
Hi all
I use a PL/SQL code to get a DB value, depending on the value that I need to disable the buttons on the Page.
I tried code below
IF : P2_FLAG == ' not THEN
HTP.script ("document.getElementById ("SUBMIT") .disabled = false;", "Javascript");
END IF;
It is said screw the page saying - the/apex/f requested URL was not found on this server
I use Apex 5.0, please need your contributions.
Hello
However, if you want to show/hide the button, you can use conditions:
Open the properties of the button and put Conditions such as "Item = value '.
Point - P2_FLAG
Value - N
To turn on or off, you must run ajax with jquery to get the DB value before charge and then print button.
It may be useful
Sunil Bhatia
-
Extensions: Convert T - SQL code
Hello
Do we not have an extension for SQL Developer that converts the Oracle in T - SQL code?
Thank you
Do we not have an extension for SQL Developer that converts the Oracle in T - SQL code?
There is such an extension. It is called a "consultant."
See you soon,.
Brian
-
Impact of writing more comments in the pl/sql code
What is the impact of writing more comments in the pl/sql code. If it has an impact on the compile time, it is fine but it has no effect on the runtime? even in nano seconds?
Hello
2981581 wrote:
What is the impact of writing more comments in the pl/sql code. If it has an impact on the compile time, it is fine but it has no effect on the runtime? even in nano seconds?
Outside advice, comments have no effect on the runtime.
They can have a big impact on maintenance time.
-
PL/SQL code to add to the data file
Can someone help me with a PL/SQL code. I want to do the following:
get the latest data from the tablespace file
If (value > 30 GB)
then
Loop
change the database add datafile '+ DATA01' size 30 GB
# Note data file cannot be larger than 30 GB
# IE if 40 GB is entered as 2 entries are created one for 30 GB
# the second for 10 GB
end loop
on the other
same logic adds size datafile up to 30 GB
Loop
If you go over 30 GB that to create the new data file
End of loop
IfPlease excuse the syntax I know its not correct. In summary,.
what I want to do is to create data no larger than 30 GB files for the
extra space simply create new datafiles Nigerian, we reached the "value in".
limitHe can be hard-code "«+ DATA01»»
Note, I don't want to use datafile autoextend I want to control the size of my storage space...
Any code would be greatly apprecuated.
Thanks to all those who responded
create or replace procedure add_datafile( p_tablespace varchar2, p_size_in_gibabytes number ) is space_required number := 0; space_created number := 0; file_max_size number := 30; last_file_size number := 0; begin for ts in ( select tablespace_name, round(sum(bytes / 1024 / 1024 / 1024)) current_gigabytes from dba_data_files where tablespace_name = upper(p_tablespace) group by tablespace_name ) loop dbms_output.put_line('-- current size of ' || ts.tablespace_name || ' is ' || ts.current_gigabytes || 'G'); space_required := p_size_in_gibabytes - ts.current_gigabytes; dbms_output.put_line('-- adding files ' || space_required || 'G up to ' || p_size_in_gibabytes || 'G with files max ' || file_max_size || 'G'); last_file_size := mod(space_required, file_max_size); while space_created < (space_required - last_file_size) loop dbms_output.put_line('alter tablespace ' || ts.tablespace_name || q'" add datafile '+DATA01' size "' || file_max_size || 'G;'); space_created := space_created + file_max_size; end loop; if space_created < space_required then dbms_output.put_line('alter tablespace ' || ts.tablespace_name || q'" add datafile '+DATA01' size "' || last_file_size || 'G;'); end if; end loop; end; / set serveroutput on size unlimited exec add_datafile('sysaux', 65); PROCEDURE ADD_DATAFILE compiled anonymous block completed -- current size of SYSAUX is 1G -- adding files 64G up to 65G with files max 30G alter tablespace SYSAUX add datafile '+DATA01' size 30G; alter tablespace SYSAUX add datafile '+DATA01' size 30G; alter tablespace SYSAUX add datafile '+DATA01' size 4G;
-
Dynamic Action run PL/SQL Code runs is not after 4.2.5 upgrade
APEX 4.2.4 to 4.2.5 11.2 database upgrade
I have a button to click on DA who owns shares run of PL/SQL Code and update point who worked in version 4.2.4 which is no longer running after the 4.2.5 patch.
The PL/SQL procedure has been tested autonomous and it runs correctly.
I tested him DA is actually shot on the click event by adding an alert "DA xxxx pulled" action before the execution of work of PL/SQL action and action alert.
There is also a similar on DA click which makes the action opposite to the DA problem and it works both are configured in the same way:
Static DA, run Code PL/SQL - check waiting for result, and not repress with the same Submit and return items.
Any ideas on a possible cause/solution much appreciated
Fixed it, the question was the Page elements of return of goods on the action of PL/SQL Code:
If the target element was empty the action failed, by adding a value in the database through a normal SQL insert then the insert DA completed successfully.
Removing Page elements at the point of return of the action of PL/SQL and together action update the target element after the DA fires in all scenarios.
But thanks for the lead
-
How to invoke the export and import of orders for all tables of pl/sql code?
I want to export a few (not entire schema) tables from one database to another. But I want to run as a PL/SQL package so that I can call it from an application server. So my question is...
How to call a tax / export commands from pl/sql code (SP or packaging) so that I can call these (SP or packaging) as a JDBC application server call?
Krishna_Architect wrote:
I want to export a few (not entire schema) tables from one database to another. But I want to run as a PL/SQL package so that I can call it from an application server. So my question is...
How to call a tax / export commands from pl/sql code (SP or packaging) so that I can call these (SP or packaging) as a JDBC application server call?
When all else fails, read the Fine
-
Need help with a PL/SQL code
Hello
I am trying to execute the following PL/SQL code, which translates errors, obviously I'm not doing things, but it gives you an idea what I'm trying to do:
DECLARE
INT var_count;
SELECT COUNT (*) IN var_count
FROM sys.all_tables WHERE OWNER = 'SAKILA' AND table_name = "ACTOR";
If var_count > 0 then
BEGIN
DROP TABLE "ACTOR";
END;
/
Erros:
SELECT COUNT (*) IN var_count
*
ERROR at line 3:
ORA-06550: line 3, column 1:
PLS-00103: encountered the symbol "SELECT" at the expected in the following way:
Start function < an ID > pragma procedure subtype type
< between double quote delimited identifiers > delete the current cursor
There is before
The symbol 'start' has been substituted for "SELECT" to continue.
ORA-06550: line 7, column 1:
PLS-00103: encountered the symbol "DROP" when expecting one of the following conditions:
(begin case declare exit for goto if loop mod null pragma
raise return select update while < ID >
< between double quote delimited identifiers of > < a variable binding > < <
continue the narrow current delete fetch locking insert open rollback
savepoint sql set run commit forall fusion pipe purge
Your help to create it in a right way will be appreciated.
Thank you very much.
Tonya.
Try the following:
My = $ora $csr-> prepare (q {}
DECLARE
INT var_count;
BEGIN
SELECT COUNT (*) IN var_count
FROM sys.all_tables WHERE OWNER = 'SAKILA' AND table_name =: ts;
If var_count > 0 then
RUN IMMEDIATELY 'DROP TABLE' |: ts | "CASCADE CONSTRAINTS;
end if;
END;
});
-
First of all, Hi everyone.
I need to encrypt my PL/SQL code at run time. I thought using the wrap.exe, but it won't be a good option, once maybe I need to change something in the code and I'll not can send the code wrapped to the final customer. So, I'll use the DBMS_DDL. WRAP, but I have a doubt, I understand that my object will be encrypted in the database, but how can I prevent software this capture SQL (like SQL STATEMENTS TRACE) get the source when creating the object?
Thank you very much.Agree with SomeoneElse, having a license legally correct contract protects your code.
The package code is not a bad thing if that's what you are providing to the customer and that you have in place adequate source code controls, so you do not lose the source for yourself. Although there are "unwrappers" out there, it may depend on the version of Oracle as to how well they work, and if they can achieve. There are tools out there too which can obscure the PL/SQL code by doing things such as the conversion of all the variable names to things without meaning as a0001, a0002, a0003,... and deletes all comments etc before you wrap, so even if someone manages to undo what they are presented with the code that is more difficult to follow.
Regarding the customer can see SQL running, you won't really be able to do something that, if the customer has access of type DBA to the database; the only thing you can do to avoid this is to provide a managed service where your company has total control of provides a full support for the server, database and applications and the client does not have access to all but the front end of the application. Of course, if the customer has access to the database and can see running SQL code, then who can actually be beneficial if they have problems, because they can do their own initial analysis to determine the cause and determine if they should send the question to yourselves.
-
What is missing with Pl SQL code?
Hey guys,.
I'm learning to get out of this book and the guy has that little bit of Pl/sql...
It runs organist.
create table zed (z varchar2 (30);)
declare the procedure thisway1
(p_data in varchar2)
is
Start
immediate execution
"insert into zed (z) values(:z) '.
using p_data; end thisway1;
The code is correct?
Hello
XevBellringer wrote:
Hey guys,.
I'm learning to get out of this book and the guy has that little bit of Pl/sql...
It runs organist.
create table zed (z varchar2 (30);)
declare the procedure thisway1
(p_data in varchar2)
is
Start
immediate execution
"insert into zed (z) values(:z) '.
using p_data; end thisway1;
The code is correct?
No code is absolutely correct. The code may be correct for a specific purpose, which means that it will be incorrect for other purposes. If this code was copied from a book, the book probably explains the context and why the author chose to use EXECUTE IMMEDIATE when it is not needed. (You must use dynamic SQL, such as EXECUTE IMMEDIATE, only when you really need to. This is one of the most important things to know about dynamic SQL statements. Perhaps the book uses this code to make this point.)
In itself, the PL/SQL code you have posted will get a compilation error. The DECLARE statement must have matching BEGIN and END statements. (The BEGIN and END statements above are for the thisway1 procedure, which is nested in the DECLARE section). I suspect that you copied only part of the book pulled code.
The CREATE TABLE statement includes a mistake; "He has 2 left ' (of, but only 1 right ' ')'. You must have an equal number of each...
-
frmcmp cannot compile the modules containing SQL code that connected to the database
Hello
I checked several hundred messages of the forum on the net without finding a solution.
I have a Linux server with 11.1 WebLogics (11 GR 1 material) and FormsRuntime installed.
I am logged in as root.
I put all the environment variables based on the values in default.env.
In addition, I updated TERM and ORACLE_TERM vt220. And TNS_ADMIN to the location of the sqlnet.ora and tnsnames.ora.
I compiled a simple .pll containing only the following code:
IS test PROCEDURE
an INTEGER: = 0;
BEGIN
a: = 1;
END;
command:
frmcmp_batch module = TESTLIBPLAIN.pll userid=myuser/mypassword@mydb module_type = LIBRARY output_file = TESTLIBPLAIN.plx compile_all = Yes = Yes = No. batch connection
result: successful compilation. generated .plx.
now, I'm trying to compile an another .pll containing just the following code:
IS test PROCEDURE
an INTEGER: = 0;
BEGIN
Select 1 in the doubles.
END;
command:
frmcmp_batch module = TESTLIBSQL.pll userid=myuser/mypassword@mydb module_type = LIBRARY output_file = TESTLIBSQL.plx compile_all = Yes = Yes = No. batch connection
result: error:
"
11 forms (form of the compiler) Version 11.1.1.3.0 (Production)
Copyright (c) 1982, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With partitioning, OLAP and Data Mining options
PL/SQL Version 11.1.0.7.0 (Production)
Oracle V11.1.1.3.0 - Production procedure generator
Oracle virtual graphics system Version 11.1.1.3.0 (Production)
Oracle Multimedia Version 11.1.1.3.0 (Production)
Oracle tools integration Version 11.1.1.2.0 (Production)
Common tools Oracle area Version 11.1.1.3.0
Oracle CORE Production 11.1.0.7.0
Compile the library TESTLIB.
Invalidate the body TEST procedure...
Compilation of body TEST procedure...
ERROR on line 5, column 1 0
Ignored SQL statement
Library TESTLIB closing...
Errors on TEST:
PL/SQL ERROR on line 5, column 1 0
Ignored SQL statement
Could not generate the library.
FRM-30312: unable to compile the library.
"
the two libraries differ by having used SQl commands or not.
I tried to compile some more complex .pll and .fmb containg the SQL code. I get similar error messages. The messages that I receive for each module are the same, I would get when compiling the module with FormBuilder 9i (Windows) without being connected to the database.
So my first thought was, this frmcmp_batch is unable to connect to the database.
BUT:
From frmcmp_batch with an invalid user, password, or database name not existing (resp. not in tnsnames.ora), results in appropriate error messages (not found TNS, refusal to sign etc.).
With myuser/mypassword@mydb I don' t get this kind of messages.
sqlplus myuser/mypassword@mydb works.
myuser can access all objects in the database mydb.
mydb tnsping works.
When I check v$ session on mydb while (!) frmcmp_batch is running, I see that it is in fact a db session, created from myuser: DB-User = myuser, terminal = myappsever, osuser = root, remote process = frmcmp_batch. And State of the current session of the db is ACTIVE.
As a result, frmcmp_batch fails with error messages that I expect that when there is no connection to the base, if it is connected!
Any ideas what could be wrong with my setup?
Help appreciated.
Jean
I found the solution. Seems, fmrcmp 11g can connect to, but compiles not on the 9i database. With the help of a Database 11 g resolves the problem :-)
-
Examples of pl/sql code that can be used in training for new developers
Hello
I'm working on a training ride on the pl/sql to some developers who are totally new to PL/SQL. Although they are experienced in another language. I have power point on pl/sql presentations, but they especially the theory oriented with just a few examples. I'm looking for more help to have a few example pl/sql that can be given to interns as the code for example and also to practice. It should be a bit detailed and like to print the odd numbers or print "hellp world." Can anyone help to suggest if there is an example of code that is a bit detailed with a kind of complex problem which will give students a hands good example? I see a nice example at this link: http://tucano.tucanowebdesign.com/oracle/tutorial5.html - on an inventory system. It gives the feeling of being one on the issue of real-world work. So that if anyone knows of some other example say about 150 t0 300 lines or so of the code, I'll be grateful if it is shared.
Thank you
OrauserN
That said, I feel again (my perception) that more code a person writing/comments the better he gets. So, I want students to examine several code examples. I guess I need to see some books to bring out some really long piece of PL/SQL - like case studies.
. . .
But these guys are too busy and so I try to find the net / books some really detailed examples.But you seem to be overlooking that PL/SQL is supposed to be used for: PL means "procedural language.
So, PL/SQL must be used to 'procedure' treatment; This is typically several process steps. For example, when you want to run three applications as a "TRANSACTION". If all three completed successfully you COMMIT and if any of the three you don't ROLLBACK.
You can do this by using SQL only. And a developer doesn't have to write the code until they have a technical requirements doc that explains what problem the code is supposed to solve and the constraints and requirements that the code must implement.
So, my suggestion is the following:
1. identify and teach the types of issues that PL/SQL is used to help solve. Multi-step transactions, I mentioned above is an example
2. use the documentation and the code of your own organization in the form of samples. These 'guy' is perhaps too busy, but they should be able to provide to you all the documents for the code they wrote and that you use which would be good to use as examples. If they have no documents technical requirements so you just identify a MAJOR gap in the operations of your org that you must bring to the attention of management.
3. you can provide value added a lot more if you use code from your own org as a basis for what you are doing. A very useful training exercise is to ask students to perform 'code review' of a code (a procedure or function) and write simple comments, one line that explain, in plain English, what makes each piece of code.
4 comments, students create to step #3 can actually be incorporated into your code then existing so that future developers can use these comments to understand what the code actually does.
5 part of your 'education' should be on the way to 'test' correctly a piece of code PL/SQL to make sure it is doing what it is supposed to do. Again, if your students actually your own org code allows to create tests, these tests can then be added as a result of 'test' for this application and that adds value. A lot of times those developers 'busy' will not create the actual test cases and that your students can help remedy that. In addition, it does no good to know how to write PL/SQL code if you don't know how to test properly.
Maybe you are looking for
-
Satellite L40 - 13G - need a more powerful battery
Hello! No, my current battery is PA3591U-1BRS. I need a battery that can give me more than 2 hours of work. Can you advice something? Thank you!
-
Satellite P300 - re-connection Bluetooth problem
Good day to you all,. I bought a laptop Toshiba P300 BB with WiFi and bluetooth Windows Vista certified.Everything works fine with only the exception of the connection between my mobile phone (Nokia 6300) and the program "Nokia PC Suite"When I put th
-
New BIOS and old drivers Satellite a series
Hello. old drivers work under the new BIOS?
-
connect my computer to my wireless printer wirelessly
My computer is new, my printer is not and I can not find ppwork to check... It's a printer HP deskjet 3056A
-
Hello! I bought my z3c from a seller popular ebay, said registration is a new item not open, but when I received it yesterday the box is not sealed, resembles an open box item for me. I sent them and their customer service told me that z3c boxes are