BookmarkSubscribeRSS Feed
Sai1
Fluorite | Level 6

Hi, i am asked to create a job with userwritten ,job includes only transformation  and no tables ,it should be able to collect stats on oracle tables in a particular schema in sas di.

 

here is the requirement:

 

Tables with CMPGN_* like will be included to collect the table stats in RTDMASL schema
> User written code module will be used to find out the cmpgn_*  like tables
> User written code module will used to loop throgh the tables  and collect the table stats
>

 

here is my code:

 

 


%macro CMPGN_TBL_Stats_Coll;

proc sql;
connect to oracle (user=RTDMASL password=rtdmasl path='SAS1D' );
create table cmpntbls as
select * from connection to oracle
(
 SELECT
  table_name, owner
FROM
  all_tables
  where owner='RTDMASL' and table_name like 'CMPGN_%'
ORDER BY
  owner, table_name

  );

  disconnect from oracle
;
quit;

options symbolgen;

DATA _NULL_;
SET cmpntbls END=NOMORE;
CALL SYMPUT
('_TABLE' || COMPRESS(PUT(_N_,3.)),
TRIM(table_name));
call symput ('_schema',owner);
IF NOMORE then CALL SYMPUT
('TOT_TAB', PUT(_N_,3.));
RUN;

%DO I=1 %TO &TOT_TAB;

proc sql;

connect to oracle (user=RTDMASL password=rtdmasl path='SAS1D' );
execute(
      begin
      DBMS_STATS.GATHER_TABLE_STATS(
      ownname=> &_schema,
      tabname=>  &&_table&i.,
      cascade => false);
      end;)  by oracle;


disconnect from oracle;
            quit;

            %end;

            %mend CMPGN_TBL_Stats_Coll;


%CMPGN_TBL_Stats_Coll;

 

 

and the error message i am getting is :

 

   Line 215: ERROR: ORACLE execute error: ORA-06550: line 1, column 48: PLS-00201: identifier 'RTDMASL' must be declared ORA-06550: line 1, column 7: PL/SQL: Statement ignored.

 

 

please help me with this...

 

 

 

4 REPLIES 4
SASKiwi
PROC Star

You are getting Oracle errors related to calling an Oracle-specific procedure. Not sure why you use => on the procedure parameters, why not just = ? Also test by replacing  the macro variable references with hard-coded values - I suspect they should be contained in quotes.

 

You will get better help posting just your Oracle-specific code on an Oracle forum. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Do you not need to quote username and password?

Anyways, firs decision - which application to use.  There is no benefit to wrapping this code in SAS code.  Either do the whole thing on Oracle - in which case visit an Oracle forum - or do the whole thing other than the data extract in SAS - i.e. select * from dictionary.columns where ...; Then do your "statistics" in SAS.  It is rarely a good idea to drive one application from another when either could do the job on its own.

Ksharp
Super User
You can use this to get all the schema:

proc sql;
connect to oracle (user=RTDMASL password=rtdmasl path='SAS1D' );
create table cmpntbls as
select * from connection to oracle(ORACLE::SQLTables);
quit;

BrunoMueller
SAS Super FREQ

The schema and table name have to be in single quotes. In the SAS Macro language you can use the %TSLIT autocall macro to achieve this.

 

See the code snippet below:

      execute(
        begin
        DBMS_STATS.GATHER_TABLE_STATS(
        ownname=> %tslit(&_schema),
        tabname=>  %tslit(&&_table&i.),
        cascade => false);
        end;
      ) by oracle;

Bruno

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2151 views
  • 2 likes
  • 5 in conversation