Can Pl/SQL execute a string?

Can Pl/SQL execute a string?

Post by Sean Dol » Fri, 12 Jun 1998 04:00:00



        I decided to take a different approach to this predicament - which involves piecing together a long string like "SELECT FIELD INTO something FROM SOMETABLE WHERE CRITERIA=2"... Now I would like to pass this string into a stored function and then be able to execute it.  So I think I would call the function via 'exec functionname(string)', it would then go into the function, execute that string (which is just a complex SQL statement) and return the values.

I decided on this alternative rather than composing the SELECT statement within the function for simplicity sakes.  My program already has put the SQL statement togther but I'd like to be able to pass it to the function.

Thanks,
Sean Dolan

 
 
 

Can Pl/SQL execute a string?

Post by Peter H. Larse » Fri, 12 Jun 1998 04:00:00


Hi Sean,
Look at the DMBS_SQL package. For information on how to use the package, just open the header/interface part of the package (use SELECT in SQL*PLUS for instance) and read the comments.
But be careful - dynamic SQL is not a novice function.

- Peter H. Larsen
  Oracle Consultant


>         I decided to take a different approach to this predicament - which involves piecing together a long string like "SELECT FIELD INTO something FROM SOMETABLE WHERE CRITERIA=2"... Now I would like to pass this string into a stored function and then be able to execute it.  So I think I would call the function via 'exec functionname(string)', it would then go into the function, execute that string (which is just a complex SQL statement) and return the values.

> I decided on this alternative rather than composing the SELECT statement within the function for simplicity sakes.  My program already has put the SQL statement togther but I'd like to be able to pass it to the function.

> Thanks,
> Sean Dolan


 
 
 

1. executing dynamic sql statements in a PL/SQL procedure

Hello,

I am writing a PL/SQL procedure.  In the procedure, I need to compose a
SQL statement at runtime and execute it.

I know that one way to do this is to use the dbms_sql package's
procedures to open a cursor, parse the sql statement and then execute
the statement and close the cursor.  But it seems a lot of work just to
execute an update statement.

Does anyone know of a quicker way to execute an SQL statement that is
stored in a string?

Thanks.

Ray

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Bug Tracking Shareware

3. Best way to connect many users?

4. Executing multi sql statements simulously in PL/SQL

5. silent truncation of varchar data

6. Embed a Date variable in a string and execute the string

7. ADO 2.5 and Sybase ASE 11.9.2

8. SQL-92, Migrate PL/SQL at ORACLE into PL/SQL at SQL Server 7.0

9. Executing a PL/SQL Function ?

10. EXECUTE PL SQL FROM VISUAL C

11. How to execute an anonymous Oracle PL/SQL block

12. How to execute a PL/SQL from java ???????