Is there a way to get the contnents of an RPG program using SQL?
Depends on your definition of "contents"...

At v7.3 and more at v7.4 IBM has added some services for program info, module info, ect...
IBM i Services (SQL)

But if you're thinking "contents" as in a source list...

Then you'd have needed to have the program compiled with DBGVIEW(*LIST|*COPY|*ALL) and then use the debugger APIs to retrieve the source...