Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7709861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:58:05+00:00 2026-06-01T00:58:05+00:00

I have a few SQL (Select/Update/Insert) syntax that I will run inside PL/SQL one

  • 0

I have a few SQL (Select/Update/Insert) syntax that I will run inside PL/SQL one after another

is there any way to check if each syntax completed correctly and if there is some error it will not halt the whole PL/SQL, it will just return “OK” or “Not OK” to a variable so I can use it with IF?

UPDATE

I came up with this function, but it dose not seems to work, it returns 0 all time!

create or replace
FUNCTION EXECUTE_SQL(
      V_SQL IN VARCHAR2 )
    RETURN NUMBER
  AS
    V_RESULTS NUMBER := 1;
  BEGIN
    BEGIN
      EXECUTE IMMEDIATE V_SQL;
    EXCEPTION
    WHEN OTHERS THEN
      -- the following line is just for debugging!
      dbms_output.put_line(SQLERRM);
      V_RESULTS:= 0;
    END;
    RETURN V_RESULTS;
  END EXECUTE_SQL;

what is wrong wit it (if any)!
cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:58:07+00:00Added an answer on June 1, 2026 at 12:58 am
    if sql%rowcount > 0 then
       -- insert or update statement affected sql%rowcount rows
    end if;
    

    As for the correct syntax: if the syntax is wrong, it won’t even compile. If there’s a data consistency error (such as divide by 0 error, or primary key violation) an exception will be thrown. Such exception can be caught in exception handlers

    In the exception handler, you can then check sqlerrm for more details:

     begin
        update t set x = ...
     exception when others then
        dbms_output.put_line(SQLERRM);
     end;
    

    There are also a few predefined exceptions that you can check on:

     begin
               update t set x = ...
     exception
        when DUP_VAL_ON_INDEX
             -- primary key or unique key violation
        when OTHERS
             -- other kind of exception
      end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few sql scripts that I need to run via SQL*Plus. These
I have a sql script that looks like UPDATE dbo.Pictures SET Data = (SELECT
I have a few SQL Server databases (all in one server), containing their own
We have a few tables with persisted computed columns in SQL Server. Is there
I have a few huge tables on a production SQL 2005 DB that need
Major Update after a couple days of debugging: I run a few queries similar
I have a few thousand tables in my SQL Server instance, and I need
I have a few windwos services. They get xml column from Sql server manipulate
Greetings, I have a few applications/websites running with LINQ to SQL and the other
I have been playing around with a quite complex SQL Statement for a few

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.