Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to store query result to variable and perform update to another table

Shalini RadhakrishnanMay 25 2022 — edited May 25 2022

Hi All,
I have oracle package which has 2 procs
i have 2 variable
sqlstr varchar2 (2000);
v_end_date Varchar (100);
i perform the below
sqlstr := ‘select max(end _date) from table1 where start_date < sysdate-5 and end_date < sysdate -5’
DBMS_OUTPUT.PUT_LINE(sqlstr);
EXECUTE IMMEDITAE(sqlstr);
v_end_date :-sqlstr;
i need use that v_end_date result to insert into another table which is date column
INSERT INTO LOG_DETAIL( columnA,columnB,columnC)
VALUES(‘A’,’B’, v_end_date);
I wanted the variable values in column C
but im getting reg below error
ORA-06502-PL/SQL: numeric or value error : character string buffer too small
If I change v_end_date DATE to date data type.
getting below
ORA- 01858: a non - numeric character was found where a numeric was expected
what is issue in this? Pls help me. What data type should I use ? And how I should use that variable to insert the data into Table

This post has been answered by BluShadow on May 25 2022
Jump to Answer
Comments
Post Details
Added on May 25 2022
3 comments
5,059 views