1

Below is my requirement:

  • I want to generate a text file named as DBService_DateTimeStamp_UpgradeScipts.txt where
  • DBService=> is the oracle service name against which the script is executed(dit/fit etc.)
  • DateTimeStamp=>Current date time stamp upto seconds and
  • UpgradeScipts->static text

Below is my script part:

SET SERVEROUTPUT ON
DECLARE fileName VARCHAR2(100); 
  --Declare tStamp VARCHAR2(100);
BEGIN
  DECLARE fileName VARCHAR2(100); 
  Declare tStamp VARCHAR2(100);
  select sys_context('userenv','service_name') into fileName from dual;
  --SELECT SYSTIMESTAMP into tStamp FROM DUAL;
  --fileName:= fileName || '_' || tStamp; 
  --Dbms_Output.Put_Line('' || TIMESTAMP(3));
  --spool UpgradeClients.txt --here the desired file name should be like
  --  svc1_03-APR-17-12.51.12 AM.txt
END;
/

I think I am close to it, any help will be highly appretiated.

1 Answer 1

3
SET SERVEROUTPUT ON

DECLARE
  fileName VARCHAR2(100) := SYS_CONTEXT('userenv','service_name')
                            || '_' || TO_CHAR( SYSDATE, 'DD-MON-YY-HH24.MI.SS' )
                            || '_UpgradeScripts.txt';
BEGIN
  DBMS_OUTPUT.PUT_LINE( fileName );
END;
/
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.