Hi,
I am new to SQL, taking a course at a State University. I am building a database and would like to have my Owner_ID field come from automatically taking the first 2 letters of that records Last_Name field and 5 random numbers (generated automatically from the system) (example: db43679).
Name Null? Type
OWNER_ID NOT NULL VARCHAR2(7)
FIRST_NAME NOT NULL CHAR(20)
LAST_NAME NOT NULL CHAR(20)
SALUTATION CHAR(4)
STREET VARCHAR2(20)
Is this possible? If so, could someone please assist?
To reemphasize...I am very new to SQL, so keeping it as simpl, yet specific, as possible would be VERY helpful.
Thank you,
MsReece
4 1556
If you want help with Oracle (see thread subject) you are in the wrong forum. I'll transfer you.
Ronald :cool:
OK...thank you!
Ms Reece
If you want help with Oracle (see thread subject) you are in the wrong forum. I'll transfer you.
Ronald :cool:
Hello,
the main scenario:
1) create sequence to generate 5 numbers: -
create sequence s_seq
-
minvalue 1
-
maxvalue 999999999999999999999999999
-
start with 10001
-
increment by 1
-
cache 20
-
2)create trigger before insert each row to fill OWNER_ID: -
create or replace trigger TBI_YOURTABLE
-
before insert on YOURTABLE
-
for each row
-
declare
-
var_owner_id varchar2(50);
-
seq_number number;
-
begin
-
-
select s_seq.nextval into seq_number from dual;
-
var_owner_id := substr(:new.LAST_NAME, 1, 2) || to_char(seq_number);
-
select var_owner_id into :new.OWNER_ID from dual;
-
-
end TBI_YOURTABLE;
-
-
Best Regards,
Michael Milonov http://www.snotratech.com
Hi,
I am new to SQL, taking a course at a State University. I am building a database and would like to have my Owner_ID field come from automatically taking the first 2 letters of that records Last_Name field and 5 random numbers (generated automatically from the system) (example: db43679).
Name Null? Type
OWNER_ID NOT NULL VARCHAR2(7)
FIRST_NAME NOT NULL CHAR(20)
LAST_NAME NOT NULL CHAR(20)
SALUTATION CHAR(4)
STREET VARCHAR2(20)
Is this possible? If so, could someone please assist?
To reemphasize...I am very new to SQL, so keeping it as simpl, yet specific, as possible would be VERY helpful.
Thank you,
MsReece
Thank you, Michael! I will try this.
Ms Reece
Hello,
the main scenario:
1) create sequence to generate 5 numbers: -
create sequence s_seq
-
minvalue 1
-
maxvalue 999999999999999999999999999
-
start with 10001
-
increment by 1
-
cache 20
-
2)create trigger before insert each row to fill OWNER_ID: -
create or replace trigger TBI_YOURTABLE
-
before insert on YOURTABLE
-
for each row
-
declare
-
var_owner_id varchar2(50);
-
seq_number number;
-
begin
-
-
select s_seq.nextval into seq_number from dual;
-
var_owner_id := substr(:new.LAST_NAME, 1, 2) || to_char(seq_number);
-
select var_owner_id into :new.OWNER_ID from dual;
-
-
end TBI_YOURTABLE;
-
-
Best Regards,
Michael Milonov http://www.snotratech.com Sign in to post your reply or Sign up for a free account.
Similar topics
by: new_GUY |
last post by:
I have a HUGE project (at least for me) and need some guidance.
I am trying to create a database for a local university movie club
that allows users to input there basic personal information...
|
by: Nikola Pecigos |
last post by:
Hi,
I have the following problem:
We have an Oracle 9.2 with one table "document" which contains a path
to the filesystem. If I want to index these files (HTML, PDF, World,
Excel, etc.), I...
|
by: Sudhesh Nayak |
last post by:
Hi,
I have an Oracle (8.1) & a SQL Server 2000 database with
Production data. There are situations when I need data from both the
databases. My first choice was to link Oracle to SQL and run DTS...
|
by: Andrew Arace |
last post by:
I scoured the groups for some hands on code to perform the menial task
of exporting table data from an Access 2000 database to Oracle
database (in this case, it was oracle 8i but i'm assuming this...
|
by: AnandaSim |
last post by:
Hi All,
I've had Access 97, 2000 connections to the corporate Oracle database
for a few years now - but seldom use it. When I did use it years ago,
performance was not fast but the features were...
|
by: phantom |
last post by:
Hi all.
We have a production data source running postgres for reporting/DSS
we are thinking on building a warehouse, wherein data would be
transferred from postgres to the warehouse.
The...
|
by: egoldthwait |
last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a
Citrix farm. The issue: we have never converted an Access Db to Oracle
but can probably use Oracle's Workbench to assist with...
|
by: Nasir |
last post by:
Hi there,
Is it posible to set the collation of SQL server 2005 like Oracle, which is
that objects names and column names are case-insensitive, but data is
sensitive;e.g:
In Oracle:
--create...
|
by: RLN |
last post by:
Re: Access 2003/Oracle 9i
I have an Access app that connects to an Oracle DB via OLEDB/VBA code
(no DSN or ODBC)
Queries against straight Oracle tables run fine.
For this query, however,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |