Sign Up

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

Have an account? Sign In
Continue with Google
or use


Have an account? Sign In Now

Sign In

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

Sign Up Here
Continue with Google
or use

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.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

You must login to ask a question.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Continue with Google
or use

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.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

Hassan AbdElrahman

MasterOracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
Ask Hassan AbdElrahman
1k Visits
29 Followers
0 Questions
Home/ Hassan AbdElrahman/Answers
  • About
  • Questions
  • Answers
  • Best Answers
  • Posts
  • Polls
  • Asked Questions
  • Comments
  1. Asked: June 20, 2016In: PL/SQL

    Return more than one row from stored procedure in pl/sql

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on August 13, 2017 at 7:09 pm

    hello aya, as you know the procedure you can't use inside query so if you need to create procedure to return multiple row or values you can use : create or replace procedure myprocedure(retval in out sys_refcursor) is begin open retval for select employee_id,last_name from employees; end myprocedureRead more

    hello aya,

    as you know the procedure you can’t use inside query so if you need to create procedure to return multiple row or values you can use :

    create or replace procedure myprocedure(retval in out sys_refcursor) is
    begin
    open retval for
    select employee_id,last_name from employees;
    end myprocedure;

    and here you can call procedure inside anonymous pl/sql block :

    [code]

    DECLARE
    myrefcur SYS_REFCURSOR;
    employee_id employees.employee_id%TYPE;
    last_name employees.last_name%TYPE;
    BEGIN
    myprocedure (myrefcur);

    LOOP
    FETCH myrefcur INTO employee_id,last_name;

    EXIT WHEN myrefcur%NOTFOUND;
    DBMS_OUTPUT.put_line (‘Employee Id: ‘ || employee_id || ‘ Last Name: ‘|| last_name);
    END LOOP;

    CLOSE myrefcur;
    END;
    [/code]

    hope this help.

    See less
      • -1
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  2. Asked: June 19, 2016In: Oracle SQL

    What is the difference between schema and user ?

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on August 5, 2017 at 9:37 pm

    SCOTT is a schema that includes the EMP, DEPT and BONUS tables with various grants, and other stuff. SYS is a schema that includes tons of tables, views, grants, etc etc etc. SYSTEM is a schema.....   Technically -- A schema is the set of metadata (data dictionary) used by the database, typicalRead more

    SCOTT is a schema that includes the EMP, DEPT and BONUS tables with various grants, and other stuff.

    SYS is a schema that includes tons of tables, views, grants, etc etc etc.

    SYSTEM is a schema…..

     

    Technically — A schema is the set of metadata (data dictionary) used by the database, typically generated using DDL. A schema defines attributes of the database, such as tables, columns, and properties. A database schema is a description of the data in a database.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  3. Asked: June 19, 2016In: PL/SQL

    ORA-29280: utl_file.fopen invalid directory path with directory

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 13, 2017 at 6:49 pm

    utl_file.fopen takes the name of a directory, not the path. For example: (you may need to login as SYS to execute these) [code]Windows: CREATE DIRECTORY CUST_DIR AS 'C:'; Linux CREATE DIRECTORY CUST_DIR AS '/usr/tmp'; GRANT READ ON DIRECTORY CUST_DIR TO SCOTT;[/code] Then, you can refer to it in theRead more

    utl_file.fopen takes the name of a directory, not the path. For example:

    (you may need to login as SYS to execute these)

    [code]Windows:
    CREATE DIRECTORY CUST_DIR AS ‘C:’;

    Linux
    CREATE DIRECTORY CUST_DIR AS ‘/usr/tmp’;

    GRANT READ ON DIRECTORY CUST_DIR TO SCOTT;[/code]

    Then, you can refer to it in the call to fopen:

    [code]
    UTL_FILE.FOPEN(‘CUST_DIR’, ‘oraask_test.txt’, ‘W’);
    [/code]

     

    hope this help.

    See less
      • 1
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  4. Asked: June 18, 2016In: PL/SQL

    Error: PLS-00103: Encountered the symbol when trying to compile

    Hassan AbdElrahman
    Best Answer
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 13, 2017 at 4:21 pm

    You need to change ELSEIF to ELSIF . your code would be like this : [code]declare CURSOR abc IS select * from all_Objects; begin for rec in abc loop if rec.object_id is null then null; elsif rec.owner is null then null; end if; end loop; end;[/code]

    You need to change ELSEIF to ELSIF .

    your code would be like this :

    [code]declare
    CURSOR abc IS select * from all_Objects;
    begin
    for rec in abc
    loop
    if rec.object_id is null then
    null;
    elsif rec.owner is null then
    null;
    end if;
    end loop;
    end;[/code]

    See less
      • 2
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  5. Asked: April 1, 2017In: PL/SQL

    What is the difference between procedure and function in PL/SQL?

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 13, 2017 at 9:53 am

    1. Procedure may or may not return value where as function should return one value. 2. Function can be called from SQL statement where as procedure can't be called from the SQL statement. 3. Function are normally used for computation where as procedure are normally used for executing business logic.Read more

    1. Procedure may or may not return value where as function should return one value.

    2. Function can be called from SQL statement where as procedure can’t be called from the SQL statement.

    3. Function are normally used for computation where as procedure are normally used for executing business logic.

    4. Stored procedure is pre-compiled execution plan where as function are not.

    5. We can call function within procedure but we can not call procedure within function.

    6. A FUNCTION must be part of an executable statement, as it cannot be executed independently, whereas procedure represents an independent executable statement.

    and for example of both syntax of function and procedure :

    [code]CREATE OR REPLACE PROCEDURE test_proc
    (p_id IN VARCHAR2) as begin … end

    CREATE OR REPLACE FUNCTION test_func
    (p_id IN VARCHAR2) return varchar2 as begin … end[/code]

     

    hope this help.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  6. Asked: June 23, 2016In: Oracle SQL

    how to check if the column value is number or character

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 12, 2017 at 9:16 pm

    one example to create a function to return 'Y' if parameter value is number otherwise which is exception in this case to return ('N') ex: [code]CREATE OR REPLACE FUNCTION is_number (p_string IN VARCHAR2) RETURN VARCHAR2 DETERMINISTIC PARALLEL_ENABLE IS l_num NUMBER; BEGIN l_num := TO_NUMBER (p_strinRead more

    one example to create a function to return ‘Y’ if parameter value is number otherwise which is exception in this case to return (‘N’)

    ex:

    [code]CREATE OR REPLACE FUNCTION is_number (p_string IN VARCHAR2)
    RETURN VARCHAR2
    DETERMINISTIC
    PARALLEL_ENABLE
    IS
    l_num NUMBER;
    BEGIN
    l_num := TO_NUMBER (p_string);
    RETURN ‘Y’;
    EXCEPTION
    WHEN VALUE_ERROR
    THEN
    RETURN ‘N’;
    END is_number;[/code]

    and here you can call the function created above to identify the value passed is number or not like :

    [code]SELECT (CASE
    WHEN (is_number (mycolumn) = ‘Y’)
    THEN
    ‘your column value is number’
    ELSE
    ‘your column value is not number’
    END)
    FROM myTable;[/code]

    hope this help you.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  7. Asked: June 18, 2016In: Oracle SQL

    How to count specific values from table ?

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 12, 2017 at 9:05 pm

    Hi, try this query : [code]SELECT SUM ( CASE WHEN Col1 = 2 THEN 1 ELSE 0 END + CASE WHEN Col2 = 2 THEN 1 ELSE 0 END + CASE WHEN Col3 = 2 THEN 1 ELSE 0 END) FROM table_name WHERE Col1 = 2 OR Col2 = 2 OR Col3 = 2;[/code]

    Hi,

    try this query :

    [code]SELECT SUM (
    CASE WHEN Col1 = 2 THEN 1 ELSE 0 END
    + CASE WHEN Col2 = 2 THEN 1 ELSE 0 END
    + CASE WHEN Col3 = 2 THEN 1 ELSE 0 END)
    FROM table_name
    WHERE Col1 = 2 OR Col2 = 2 OR Col3 = 2;[/code]

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  8. Asked: March 25, 2017In: JavaScript

    How do i redirect user from page to another in JavaScript ?

    Hassan AbdElrahman
    Best Answer
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 12, 2017 at 8:57 pm

    Hi Saly, Actually you can achieve this by simulate HTTP redirect by using one of the following : // similar behavior as an HTTP redirect [code]window.location.replace("http://www.oraask.com");[/code] or // similar behavior as clicking on a link [code]window.location.href("http://www.oraask.com");[/cRead more

    Hi Saly,

    Actually you can achieve this by simulate HTTP redirect by using one of the following :

    // similar behavior as an HTTP redirect

    [code]window.location.replace(“http://www.oraask.com”);[/code]

    or

    // similar behavior as clicking on a link

    [code]window.location.href(“http://www.oraask.com”);[/code]

    at the end this your choice but for my suggestion i prefer using  (window.location.replace) because this doesn’t keep originate page in the session history.

    hope this help.

     

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  9. Asked: March 24, 2017In: Oracle SQL

    How to add a new column to a table only if not exist?

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 12, 2017 at 7:12 pm

    You can find the following view to access all metadata about the columns :user_tab_cols; -- For all tables owned by the userall_tab_cols ; -- For all tables accessible to the userdba_tab_cols; -- For all tables in the Database.and lets consider you want to add new column only if doesn't exists you cRead more

    You can find the following view to access all metadata about the columns :

    user_tab_cols; — For all tables owned by the user

    all_tab_cols ; — For all tables accessible to the user

    dba_tab_cols; — For all tables in the Database.

    and lets consider you want to add new column only if doesn’t exists you can use this pl/sql to check and add new column

    [code]DECLARE
    v_column_exists number := 0;
    BEGIN
    Select count(*)
    into v_column_exists
    from user_tab_cols
    where column_name = ‘ADD_COLUMN’
    and table_name = ‘departments’;

    if (v_column_exists = 0) then
    execute immediate ‘alter table departments add (ADD_COLUMN NUMBER)’;
    end if;
    end;[/code]

    hope this help.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  10. Asked: April 3, 2017In: PL/SQL

    ORA-06550: line , column : PLS-00201: identifier must be declared

    Hassan AbdElrahman
    Best Answer
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on July 12, 2017 at 9:26 pm
    This answer was edited.

    ORA-06550: error causes are:  You tried to execute an invalid block of PLSQL code (like a stored procedure or function), but a compilation error occurred. in your example, you selected a value inside the variable (v_last) that is not declared in your block. So to correct your block of code, you canRead more

    ORA-06550: error causes are:  You tried to execute an invalid block of PLSQL code (like a stored procedure or function), but a compilation error occurred.

    in your example, you selected a value inside the variable (v_last) that is not declared in your block.

    So to correct your block of code, you can rewrite it like this:

    DECLARE
    V_LAST EMPLOYEES.LAST_NAME%TYPE;
    BEGIN
    SELECT LAST_NAME INTO V_LAST FROM EMPLOYEES; dbms_output.put_line(‘v_last is :’ || V_LAST );
    END;
    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
1 … 11 12 13 14 15 … 17

Sidebar

Adv 250x250

Explore

  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

Footer

Oraask

About

Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy
  • Terms & Conditions

Follow

Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

© 2019 Oraask. All Rights Reserved
With Love by Oraask.