Knowee
Questions
Features
Study Tools

Create a simple function named characterCount that takes a string and count the characters in the string. The function will return the number of characters in the given string.Use the skeleton file, to develop the function.FUNCTION characterCount(str IN VARCHAR2)   Function name : characterCountparameters  :  str datatype VARCHAR2Function return type : NumberNote:Do not change the function nameDo not change the argument count and orderDo not change the output text.You can query the table records using select statementDelimiter / is mandatory. If delimiter is missed, then while executing nothing will be displayedWhile executing, if you get WARNING: FUNCTION CREATED WITH COMPILATION ERRORS, then use SHOW ERRORS to display the errors in the function.Instructions:1. Create the function successfully2. Once the function is created, check the functionality of the function using appropriate select call3. DO NOT submit the select statement. Submit only the CREATE FUNCTION query.Sample Input and Output:If we execute the function with "HELLO" it should return 5.SubmitPreviously Executed Queries

Question

Create a simple function named characterCount that takes a string and count the characters in the string. The function will return the number of characters in the given string.Use the skeleton file, to develop the function.FUNCTION characterCount(str IN VARCHAR2)   Function name : characterCountparameters  :  str datatype VARCHAR2Function return type : NumberNote:Do not change the function nameDo not change the argument count and orderDo not change the output text.You can query the table records using select statementDelimiter / is mandatory. If delimiter is missed, then while executing nothing will be displayedWhile executing, if you get WARNING: FUNCTION CREATED WITH COMPILATION ERRORS, then use SHOW ERRORS to display the errors in the function.Instructions:1. Create the function successfully2. Once the function is created, check the functionality of the function using appropriate select call3. DO NOT submit the select statement. Submit only the CREATE FUNCTION query.Sample Input and Output:If we execute the function with "HELLO" it should return 5.SubmitPreviously Executed Queries

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is the SQL function you requested:

CREATE FUNCTION characterCount(str IN VARCHAR2) 
RETURN NUMBER 
IS 
    str_length NUMBER; 
BEGIN 
    str_length := LENGTH(str); 
    RETURN str_length; 
END; 
/

This function, named characterCount, takes a string as an input parameter. It then uses the LENGTH function to count the number of characters in the string and stores this number in the str_length variable. Finally, it returns the value of str_length.

Please note that you need to use the / delimiter at the end of the function definition. This is mandatory in SQL*Plus and some other tools to execute the PL/SQL block.

To test this function, you can use a SELECT statement like this:

SELECT characterCount('HELLO') FROM dual;

This should return 5, as there are 5 characters in the string "HELLO".

This problem has been solved

Similar Questions

Create a simple function named wordCount that takes a sentence (String) separated with space and count the words in the sentence. The function will return the number of words in the given sentence.Use the skeleton file, to develop the function.FUNCTION wordCount(str IN VARCHAR2)Function name :   wordCountparameter  :  str datatype VARCHAR2Function return type : NumberNote:Do not change the function nameDo not change the argument count and orderDo not change the output text.You can query the table records using select statementDelimiter / is mandatory. If delimiter is missed, then while executing nothing will be displayedWhile executing, if you get WARNING: FUNCTION CREATED WITH COMPILATION ERRORS, then use SHOW ERRORS to display the errors in the function.Instructions:1. Create the function successfully2. Once the function is created, check the functionality of the function using appropriate select call3. DO NOT submit the select statement. Submit only the CREATE FUNCTION query.Sample Input and Output:If we execute the function with "HELLO WORLD" it should return 2.SubmitSaveExecutePrevious Submission

Which of the following function returns the number of characters in a string variable?A.count($variable)B.len($variable)C.strcount($variable)D.strlen($variable)

The function LEN() returns the total number of characters in a string

Write a Python program to count the number of occurrences of a specific character in a string

You want to count the number of cells in a column that contain text and are longer than 10 characters. Which function would you use?*COUNTLONGCOUNTTEXTLENCOUNTIFS

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.