You can't use variables to specify object names (tables, columns, partition etc.) in static SQL.
You need to use dynamic SQL, e.g. with a non-quoted partition name:
DECLARE
pt all_tab_partitions.partition_name%TYPE;
countr NUMBER;
BEGIN
pt:='p61';
DBMS_OUTPUT.PUT_LINE(pt);
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM T1 PARTITION (' || pt || ')'
INTO countr ;
END;
/
If you have quoted identifiers for the partition names you need to include the quotes in the statement, and make sure the case of the partition name matches exactly:
DECLARE
pt all_tab_partitions.partition_name%TYPE;
countr NUMBER;
BEGIN
pt:='61';
DBMS_OUTPUT.PUT_LINE(pt);
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM T1 PARTITION ("' || pt || '")'
INTO countr ;
END;
/
'61'doesn't look like a valid partition name, as it doesn't meet the object naming rules.