ORA-06502: PL/SQL: character to number conversion error while using variable

I know its been asked a lot but didn’t know how to apply it in a variable; this is my code DECLARE Main_time_elap varchar2(1000); time_elap varchar2(1000); time_elape number(5); BEGIN main_time_elap:=to_char(systimestamp,’HH24:MI:SS’); time_elap:=to_char(systimestamp,’HH24:MI:SS’); time_elape:=to_number(time_elap)-to_number(main_time_elap); –time_elape :=time_elap-main_time_elap ; end; / >Solution : It is much simpler: DECLARE Main_time_elap TIMESTAMP; time_elap TIMESTAMP; time_elape INTERVAL DAY TO SECOND; sec_elape NUMBER;… Read More ORA-06502: PL/SQL: character to number conversion error while using variable

Why is this query returning each student – month pairing individually?

SELECT To_Char(registrationdate, ‘Month’) AS "REGDATE", COUNT(*) AS "NUMSTUDENTS" FROM registration r INNER JOIN students s ON r.studentid = s.studentid GROUP BY registrationdate ORDER BY NUMSTUDENTS; Results are coming back like this: May 1 April 1 April 1 May 1 April 1 May 1 April 1 May 1 And the expected results are June 213 March… Read More Why is this query returning each student – month pairing individually?

Rebuilding an index, without knowing the index name (SQL)

What is the correct way to rebuild an index of a specific constraint, without knowing the index name, since it might different between environments. In this case, prefer not knowing the index name (existing condition), and not renaming it first. ALTER INDEX (select index_name from user_constraints where constraint_name = upper(‘constraint123’)) REBUILD; I tried casting, string,… Read More Rebuilding an index, without knowing the index name (SQL)

More than one occurrence from table

create table customer (cif number, name varchar(20),mobile number); insert into table customer values(121,’ANT’,789); insert into table customer values(122,’ANT’,789); insert into table customer values(123,’ENT’,789); insert into customer values(124,’ENT’,789); insert into customer values(125,’BEE’,123); insert into customer values(126,’BEE’,123); insert into customer values(127,’BRO’,789); insert into customer values(128,’FIO’,789); commit; I want retrieve data from customer table based on name and… Read More More than one occurrence from table