Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
This promise is immense; every day and every night, we are trying our best to fulfill it by helping others, leaving something worthwhile behind us, and living for a purpose that is "Enrich & Spread knowledge everywhere".
How to return N of rows after ordering in oracle sql ?
You can use a subquery for this like [code] select * from ( select * from emp order by sal desc ) where ROWNUM <= 5; [/code] Starting from Oracle 12c R1 (12.1). there is a syntax available to limit rows or start at offsets (full syntax here) example : [code] SELECT * FROM employees ORDER BY salarRead more
You can use a subquery for this like
[code]
select *
from
( select *
from emp
order by sal desc )
where ROWNUM <= 5;
[/code]
Starting from Oracle 12c R1 (12.1). there is a syntax available to limit rows or start at offsets (full syntax here)
example :
[code]
SELECT *
FROM employees
ORDER BY salary
OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY;
[/code]
hope this helpful 🙂
See lessHow to create ArrayList from array in Java ?
you can use :[code]List<Integer> intList = new ArrayList<Integer>(Arrays.asList(a));[/code]
you can use :
[code]
See lessList<Integer> intList = new ArrayList<Integer>(Arrays.asList(a));
[/code]
How dbms_assert protects against SQL injection ?
The dbms_assert package is used in databases that don't employ bind variables to help prevent SQL injection attacks, by "sanitizing" the SQL. it has several procedures inside ex : simple_sql_name: Validates the syntax of the SQL to ensure that the SQL statement only contains valid characters and proRead more
The dbms_assert package is used in databases that don’t employ bind variables to help prevent SQL injection attacks, by “sanitizing” the SQL.
it has several procedures inside ex :
and this a simple example of using (dbms_assert.simple_sql_name)
[code]CREATE OR REPLACE PROCEDURE oraask_test (tbl_name VARCHAR2, col_name VARCHAR2)
IS
qry VARCHAR2 (500);
BEGIN
qry := ‘ALTER TABLE ‘ || dbms_assert.simple_sql_name ( :tbl_name) || ‘ ADD ‘ || :col_name || char (1);
EXECUTE IMMEDIATE qry USING col_name;
See lessEND oraask_test;[/code]
How to validate phone number with specific format and fixed length ?
hello, you can use Format mask item property, it will handle the length along with format validation. you may enter this format mask ex: [code] 9"-"999"-"999"-"9999 [/code]
hello,
you can use Format mask item property, it will handle the length along with format validation. you may enter this format mask ex:
[code]
See less9″-“999”-“999”-“9999
[/code]
How to set a checkbox to be “checked” and “uncheck” with JQuery 1.5 & 1.6 ?
jQuery 1.6+ Use the new .prop() method: [code]$('.myCheckbox').prop('checked', true); $('.myCheckbox').prop('checked', false);[/code] jQuery 1.5.x and below The .prop() method is not available, so you need to use .attr(). [code]$('.myCheckbox').attr('checked', true); $('.myCheckbox').attr('checked',Read more
jQuery 1.6+
Use the new .prop() method:
[code]$(‘.myCheckbox’).prop(‘checked’, true);
$(‘.myCheckbox’).prop(‘checked’, false);[/code]
jQuery 1.5.x and below
The .prop() method is not available, so you need to use .attr().
[code]$(‘.myCheckbox’).attr(‘checked’, true);
$(‘.myCheckbox’).attr(‘checked’, false);[/code]
Note that this is the approach used by jQuery’s unit tests prior to version 1.6 and is preferable to using
[code]$(‘.myCheckbox’).removeAttr(‘checked’);[/code]
since the latter will, if the box was initially checked, change the behaviour of a call to .reset() on any form that contains it – a subtle but probably unwelcome behaviour change.
For more context, some incomplete discussion of the changes to the handling of the checked attribute/property in the transition from 1.5.x to 1.6 can be found in the version 1.6 release notes and the Attributes vs. Properties section of the .prop() documentation.
See lessCan i INSERT or UPDATE a table through a view ?
Hello Beter, Views in Oracle may be updateable under specific conditions. It can be tricky, and usually is not advisable. From the Oracle 10g SQL Reference: Notes on Updatable Views An updatable view is one you can use to insert, update, or delete base table rows. You can create a view to be inherenRead more
Hello Beter,
Views in Oracle may be updateable under specific conditions. It can be tricky, and usually is not advisable.
From the Oracle 10g SQL Reference:
Notes on Updatable Views
An updatable view is one you can use to insert, update, or delete base table rows. You can create a view to be inherently updatable, or you can create an INSTEAD OF trigger on any view to make it updatable.
To learn whether and in what ways the columns of an inherently updatable view can be modified, query the USER_UPDATABLE_COLUMNS data dictionary view. The information displayed by this view is meaningful only for inherently updatable views. For a view to be inherently updatable, the following conditions must be met:
In addition, if an inherently updatable view contains pseudocolumns or expressions, then you cannot update base table rows with an UPDATE statement that refers to any of these pseudocolumns or expressions.
If you want a join view to be updatable, then all of the following conditions must be true:
How to validate email address in JavaScript?
Using regular expressions is probably the best way. You can see a bunch of tests here (taken from chromium) [code]function validateEmail(email) { var re = /^(([^<>()[]\.,;:s@"]+(.[^<>()[]\.,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}Read more
Using regular expressions is probably the best way. You can see a bunch of tests here (taken from chromium)
[code]function validateEmail(email) {
var re = /^(([^<>()[]\.,;:s@”]+(.[^<>()[]\.,;:s@”]+)*)|(“.+”))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
return re.test(String(email).toLowerCase());[/code]
}
Here’s the example of regular expresion that accepts unicode:
[code]var re = /^(([^<>()[].,;:s@”]+(.[^<>()[].,;:s@”]+)*)|(“.+”))@(([^<>()[].,;:s@”]+.)+[^<>()[].,;:s@”]{2,})$/i;[/code]
But keep in mind that one should not rely only upon JavaScript validation. JavaScript can easily be disabled. This should be validated on the server side as well.
[code]function validateEmail(email) {
var re = /^(([^<>()[]\.,;:s@”]+(.[^<>()[]\.,;:s@”]+)*)|(“.+”))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}[/code]
[code]
function validate() {
var $result = $(“#result”);
var email = $(“#email”).val();
$result.text(“”);
if (validateEmail(email)) {
$result.text(email + ” is valid :)”);
$result.css(“color”, “green”);
} else {
$result.text(email + ” is not valid :(“);
$result.css(“color”, “red”);
}
return false;
}
$(“#validate”).bind(“click”, validate);[/code]
[code]<script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script>
<form>
<p>Enter an email address:</p>
<input id=’email’>
<button type=’submit’ id=’validate’>Validate!</button>
</form>
<h2 id=’result’></h2>[/code]
See lessCan I use If statement inside Where clause in oracle SQL?
hello oracle user, you can use CASE statement same like IF ex: [code] WHERE e.status = (CASE WHEN status_flag = STATUS_ACTIVE THEN 'A' WHEN status_flag = STATUS_INACTIVE THEN 'T' ELSE null END) AND e.business_unit = (CASE WHEN source_flag = SOURCE_FUNCTION THEN 'production' WHEN source_flag = SOURCERead more
hello oracle user,
you can use CASE statement same like IF ex:
[code]
See lessWHERE e.status = (CASE WHEN status_flag = STATUS_ACTIVE THEN ‘A’
WHEN status_flag = STATUS_INACTIVE THEN ‘T’
ELSE null END)
AND e.business_unit = (CASE WHEN source_flag = SOURCE_FUNCTION THEN ‘production’
WHEN source_flag = SOURCE_USER THEN ‘users’
ELSE null END)
[/code]
How to handle a unique constraint exceptions in PL/SQL code?
hello, you can use exception : [code] EXCEPTION WHEN DUP_VAL_ON_INDEX [/code]
hello,
you can use exception :
[code]
See lessEXCEPTION
WHEN DUP_VAL_ON_INDEX
[/code]
How to rollback oracle sequence value ?
There is no way to rollback the generated sequence. To restart the sequence at a different number, you must drop and re-create it. See http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_2011.htm. If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequenceRead more
There is no way to rollback the generated sequence.
To restart the sequence at a different number, you must drop and re-create it. See http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_2011.htm.
If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value.
See less