Toad World® Forums

Retain leading zeros for declared variables using cursor and fetch stmts


#1

Greetings,

I have an sql stmt I need to modify to retain leading zeros and I’m not sure how to modify it. Here is the code:

undef mmy_schema;

undef BeginDate;

undef EndDate;

DECLARE – declare variables and cursors

startDt VARCHAR2(10) := ‘&&BeginDate’;

stopDt VARCHAR2(10) := ‘&&EndDate’;

mmy_schema varchar2(200) := ‘&&mmy_schema’

policyNo &&mmy_schema…TableName.fieldname%TYPE;

---------THIS poliycNo IS THE VARIABLE I WANT TO RETAIN LEADING ZEROS…HOW??? IT IS A VARCHAR2(10BYTE) data type in the schema.

The cursor is defined after this, with FETCH and loop stmts.


#2

can youexecute this little changed code:

set serveroutput on size unlimited;

undef mmy_schema;
undef BeginDate;
undef EndDate;
DECLARE – declare variables and cursors
startDt VARCHAR2(10) := ‘&&BeginDate’;
stopDt VARCHAR2(10) := ‘&&EndDate’;
xmy_schema varchar2(200) := ‘&&mmy_schema’;
policyNo &&xmy_schema…TableName.fieldname%TYPE;
begin
dbms_output.put_line(xmy_schema);
end;
/

and please show output of that code and the way you call them.

brg

Damir