|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Stored procedure prob!
Hi, can someone help me, when i try to create this Proc using SQL*Plus on 9i i get error:
Warning: Procedure created with compilation errors. CREATE OR REPLACE PROCEDURE sp_IssuePresc ( PID_in IN integer, drug_in IN varchar2(100), qty_in IN integer, pName_in IN varchar2(50), docName_in IN varchar2(50), issued_in IN boolean, expires_in IN date, ) AS BEGIN INSERT INTO Prescription(prescriptionID, PID, drug, qty, pName, docName, issued, expires) VALUES(perscription_seq.NEXTVAL, PID_in, drug_in, qty_in, pName_in, docName_in, issued_in, expires_in) END All help appreciated!!!!! |
|
#2
|
|||
|
|||
|
edited wrong advice!
|
|
#3
|
|||
|
|||
|
Quote:
Hi Paul, any chance you could show the full code? i'm new to Oracle and havent a clue! Thanks in advance! |
|
#4
|
|||
|
|||
|
edited! my mistake! wrong advice
|
|
#5
|
|||
|
|||
|
try this code:
Code:
CREATE OR REPLACE PROCEDURE sp_IssuePresc ( PID_in integer, drug_in varchar2(100), qty_in integer, pName_in varchar2(50), docName_in varchar2(50), issued_in boolean, expires_in date, ) AS BEGIN INSERT INTO Prescription(prescriptionID, PID, drug, qty, pName, docName, issued, expires) VALUES(perscription_seq.NEXTVAL, PID_in, drug_in, qty_in, pName_in, docName_in, issued_in, expires_in) END; / forget everything i have said before this post!! ! i wasnt looking at your code too carefully! sorry ok i think u need to remove the IN from there1 and one more thing if your prescription tables has these 8 columns it would be better if you used: insert into Prescription values((perscription_seq.NEXTVAL, PID_in, drug_in, qty_in, pName_in, docName_in, issued_in, expires_in) and one more thing, after the end there should be ; and a / |
|
#6
|
|||
|
|||
|
Does "show errors" give you more detailed information?
|
|
#7
|
|||
|
|||
|
Quote:
what he means is that after you type in your procedure and it says compilation error, type in "show errors" and press enter, you should get some info cant believe i missed that out ![]() |
|
#8
|
|||
|
|||
|
Quote:
it doesnt show anything! |
|
#9
|
|||
|
|||
|
Quote:
give me the table info (post it here) and i am gonna try it myself |
|
#10
|
|||
|
|||
|
extra comma after last argument, prescription spelled wrong, missing semi-colons
PHP Code:
what's the point of making this a sp anyway? |
|
#11
|
|||
|
|||
|
Quote:
I've left the code in college, i can post it in the morning, hope thats ok! |
|
#12
|
|||
|
|||
|
Quote:
yeah thats fine. |
|
#13
|
||||
|
||||
|
when specifying the arguments for stored procedures in Oracle, u r not allowed to specify lengths so signature of your stored procedure should be:
Code:
CREATE OR REPLACE PROCEDURE sp_IssuePresc ( PID_in IN integer, drug_in IN varchar2, qty_in IN integer, pName_in IN varchar2, docName_in IN varchar2, issued_in IN boolean, expires_in IN date, ) The only other potential error is make sure that arguments have same data type as the columns they're inserting into... im not sure if Oracle converts the arguments to column data types if theyre not already when inserting but just to be on the safe side make sure that they are the same. |
|
#14
|
|||
|
|||
|
Code:
CREATE OR REPLACE PROCEDURE sp_IssuePresc ( PID_in IN integer, drug_in IN varchar2(100), qty_in IN integer, pName_in IN varchar2(50), docName_in IN varchar2(50), issued_in IN boolean, expires_in IN date, -- remove the comma because it is a last argument in the list ) AS BEGIN INSERT INTO Prescription(prescriptionID, PID, drug, qty, pName, docName, issued, expires) VALUES(perscription_seq.NEXTVAL, PID_in, drug_in, qty_in, pName_in, docName_in, issued_in, expires_in); -- put the samicolon at the end of statement END; --put samicolon at the end of statement / -- put the termination of block Yes Oracle converts the one data type to its compatible data type. The another issue when you are passing values you need to keep sequence until you are using column alias in calling of procedure. |
|
#15
|
|||
|
|||
|
Quote:
Thanks guys! My syntax ia a shambles! I'm a complete newbie to this stuff, the proc works now! Stu. |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Stored procedure prob! |
| Thread Tools | Search this Thread |