Home > OS >  Oracle procedure saving SYSDATE
Oracle procedure saving SYSDATE

Time:11-18

As part of a larger procedure I'm trying to write some code, which saves SYSDATE into a variable but I'm running into a problem. I narrowed it down to the following. Can someone please help me out.

CREATE OR REPLACE PROCEDURE XXX
AS
  l_date_string VARCHAR2(50);
BEGIN

select into l_date_string '['||TO_CHAR (SYSDATE, 'MMDDYYYY-HH24:MI:SS')||']' from dual;
 
END;
/

CodePudding user response:

In PL\SQL you can just assign:

BEGIN

...

  l_date_string := '[' || TO_CHAR (SYSDATE, 'MMDDYYYY-HH24:MI:SS') || ']'; 

...

END;

if you insist on sql all you have to do is to add into after select:

BEGIN

...

  -- standard select .. from .. with additional "into"  
  select '[' || TO_CHAR (SYSDATE, 'MMDDYYYY-HH24:MI:SS') || ']'
    into l_date_string 
    from dual;

...

END;

CodePudding user response:

I think this is where your issue might be .

select '['||TO_CHAR (SYSDATE, 'MMDDYYYY-HH24:MI:SS')||']' into l_date_string  from dual;

notice the change of the into.

  • Related