Home Forums SQL Server 2008 Working with Oracle How to create a function that takes a table name and where clause as parameters RE: How to create a function that takes a table name and where clause as parameters

  • In SQL you have to use dynamic sql and the EXEC(EXECUTE) statement.

    Oracle is the same, but you would use EXECUTE IMMEDIATE,

    ie execute immediate 'drop table TEMPTBL';

    it sounds like you are trying to create a procedure to do all your adhoc sql statements; you should not do that. it's bad practice, and leaves you open to SQL injection, as well as potentially poor performance because no plan will get cached.

    if you have the table name and the WHERE statement, why not just do the ad hoc query directly from your application? why send it off to a proceudre?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!