Avoid to insert a short value in column with friendly notification
Hi all
I've got table with column 'mobile phone '. My need is to avoid inserting too short values (normal duration is 9). Also the user should receive easy to use, why he or she can't insert a value that is too short. How can I make it?
Thanks in advance.
CREATE TABLE 'SCHEMENAME '. "" CELL PHONES. "
('ID' (32 BYTE) CHAR by DEFAULT sys_guid(),
'MOBILE PHONE' NUMBER (9.0).
"DESCR" VARCHAR2 (1000 BYTE),
'STATE' NUMBER (5.0) DEFAULT 0,
"CREATED" DATE default sysdate,
"CREATEDBY" VARCHAR2 (1000 BYTE),
DATE 'DAY. '
"UPDATEDBY' VARCHAR2 (1000 BYTE)
);
Hello
You can use a trigger to achieve
for example
CREATE OR REPLACE TRIGGER SCHEMENAME.TR_CELLPHONES
BEFORE INSERT OR UPDATE ON SCHEMENAME. CELL PHONES
FOR EACH LINE
DECLARE
BEGIN
IF length(:new.) MOBILE PHONE)<>
THEN
RAISE_APPLICATION_ERROR ("-20101, ' the phone is too short!");
ROLLBACK;
END IF;
END;
/
Concerning
Tags: Database
Similar Questions
-
Insert/update the column with the clob data type
Hi all
ORCL Version: 11g.
I have a table with the clob data type.
Test12
(col1 clob);
I'm trying to insert/update to update the column with more than 4000 characters.
But due to the limitation of tank 4000, I could not Insert/Update.
Need your help in resolving this issue.
THX
Rod.
The limit of 4000 characters is incorrect. That pertains only to the varchar2 data type. A clob can hold more than 4 G.
Here is an example that shows how to insert it, I found...
Otherwise, here is a way 'dirty' to do.
insert into your_table (COLA, COLB)
values
(PRIMARY_KEY, PART 1 OF DATA)
;
Update your_table
Define COLB = COLB | PART 2 OF BIG DATA
where COLA = PRIMARY_KEY;
Update your_table
Define COLB = COLB | PART 3 OF BIG DATA
where COLA = PRIMARY_KEY;
.. and so on...
I don't know that I personally recommend the second style... But he could do the job.
-
Insertion in a column with &; value
Hello
When I run under instruction, it asks me to enter a & D cause input value of & sign in the value.
any suggestion
INSERT INTO xxgdv_legacy_inv_ord VALUES (545566,16778, 'S & D BUILD', NULL);
Thank you
Hello
2795332 wrote:
Hello
When I run under instruction, it asks me to enter a & D cause input value of & sign in the value.
any suggestion
INSERT INTO xxgdv_legacy_inv_ord VALUES (545566,16778, 'S & D BUILD', NULL);
Thank you
The simplest thing is to turn off the feature of variable substitution. In SQL * Plus, the way to do it is:
SET DEFINE OFF
You should only do this once, before the Insert; It will remain in force until the end of the SQL * Plus the term. If you want to re - activate (for example, if you call other scripts later, and they may need this feature) so you can light it using the
ALL SET ON
Other ways to treat &, see Re: & value as variable substitution in select
-
Insert the new value in existing csv file
Hello
I have a CSV file that I created using a totalizer. now I need to insert this string values by searching the line
For example:-first column is date so I'll look for the date and insert comment for her
attached the CSV file
-
insertion of unique values as well as the value of the sequence
Hello gurus,
I need to copy values from table A to table B as well as the value of the sequence.
Please find the scripts below.
-Table A and insert
create a (varchar2 (40) of ename, space job_id varchar2 (40));
insert into a values ('Suri', 'THIS');
insert into a values ('Suri', 'THIS');
insert into a values ('ABC', 'Admin');
-Creation of table B
create table B (number empno, ename varchar2 (40), job_id varchar2 (40));
-sequence to fill data in table B empno
create sequences b_empno_seq.
Requirement is that we need fill out the unique values in table A in table B as well as the sequence (for the empno column) value
Please find below the insert and update statements I tried below.
Please let me know if we have a better approach
INSERT INTO B (ename, job_id)
SELECT DISTINCT ename, job_id
A.;
UPDATE b b1
SET empno = b_empno_seq. NEXTVAL
WHERE ename in (SELECT ename b B2 WHERE b2.ename = b1.ename);
-Suri ;-)
INSERT INTO B
() AS T
SELECT DISTINCT ename,
job_id
A
)
SELECT b_empno_seq.nextval,
Ename,
job_id
T
/
SY.
-
How to avoid duplicates on a column with condition
Hi all
I need some advice here. At work, we have an Oracle APEX application that allow the user to add new records with the decision of the increment automatic number based on the year and the group name.
Said that if they add the first record, group name AA, for 2012, they get the decision number AA 1 2013 as their record casein displayed page of the report.
The second record of AA in 2013 will be AA 2 2013.
If we add about 20 records, it will be AA 20 2013.
The first record for 2014 will be AA 1 2014.
However, recently, we get a claim of the user on two files of the same name of group have the same number of the decision.
When I looked in the history table and find that the time gap between 2 record is about 0.1 seconds.
In addition, we have the correspondence table which allows the user admin update the sequence number start with the restraint that it must be greater than the maximum number of the current name of the current year.
This boot sequence number and the name of the group is stored together in a table.
And in some other case, the user can add a decision duplicate for related record number. (this is a new feature)
The current logic of the procedure to add the new record on the application are
_Get max record table with selected group name (decision_number) and the current year.
_INSERT in the folder table the new record came with the decision to number + 1
_ update sequence number of the number of the decision just added.
So instead of utitlising the process of editing the built-in automatic table of the APEX, I write a procedure that combine all three processes.
I have run some loop for continually perform this procedure, and it seems that it can generate autotically new decision unique number with time about 0.1 second difference.
However, when I increase the number of entry to 200 and let two users run 100 each.
If the time gap is about 0.01 second, double decision numbers are displayed.
What can I do to prevent duplicate?
I can't just apply a unique constraint here for three columns with condition because it can be duplicated in some special conditions. I don't know much about the use of lock and its impact.
This is the content of my procedure
create or replace
PROCEDURE add_new_case)
-ID just use the trigger
p_case_title IN varchar2,
p_year IN varchar2,
p_group_name IN VARCHAR2,
-decisionnumber here
p_case_file_number IN VARCHAR2,
-active
p_user in VARCHAR2
)
AS
NUMBER default_value;
caseCount NUMBER;
seqNumber NUMBER;
previousDecisionNumber NUMBER;
BEGIN
-execution immediate q '[alter session set nls_date_format = "dd/mm/yyyy"]';
SELECT count (*)
IN caseCount
OF CASE_RECORD
WHERE GROUP_ABBR = p_group_name
AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));
SELECT max (decision_number)
IN previousDecisionNumber
OF CASE_RECORD
WHERE GROUP_ABBR = p_group_name
AND to_number (to_char (create_date, "yyyy")) = to_number (to_char (date_utils.get_current_date, "yyyy"));
IF p_group_name IS NULL
THEN seqNumber: = 0;
ON THE OTHER
SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name;
END IF;
IF caseCount > 0 THEN
default_value: largest = (seqNumber, previousdecisionnumber) + 1;
ON THE OTHER
default_value: = 1;
END IF;
INSERT INTO CASE_RECORD (case_title, decision_year, GROUP_ABBR, decision_number, case_file_number, active_yn, created_by, create_date)
VALUES (p_case_title, p_year, p_group_name, default_value, p_case_file_number, 'Y', p_user, sysdate);
-Need to update the sequence here also
UPDATE GROUP_LOOKUP
SET SEQ_NUMBER = default_value
WHERE the ABBREVIATION = p_group_name;
COMMIT;
EXCEPTION
WHILE OTHERS THEN
Logger.Error (p_message_text = > SQLERRM)
, p_message_code = > SQLCODE
, p_stack_trace = > dbms_utility.format_error_backtrace
);
LIFT;
END;
Many thanks in advance,
Ann
It's easier to solve for the case, while p_group_name is not null. In this case, you update a GROUP_LOOKUP line, so that you can select to update this line at the beginning, to prevent cases of two for the same group added at the same time. To do this, change the selection of GROUP_LOOKUP to:
SELECT Seq_number INTO seqNumber FROM GROUP_LOOKUP WHERE ABBREVIATION = p_group_name for an updated VERSION OF the SEQ_NUMBER;
and move this to be the first thing that did the procedure - before it has CASE_RECORD lines.
In the case when p_group_name is set to null, you have some object to be locked. I think the best you can do is to lock the entire table GROUP_LOOKUP:
the table lock in exclusive mode GROUP_LOOKUP wait 100;
The '100 expectation' means that he will wait until 100 seconds before giving up and trigger an error. in practice, that is expected to only wait a moment.
Exclusive mode allows others to read, but not to update the table.
UPDATES and the LOCK of the TABLE will be updates of other sessions wait for this transaction to validate. Queries from other sessions are not affected.
The locks are released when you commit or roll back.
-
Second most high and the third lowest value in columns
create table test (id number, a number, number of b, c number d, e number);
insert into test values (1,13,8,7,14,15);
Power required with column names more high and 3rd lowest value 2
Thank you.ID 2NDHIGHEST 3RDLOWEST --------- ---------- --------- 1 14[D] 13[A]
-
Second most high and the second lowest value in columns
Oracle 11.2.0.1
Windows
create table test (id number, a number, b number, number c number d);
insert into test values (1,20,23,38,15);
insert into test values (2,0,18,18.1,19);
Insert test values (3.40,-2, 25.67, 28);
Power required:SQL> select * from test; ID A B C D ---------- ---------- ---------- ---------- ---------- 1 20 23 38 15 2 0 18 18.1 19 3 40 -2 25.67 28
Thank you.ID 2ndHighest 2ndLowest ---------- ---------- ---------- 1 23 20 2 18.1 18 3 28 25.67
user12050217 wrote:
Thank you. What happens if I want to add column names too with the value as indicated above, please.Decode a more
with test_result as ( select t.*, case greatest(a,b,c,d) when d then greatest(a,b,c) when c then greatest(a,b,d) when b then greatest(a,d,c) when a then greatest(d,b,c) end g2, case least(a,b,c,d) when d then least(a,b,c) when c then least(a,b,d) when b then least(a,d,c) when a then least(d,b,c) end l2 from test t ) select id,g2||decode(g2,a,'[A]',b,'',c,'[C]',d,'[D]') g2,l2||decode(l2,a,'[A]',b,'[B]',c,'[C]',d,'[D]') l2 from test_result;
-
return two values of columns via Javascript
For the same purpose as:
OnClick = "$s ('P1_DEPTNO', #DEPTNO #); return false; »
to return a value from column via javascript, is it possible to return 2 values? Example:
OnClick = "$s ('P1_DEPTNO', #DEPTNO #); $s ('P1_EMP, #EMPLOYEE #); return false; »
Thank you all :)
MaxMaxime Carrier wrote:
Sorry for the wrong question form, I'm not an English speaker, so I try my best to make sentences clear.My goal is like this in this issue: Insert the value of a column in the report in a page with JavaScript element - 2?
My Apex version is: 4.0.2.00.06
My DB is: Oracle 11G
My browser: IE 7I'm trying to save two values when I click on a link in a report. I will use these values in which the declaration of another report. The content of the second report will depend on the link I clicked in the 1st. It will change dynamically without reloading the entire page.
Standard or interactive report?
Where is the defined link? Column link IR? The column link? HTML embedded in the report query?
One of the two values is not a number.
Use quotes around chains of substitution of the column as shown above.
-
The research of a column with comma separated values with ora-text
I use the Oracle 11 g 2 XE and Oracle Text to a web search engine.
I've now created and text indexed a CLOB keywords column that contains words separated by spaces. This allowed me to expand the search, as Oracle Text returns the rows that have one or more keywords that are stored in this column. The contents of the column are visible to the user and serves to 'expand' the search. This does not work as expected.
But now I need support several words or even sentences. With the current configuration, Oracle Text will only search for each keyword. How should I store the phrases and configure Oracle text so that it will search entire sentences (exact match is better, but the partial match is fine too)?
Example of content column of two lines (values separated semicolon):
"Hello, Hello; y at - it anyone out there? Nope; »
"the just; basic facts; »
I found a similar question: looking for a column with values separated by commas, except that I need a solution for Oracle 11 g with it's freetext search.
Possible solutions:
1st solution: I thought to redraw the DB as follows. I would like to make a new array of keywords (pkID NUMBER, nonUniqueID NUMBER, singlePhrase VARCHAR2 (100 BYTE)). And I want to change the column previous keyword to KeywordNonUniqueID, holding the ID (instead of a list of values). At the time of the research I had INNER JOIN with the new keyword table. The problem with this solution is that I will get several lines containing the same data except for the sentence. I guess this will destroy the ranking?
2nd solution: is it possible to store sentences as an XML in the column key of origin and somehow say Oracle text to search for in the XML?
3rd solution: separate individual phrases with spaces, but replace the spaces in sentences with the underscore or something (making a single word). If a phrase "why Hello there, Johnny!" is saved as "Why_hello_there, _Johnny!
4th solution?:
Note that, generally, there is a lot of sentences (less than 100), nor that they will be long (one sentence will be up to 5 words).
Also note that I am currently using CONTAINS, and needs some of its operators, to my full-text searches.When you talk about "phrase", do you mean "a list of words separated by a comma other sentences?
Isn't that the definition of "sentence" used by Oracle Text, where it simply means "a list of words in the order defined."
If I understand your requirement, you want to have data such as:
"aa bb cc dd".
"aa ee dd ff.and give priority to the first on the second if someone looking for "dd".
First, to conduct research in the comma separated list, you should look for in a section. You can either explicitly define sections of field such as
AA bb cc dd
Or you can use the PHRASE special section and set the sentence delimiters correctly. This is done with the attribute BASIC_LEXER punctuationThen you have the number you want to find only words where they are the only words in the section. That's the same problem, I address in the last post of this forum entry:
Contains: match exactlyOur solution will be substantially the same, some surrounding text with special markers, and then prioritize a phrase search with these special markers each side of the word.
We need to do a treatment some additional, although, as we need to surround each "sentence" (in your terminology) with special markers. I did it by surrounding the text with "XX1"... Condition2"then by replacing every comma with"Condition2, XX1"as part of a MULTI_COLUMN_DATASTORE:drop table names; create table names (id number primary key, text varchar2(50)); insert into names values( 1, 'just and kind, kind and loving' ); insert into names values( 2, 'just, kind' ); exec ctx_ddl.drop_preference ( 'mylex' ) exec ctx_ddl.create_preference( 'mylex', 'BASIC_LEXER' ) exec ctx_ddl.set_attribute ( 'mylex', 'PUNCTUATIONS', ',' ) exec ctx_ddl.drop_preference ( 'mcds' ) exec ctx_ddl.create_preference( 'mcds', 'MULTI_COLUMN_DATASTORE' ) exec ctx_ddl.set_attribute ( 'mcds', 'COLUMNS', '''XX1 ''||replace(text, '','',''XX2, XX1'')||'' XX2''' ) exec ctx_ddl.drop_preference ( 'mywl' ) exec ctx_ddl.create_preference( 'mywl', 'BASIC_WORDLIST' ) exec ctx_ddl.set_attribute ( 'mywl', 'SUBSTRING_INDEX', 'YES' ) create index namesindex on names(text) indextype is ctxsys.context parameters( 'datastore mcds wordlist mywl' ) / select score(1),id,text from names where contains( text, '
XX1 kind XX2 kind Output of this is:
SCORE(1) ID TEXT ---------- ---------- -------------------------------------------------- 52 2 just, kind 2 1 just and kind, kind and loving
-
Select the records from the first n distinct values of column
I need to write a query in plsql to select records for the first 3 values distinct from a single column (example below, ID) and all lines for the next 3 distinct values of column and so on until the end of the number of distinct values in a column.
for example:
Age of name ID
1 abc 10
1 def 20
2 IA 10
2 20 JKL
2 mno 60
3 10 pqr
4 the RST 10
4 10 TÜV
5 vwx 10
6 10 XYZ
hij 6 10
7 lmn 10
.
.
.
so now... (up to a few County)
Result must be
1 the application should result->
Age of name ID
1 abc 10
1 def 20
2 IA 10
2 20 JKL
2 mno 60
3 10 pqr
Query 2 should lead to->
4 the RST 10
4 10 TÜV
5 vwx 10
6 10 XYZ
hij 6 10
Query 3 should lead to->
7 lmn 10
.
.
9... ..
so now...
How to write a query for this inside a loop.Hello
Thus, a panel will consist of the lowest id value, the 2nd lowest and the 3rd lower, reggardless of how many lines is involved. The next group will include the 4th lowest id, the 5th lowest and the 6th lowest. To do that, you must assign the numbers 1, 2, 3, 4, 5, 6,... for the rows in order by id, with all lines with the same id, getting the same number and without jumping all the numbers.
This sounds like a job for the analytical DENSE_RANK function:WITH got_grp_id AS ( SELECT id, name, age , CEIL ( DENSE_RANK () OVER (ORDER BY id) / 3 ) AS grp_id FROM table_x ) SELECT id, name, age FROM got_grp_id WHERE id = 1 -- or whatever number you want ;
If you would care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
See the FAQ forum {message identifier: = 9360002} -
Retrieve two values of column in a table
Hi I want to retrieve two values of column in a table and store the values as a single column value in another table... How to do with it?Use in this way:
Insert in tab2 (col1) select col1 | col2 from tab1; -
How to insert data into a BLOB column using sql
Hi all
How to insert data into the BLOB column directly using sql.
Thank youcreate table temp ( a blob, b clob); SQL> / Insert into temp values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ; * ERROR at line 1: ORA-01465: invalid hex number Please help in this.
Prakash PInsert into temporary values (UTL_RAW. CAST_TO_RAW ('32aasdasdsdasdasd4e32'), 'adsfbsdkjf');
-
calculated formula database field trying to insert the null value
Hello
I have 3 elements of database text amount, rate and result.
I enter both values (quantity and frequency), and the property using formula 'result' Gets the computed value.
On the screen all the values are displayed correctly but when trying to save my information text field 'result' tent to insert the null value.
Any suggestions?
Forms 11g
Thanks in advance794018 wrote:
HelloI have 3 elements of database text amount, rate and result.
I enter both values (quantity and frequency), and the property using formula 'result' Gets the computed value.
On the screen all the values are displayed correctly but when trying to save my information text field 'result' tent to insert the null value.Point formula should not be issue of database. And insert the value in the result column in the database is not good idea.
Then, if you want to save it. create the database result item and write trigger (When-validate-point) on amount and filed rates and the trigger code, write:result:=:amount*:rate;
To display the result on the form, create the database no item and change the formula property and write the formula.
Hope this will help you
If someone useful or appropriate, please mark accordingly.
-
How to show the value of string with spaces in separate columns
Hi all, I am using Oracle 10 g.
create table
Insert a tablecreate table sample_test ( Name VARCHAR2(20 BYTE))
Select * from sample_test;insert into sample_test values ('JOAN SCT') insert into sample_test values ('MELIA FILCK') insert into sample_test values ('SSAN LIER-LILEY') insert into sample_test values ('C.M. DANY WES') insert into sample_test values ('A L SCOTT')
I would like the following outputName JOAN SCT MELIA FILCK SSAN LIER-LILEY C.M. DANY WES A L SCOTT
whenever there is a space in the name of the value next to who should be included in another column. Please note the name joan has TBS of two spaces. but it must be treated as a single space.NAME1 NAME2 NAME3 JOAN SCT MELIA FILCK SSAN LIER-LILEY C.M. DANY WES A L SCOTT
also is it possible to get something like that
the value before the first space on the right must be everything in domain Name1 Name2.NAME1 NAME2 JOAN SCT MELIA FILCK SSAN LIER-LILEY C.M.DANY WES A L SCOTT
Thanks in advance.Hello
Since you have Oracle 10, you can use regular expressions:
For the release of 3 columns:
SELECT REGEXP_SUBSTR (name, '[^ ]+', 1, 1) AS name1 , REGEXP_SUBSTR (name, '[^ ]+', 1, 2) AS name2 , REGEXP_SUBSTR (name, '[^ ]+', 1, 3) AS name3 FROM sample_test;
[^ xyz] means "any character except x, y or z."
+ means "1 or more of the previous ones.
The 4th argument to REGEXP_SUBSTR indicates where we want the appearance of the model.For the release of 2 columns:
SELECT REGEXP_REPLACE (name, ' *[^ ]+$') AS before_last_space , REGEXP_SUBSTR (name, '[^ ]+$') AS after_last_space FROM sample_test;
$ here means "the end of the string.
In Oracle 10, you will often use REGEXP_REPLACE to get substrings.
Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!
Published by: Frank Kulash, 7 Sep 2011 15:21
Maybe you are looking for
-
Search protocal for gmail pop and smtp server settings
serverportnumbersettingsforgmailinwindowsmail Search protocal for gmail pop and smtp server settings
-
I installed the updates listed as prompted. The message box confirms updates are successfully completed. Then the updates icon comes back and invite updates again. To turn off the computer, the updates display icon are available to be installed appea
-
Bluetooth blackBerry 8520 Smartphone problems
Just got my phone today and it's very nice. Unfortunately, I can't get all the files from my two existing phones to transfer via bluetooth. I just get a file error message of transfer on my old phones without further explanation. I paired the up has
-
BlackBerry Smartphones that DM Version to download and install?
Ready to upgrade OS 4.2 to 4.5. Say instructions, download the latest version of DM before installing 4.5 on PC. Current version of DM is 4.3. Subsequent versions - 4.5, 4.6 and 4.7. Should what version of DM I download? Thank you!
-
BB of Smartphones blackBerry Storm/iPhoto
Can someone tell me why iPhoto opens to connect my BB to the computer? Thanks in advance.