Hello,
I'm just starting to learn PL/SQL. To get my feet wet,
I'm trying to write a simple stored procedure that takes some
values as parameters, and inserts those values into a table.
For some reason my simple procedure is not working, I'm
probably missing something simple. Here is how I'm trying to
create this procedure:
CREATE OR REPLACE PROCEDURE insert_person(u id IN NUMBER,
first_nm IN VARCHAR,
middle_nm IN VARCHAR,
last_nm IN VARCHAR) IS
BEGIN
INSERT INTO PERSONS (prsn_uid, prsn_first_nm, prsn_middle_nm,
prsn_last_nm) values (uid, first_nm, middle_nm,
last_nm);
END insert_person;
I'm not sure this is relevant, but I'm typing the above
declaration into an Java based SQL client called SquirrelSQL
( http://sourceforge.net/projects/squirrel-sql/), the
output I get after executing the above is:
Warning: Warning: execution completed with warning
SQLState: null
ErrorCode: 17110
0 Rows Updated
Query 1 elapsed time (seconds) - Total: 0.053, SQL query: 0.053,
Building output: 0
Error: java.sql.SQLExc eption: ORA-00900: invalid SQL statement
Can anyone please point out what is wrong with the above
procedure?
Thanks,
Eraser 2 10146
There doesn't seem to be nothing wrong with your statement.
It might be the way SquirrelSQL interprets it.
Alex Ivascu
"Eraser" <er****@nospam. comwrote in message
news:pa******** *************** *****@nospam.co m...
Hello,
I'm just starting to learn PL/SQL. To get my feet wet,
I'm trying to write a simple stored procedure that takes some
values as parameters, and inserts those values into a table.
For some reason my simple procedure is not working, I'm
probably missing something simple. Here is how I'm trying to
create this procedure:
CREATE OR REPLACE PROCEDURE insert_person(u id IN NUMBER,
first_nm IN VARCHAR,
middle_nm IN VARCHAR,
last_nm IN VARCHAR) IS
BEGIN
INSERT INTO PERSONS (prsn_uid, prsn_first_nm, prsn_middle_nm,
prsn_last_nm) values (uid, first_nm, middle_nm,
last_nm);
END insert_person;
I'm not sure this is relevant, but I'm typing the above
declaration into an Java based SQL client called SquirrelSQL
(http://sourceforge.net/projects/squirrel-sql/), the
output I get after executing the above is:
Warning: Warning: execution completed with warning
SQLState: null
ErrorCode: 17110
0 Rows Updated
Query 1 elapsed time (seconds) - Total: 0.053, SQL query: 0.053,
Building output: 0
Error: java.sql.SQLExc eption: ORA-00900: invalid SQL statement
Can anyone please point out what is wrong with the above
procedure?
Thanks,
Eraser
try running from a simple sql*plus window to test: I just rana quick test
with your code and it worked:
SQLcreate table PERSONS
2 (
3 prsn_uid NUMBER,
4 prsn_first_nm VARCHAR2(20),
5 prsn_middle_nm VARCHAR2(20),
6 prsn_last_nm VARCHAR2(20)
7 );
Table created.
SQLCREATE OR REPLACE PROCEDURE insert_person(u id IN NUMBER,
2 first_nm IN VARCHAR,
3 middle_nm IN VARCHAR,
4 last_nm IN VARCHAR) IS
5 BEGIN
6 INSERT INTO PERSONS (prsn_uid, prsn_first_nm, prsn_middle_nm,
7 prsn_last_nm) values (uid, first_nm, middle_nm,
8 last_nm);
9 END insert_person;
10 /
Procedure created.
SQLset serveroutput on
SQLexec insert_person(1 ,'first', 'middle', 'last');
PL/SQL procedure successfully completed.
SQLCOMMIT;
Commit complete.
SQLselect * from persons;
PRSN_UID PRSN_FIRST_NM PRSN_MIDDLE_NM PRSN_LAST_NM
---------- -------------------- -------------------- --------------------
1 first middle last
SQL>
............... ...
I created a simple table based on your procedure, but it might be different.
--you should also look at adding exception handling in your procedure, such
as below:
CREATE OR REPLACE PROCEDURE insert_person
(
uid IN NUMBER,
first_nm IN VARCHAR,
middle_nm IN VARCHAR,
last_nm IN VARCHAR) IS
BEGIN
INSERT INTO PERSONS (prsn_uid, prsn_first_nm, prsn_middle_nm,
prsn_last_nm) values (uid, first_nm, middle_nm,
last_nm);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
DBMS_OUTPUT.PUT _LINE ('Errors found: '||SQLERRM);
END insert_person;
/
who owns the table, who's calling the procedure: do you have privs? are
there public/private synonymns?
easiet way to debug is go to the basics: sqlplus. try inserting into the
table with the same user you are running from the java, then try the
procedure, etc....
"Eraser" <er****@nospam. comwrote in message
news:pa******** *************** *****@nospam.co m...
Hello,
I'm just starting to learn PL/SQL. To get my feet wet,
I'm trying to write a simple stored procedure that takes some
values as parameters, and inserts those values into a table.
For some reason my simple procedure is not working, I'm
probably missing something simple. Here is how I'm trying to
create this procedure:
CREATE OR REPLACE PROCEDURE insert_person(u id IN NUMBER,
first_nm IN VARCHAR,
middle_nm IN VARCHAR,
last_nm IN VARCHAR) IS
BEGIN
INSERT INTO PERSONS (prsn_uid, prsn_first_nm, prsn_middle_nm,
prsn_last_nm) values (uid, first_nm, middle_nm,
last_nm);
END insert_person;
I'm not sure this is relevant, but I'm typing the above
declaration into an Java based SQL client called SquirrelSQL
(http://sourceforge.net/projects/squirrel-sql/), the
output I get after executing the above is:
Warning: Warning: execution completed with warning
SQLState: null
ErrorCode: 17110
0 Rows Updated
Query 1 elapsed time (seconds) - Total: 0.053, SQL query: 0.053,
Building output: 0
Error: java.sql.SQLExc eption: ORA-00900: invalid SQL statement
Can anyone please point out what is wrong with the above
procedure?
Thanks,
Eraser
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dan Caron |
last post by:
I have to create a stored procedure to purge "x" # of records from a
table. I have two tables (script below):
Schedule
ScheduleHistory
I need to purge records out of ScheduleHistory. The problem is that
the # of records that needs to be "kept" is dynamic, and stored in the
Schedule table. So all records in ScheduleHistory should be purged,
except for the most recent "x" number of records.
|
by: Daniel |
last post by:
hi ng,
i am newbie to sqlserver and my problem seems simple, but i didn't find
information about it:
How can i display the
RETURN @x
value of a stored procedure in the sql analyzer of the sqlserver?
thanks a lot,
d
|
by: Josh Strickland |
last post by:
I am attempting to create an Access database which uses forms to enter
data. The issue I am having is returning the query results from the
Stored Procedure back in to the Access Form.
tCetecM1CUST (SQL Table that contains the Customer Information)
tAccountingDetail (SQL Table that contains the information in the
form)
frmAccountingEntry (Access form used to enter data)
spGetCustomerInformation (Stored Procedure which returns data using...
|
by: ILCSP |
last post by:
Hello, I'm trying to accomplish 3 things with one stored procedure.
I'm trying to search for a record in table X, use the outcome of that
search to insert another record in table Y and then exec another stored
procedure and use the outcome of that stored procedure to update the
record in table Y.
I have this stored procedure (stA)
CREATE PROCEDURE procstA (@SSNum varchar(9) = NULL)
AS
|
by: fniles |
last post by:
I am using VB.NET 2003 and SQL2000 database.
I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1
parameter (varchar(10)) and returns the identity column value from that
table.
When calling the stored procedure from VB.NET, in the CommandText, can I
just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with
"INSERT_INTO_MYTABLE" then do the following :
OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
| |
by: Bangaru |
last post by:
How do i view the code in stored procedure?what permission should I have for it.
Also how do I get the list of tables in the DB?
|
by: BostonNole |
last post by:
I am using SQL 2000 and VB.NET (VS 2005).
I have three stored procedure: sp_A, sp_B and sp_C
I need to be able to call sp_A once and sp_B and sp_C 1 to n number of
times all within a single transaction that can be rolled back if any
of the calls to the stored procedures fail.
sp_A - inserts to table ZZZ
sp_B - inserts to table YYY (but needs to be called multiple times)
|
by: Constantine AI |
last post by:
Hi we have created a stored procedure to check the dates entered into a lease table does not overlap dates already stored for a lease. However when inserting overlapping lease dates, it allows us to insert this entry into the lease table, we was thinking of doing a trigger to execute the stored procedure to prevent a row being inserted into the lease table if there are overlapping dates:
The code we have for stored procedure is:
CREATE OR...
|
by: IuliaS |
last post by:
Hello everyone!
I want to create a stored procedure, so I can more easily, and transparent retrieve data from db2. Long story short: when a user wants to put some data in the DB, he also creates the tables and their links. When getting the data from the DB... well suffice to say it's ugly. I want to use one stored procedure that will return a result set as (name, value) pairs so I can display it nice and easy in the UI. So far I've managed to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |