Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am tring to write a sql procedure with some select and insert statements. But I am getting some errors. I am not able to figure out what the problem is. Kindly help me.
Following is the error I am getting:
Error(15,1): PL/SQL: Statement ignored
Error(15,22): PLS-00201: identifier 'PROJECT_ID' must be declared
Code:
create or replace
PROCEDURE UPDATION
(
NO_IN IN VARCHAR2
) IS
poject_id defects.reference_id%type;
BEGIN
Select REFERENCE_ID INTO poject_id from DEFECTS where ID=NO_IN;
dbms_output.put_line(project_id);
if poject_id is not null then
dbms_output.put_line('proj not null');
end if;
end;
You had syntax error on the project_id declaration.
create or replace
PROCEDURE UPDATION
(
NO_IN IN VARCHAR2
) IS
project_id defects.reference_id%type;
BEGIN
Select REFERENCE_ID INTO project_id from DEFECTS where ID=NO_IN;
dbms_output.put_line(project_id );
if project_id is not null then
dbms_output.put_line('proj not null');
end if;
end;
line 6
poject_id defects.reference_id%type;
project*
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Result that I want in column id: S-1, S-2, S-3
CREATE OR REPLACE TRIGGER auto_id
BEFORE INSERT ON login
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
:NEW.id := :NEW.id || to_char('"S-"',to_char(seq_log.nextval));
END login;
But when I insert data its error
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "WKSP_WORKSPACE0089.AUTO_ID", line 3
ORA-04088: error during execution of trigger 'WKSP_WORKSPACE0089.AUTO_ID'
ORA-06512: at "SYS.DBMS_SQL", line 1721
Should be
:NEW.id := :NEW.id || 'S-' || to_char(seq_log.nextval);
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I have this function:
CREATE OR REPLACE FUNCTION findMyList( p_user_id bigint)
....
DECLARE
myVar_id bigint;
...
IF myVar_id = select p_user_id from myFunction(p_user_id ) THEN
NULL;
ELSE
myVar_id := NULL;
END IF;
however there appears to be a syntax issue that I can't work out why it does not allow this as it doesnt seem unreasonable:
ERROR: syntax error at or near "select"
LINE 78: IF myVar_id = select p_user_id from myFunction...
why does it not let me define the variable as such?
Try :
myVar_id := (SELECT p_user_id from myFunction(p_user_id))
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I am using REF CURSOR to fetch the data and process it.
TYPE ty_ref_cur IS REF CURSOR RETURN MyTable%ROWTYPE;
l_cursor ty_ref_cur;
IF SomeCondition = 'Y' THEN
OPEN l_cursor for 'SELECT column1, column2
FROM SomeTable
WHERE column1 = regexp_replace(SomeColumn, '~', NULL)';
When above code is compiled, I am getting PLS-00103 : Encountered the symbol "~" when expecting one of the following.. error.
There is no need of quotes
OPEN l_cursor for SELECT column1, column2
FROM SomeTable
WHERE column1 = regexp_replace(SomeColumn, '~', NULL);
you can not use single quotations inside single quotations,
use with double quotations instead like this : regexp_replace(SomeColumn, ''~'', NULL)
Try this,
OPEN l_cursor for 'SELECT column1, column2
FROM SomeTable
WHERE column1 = regexp_replace(SomeColumn, ''~'', NULL)';
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm trying to generate a trigger that if a column within a table is filled in with a specific set value e.g. i have a column named 'Volunteertype' which can only be assigned either 'staff' of 'student', if student is entered the trigger must nullify all columns relating to staff details within the volunteer table such as 'area of work', 'staffmanager' etc below is code i have tried to put together utilising the resources on the website however i'm having no luck.
CREATE TRIGGER trg_voltype
ON Volunteer
AFTER INSERT
AS
IF EXISTS (SELECT NULL FROM inserted i WHERE VolunteerType = 'student')
FOR EACH ROW BEGIN;
UPDATE v
SET Area_of_work = NULL
SET StaffManagerName = NULL
SET StaffManagerEmail = NULL
SET StaffManagerPhone = NULL
FROM Volunteer v
JOIN inserted i ON v.Volunteer_id = i.Volunteer_id
WHERE v.VolunteerType = 'student';
END;
However when this is run within the Oracle environment an error is produced ORA-04071: missing BEFORE, AFTER or INSTEAD OF keyword. when i attempt to shift the 'AFTER INSERT' to before the keyword i get an 'invalid trigger' error
Is anyone able to assist and inform me if the code itself is correct/ incorrect and how i should go about amending the code, thanks in advance and have a wonderful end to the year thanks!
Your trigger should be like :
CREATE OR REPLACE TRIGGER trg_voltype
BEFORE INSERT ON volunteer
FOR EACH ROW
BEGIN
if :new.Volunteertype = 'STUDENT'
then
:new.Area_of_work := NULL;
:new.StaffManagerName := NULL;
:new.StaffManagerEmail := NULL;
:new.StaffManagerPhone := NULL ;
end if;
END;
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Created a simple PL/sql
CREATE OR REPLACE PROCEDURE Insert_Invoice(
inv_number IN NUMBER,
cust_id IN NUMBER,
date_in DATE,
date_out DATE,
Sub_tot IN NUMBER,
tax IN NUMBER,
total IN NUMBER) IS
BEGIN
INSERT INTO INVOICE VALUES( inv_number, cust_id, date_in,date_out,
Sub_tot,tax,total);
COMMIT;
END Insert_Invoice;
I having an error that ORA-06550 at line1, column 7
PLS-00201,indentifier 'INSERT_INVOICE' must be declared
but i following the example at website but it's still doesn't work. isn't my structure problem?
I haven't seen the procedure name on the end statement in PL/SQL. Try putting it in a comment:
BEGIN
INSERT INTO INVOICE VALUES( inv_number, cust_id, date_in,date_out,
Sub_tot,tax,total);
COMMIT;
END; -- Insert_Invoice