How to CREATE SEQUENCE in one table
dear all
the one thing i want to know when i use CREATE SEQUENCE in one table like this and then at that table
CREATE SEQUENCE oproduct_sequence
START WITH 1 INCREMENT BY 1
nocache
create table oproduct(
tname varchar2(20) not null,
tid int default oproduct_sequence.nextval
the system indicat that i cannot use this way to create table , so i really want to know how can i achieve this method
becuase when i want to insert inot table oproduct only use
insert into oproduct valuse('aaaa');
and the result like
aaaaa 1
bbbb 2
Actual name is before insert trigger. Some examples are listed below:
Example Number 1 ...
create sequence product_seq start with 1 increment 1
create or replace trigger product_insert before insert for each row begin
select productseq.nextval
into :new.product_id
from dual;
end;
Example Number 2 ...
How to create an autoincrement field in a table with a sequence ...
SQLWKS> create table bob(a number , b varchar2(21));
Statement processed.
First create a sequence
SQLWKS> create sequence x ;
Statement processed.
Then create the trigger.
create trigger y before insert on bob
for each row
when (new.a is null)
begin
select x.nextval into :new.a from dual;
end;
Example Number 3 ...
First create a sequence:
create sequence emp_no_seq;By default it increments by 1 starting at 0.
Use its values when inserting data into the table:
insert into t_emp values (emp_no_seq.nexval, 'Joe Black');~ Madrid.
Similar Messages
-
How to create partition from one table to another?
Hi,
Can any one help me in this :
I have copied table from one schema to another by using the following command. The table is around 300 GB in size and the partitions are not copied. Now i got a request to create partitions in the destination table similar to the source table.
CREATE TABLE user2.table_name AS SELECT * FROM user1.table_name;
I am using Oracle 9i database. This is very urgent, could any one please suggest me how can i create the partitions in user2 table as user1 table.If you have the TOAD/ SQL DEVELOPER , get the partition DDL from the source table and execute it in the newly created table.
or you can use DBMS_METADATA:
SET LONG 10000
SELECT dbms_metadata.get_ddl('TABLE', 'TEST')
FROM DUAL;
Thanks,
<Moderator Edit - deleted link signature - pl see FAQ link on top right> -
How to create sequence(Auto generated no in oralce) with out using Triggers?
If i create trigger sequence of numbers are getting generated but in case if i want to include explicit sequence no at the end of the table say like '9999'...it is not getting updated
Pls help very urgent..user2134711 wrote:
How to create sequence(Auto generated no in oralce) with out using Triggers? Sequence is an oracle object used to create unique number sequence. It has no connection with trigger.
Generally Sequence is used in a Trigger to generate some column value automatically. Something like the IDENTITY column used in SQL Server.
If i create trigger sequence of numbers are getting generated but in case if i want to include explicit sequence no at the end of the table say like '9999'...it is not getting updated This totally depends on how you have written the trigger. If you can show your trigger code we can help you out. -
How to create view for xmltype table in oracle
hi:
Can some one help me how to create view for xmltype table in oracle?
XMLType do not have column
SemThank you !!
I read it and become very hard to implement what I want to do.
Can you give me example please?
My main goal to create view for xmltype table is to XQuery the XML data?
Do you have any other suggestion?
Please help
Ali_2 -
Multiple sequences on one table?
I have a simple table with 3 columns: ID, DML_ID and VALUE. The table was designed to be a metadata table with values for certain DML_IDs. The table has been maintained by IT. However, now the users wants to have control over some of the values. Let's call it User_Maintained values. IT does DML on this table and migrate the change to acceptance and production. At the same time users do DML in production. This causes ID conflict between dev, acc and prod.
My solution is to use 2 sequences, one for IT_maintained IDs the other for User_maintained IDs. One of the sequences starts with a much bigger number like 1000000 to avoid the conflict. Create a before insert trigger on the table to pick the right sequence number depends on if the DML is IT or user maintained.
My question here is, is it ok to use 2 sequences on one table? Is it against best practice of Oracle?
Another idea from my co-worker is, use single sequence instead of 2. The sequence will reside in production database and all the 3 databases (dev, acc and prod) will get ID from the same sequence through dblink. Personally I don't like the idea because I don't think getting sequence from production to be used in development is the "best pratice" of Oracle. Although I don't know where I can find the document to support my opinion.
Any idea is appreciated!!
SharonI've discussed with the DBAs and some developers, we all have concern about the idea of one sequence on production being used by all 3 databases (dev, acc and prod). Database clone is one issue. Also making one database (dev or acc) relies on another (production) is not a good approach. Each database should be as independent as possible - only create the linkage when it's necessary. In this case I don't think it's necessary.
I will go with one sequence for user maintained values (in prod), and a manual increase number (max(id) of IT maintained value plus 1) for IT list.
I do all these because the table was a bad design from the first begining so I can't really come up with a correct solution to work around this.
Thanks for everybody who gave input here. Very appreciated! -
How to create dynamic nested internal table
Hi Experts,
Pleae tell me or give sample code, how to create dynamic nested internal table ?
I have seen threads saying creation of dynamic internal tables using some table structure only. But now the requirement is to create dynamic nested internal table.
For example the internal table contains two fields viz., one is field1 of dynamic internal table and other is normal field2 and values as shown below:
Nested internal table:
field1 | field2 ...
<table content1> | value2..
<table content1> | value2..
Here the [table content] should also a dynamic internal table.
Let me know if you need any other info.
regards
Saravanan Rsee the complete code..i am currently working in ECC6.0 EHP4. just check which version you are using..
REPORT yst_test_000.
DATA:
lt_comptab TYPE cl_abap_structdescr=>component_table,
ls_comp LIKE LINE OF lt_comptab,
lref_newstr TYPE REF TO cl_abap_structdescr,
lref_tab_type TYPE REF TO cl_abap_tabledescr,
lt_fcat TYPE lvc_t_fcat,
ls_fcat TYPE lvc_s_fcat,
ls_dd03p TYPE dd03p,
lt_data type ref to data.
field-symbols: <fs_table> type standard table.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SCARR'
CHANGING
ct_fieldcat = lt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
LOOP AT lt_fcat INTO ls_fcat.
IF ls_fcat-ref_table IS NOT INITIAL.
CLEAR ls_dd03p.
CALL FUNCTION 'BUS_DDFIELD_GET'
EXPORTING
i_tabnm = ls_fcat-ref_table
i_fldnm = ls_fcat-fieldname
IMPORTING
e_dd03p = ls_dd03p
EXCEPTIONS
field_not_found = 1
OTHERS = 2.
IF sy-subrc EQ 0.
ls_comp-name = ls_fcat-fieldname.
ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_dd03p-rollname ).
APPEND ls_comp TO lt_comptab.
CLEAR ls_comp.
ENDIF.
ELSE.
ls_comp-name = ls_fcat-fieldname.
ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_fcat-rollname ).
APPEND ls_comp TO lt_comptab.
CLEAR ls_comp.
ENDIF.
ENDLOOP.
*Now for the Field which you want deep table then you can do like this
ls_fcat-fieldname = 'NESTED_TABLE'.
ls_fcat-inttype = 'C'.
ls_fcat-intlen = '000006'.
ls_fcat-rollname = 'SFLIGHT_TAB1'. "For SFLIGHT
APPEND ls_fcat TO lt_fcat.
ls_comp-name = ls_fcat-fieldname.
ls_comp-type ?= cl_abap_datadescr=>describe_by_name( ls_fcat-rollname ).
APPEND ls_comp TO lt_comptab.
CLEAR ls_comp.
lref_newstr = cl_abap_structdescr=>create( lt_comptab ).
lref_tab_type = cl_abap_tabledescr=>create( lref_newstr ).
create data lt_data type handle lref_tab_type.
assign lt_data->* to <fs_table>.
break-point.
Edited by: Vijay Babu Dudla on Apr 28, 2009 8:05 AM -
How To Create the New Advance Table in standered RN?
Hi Gurus,
How to create the New Advance Table in stander RN?
My requirement is slandered RN Having 1 Advance Table that advance table retrieve the two types of data 1.FUNC 2.BEHV Now My Client is asking split the data
1) FUNC Data
2) BEHV Data.
Now i did first one through Vo Extension Filter the FUNC Data. now i really struck the Another part plz help me i cont go the next step....pl z tell me what are prerequisites are needed and how to go next step plz help me Gurus.
Regards,
SriniHi,
I have adding new & existing forms and creating User Defined Field in row. example on adding a field in an existing Form and its corresponding to the database, including user input validations?
I want to add a new field in the detail section ( row area ) of a Production Document, and save it to database and read it back when the document is opened.
Thanks.
Syed Waqar Khurshid -
How to create tree by database table
hello sir ,
my table is as follows,
NAME LINK ID PID ROLLID
User mgt. f?p=131:1: 1 - 10 ////root node///
district 10 1 1 child
Roles 16 14 4 child
Users 11 10 1 child
ROLLID is given from another table whis is (ROLES). i making tree by the combinations of id , pid, & roll id. by the roll id i can manage the tree to do not display specific nodes to specific users.
ROLE table as :
ROLE_ID NAME DESCRIPTION
1 Administrator This is administrator
2 Assistant Director -
3 Assistant Statistical Officer -
4 Data Entry Operator -
but i think it is very complicated process . give me solution about it
also i have to give my images to each node. how can i do that?You already have a thread going about this: Re: how to create tree by database table .
Scott -
How to create a record for table PLAF with order type 'NB'.
How to create a record for table PLAF with order type 'NB'(standard purchase order).
who can tell me the T-code or some usefull information?
Thanks.Hi
This will be updated automatically when generate planned orders thru MRP. (MD02)
regards
Srinivas -
How to create a tree in table?
How to create a tree in table?
Hi,
check these links,
Tree Structure:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/de59f7c2-0401-0010-f08d-8659cef543ce
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d#31
/people/paolo.romano2/blog/2007/11/09/dynamic-tree-in-abap-webdynpro
Regards,
Muneesh Gitta. -
How to create vertical Scrollbar in table control?
Dear All,
How to create vertical scrollbar in table controll.?
regards,
DharmeshHi
It should be created automatically, if you can't see it, try to set the field lines of table control
PROCESS PBO
MODULE SET_ATTR_TC.
LOOP AT ITAB WITH .....
ENDLOOP.
MODULE SET_ATTR_TC.
DESCRIBE TABLE ITAB LINES SY-TABIX.
<TABLE CONTROL>-LINES = SY-TABIX.
ENDMODULE.
Max -
How to create a multi-line table/column comment
Can someone tell me how to create a multi-line table or column comment?
Apparently, the concatenate operator (||) does not work with the COMMENT statement.
I've searched the Oracle manuals and couldn't find an answer.
COMMENT ON TABLE sometbl IS 'i would like to break up this comment into several lines in order to improve readability'; Effectively, this is what I'd like to do (but it doesn't work):
COMMENT ON TABLE sometbl IS
'i would like to break up ' || CHAR(10) ||
'this comment into several lines ' || CHAR(10) ||
'in order to improve readability' || CHAR(10); Oracle version is 10.2.0.4Why not just
SQL> create table t (a int)
Createtable successfully completed.
SQL> comment on table t is 'i would like to break up
this comment into several lines
in order to improve readability'
Commenton successfully completed.
SQL> select * from user_tab_comments where table_name = 'T'
TABLE_NAME TABLE_TYPE COMMENTS
T TABLE i would like to break up
this comment into several lines
in order to improve readability
1 row selected.? -
What is authorization object and how to create it for a table
Hi All,
What is authorization object and how to create it for a table?
ThanksHi
Authorization
For authorization checks, there are many ways of linking authorization objects with user actions in an SAP system. The following discusses three possibilities in the context of ABAP programming.
Authorization Check for Transactions
You can directly link authorization objects with transaction codes. You can enter values for the fields of an authorization object in the transaction maintenance. Before the transaction is executed, the system compares these values with the values in the user master record and only starts the transaction if the appropriate authorization exists.
Authorization Check for ABAP Programs
For ABAP programs, the two objects S_DEVELOP (program development and program execution) and S_PROGRAM (program maintenance) exist. They contains a field P_GROUP that is connected with the program attribute authorization group. Thus, you can assign users program-specific authorizations for individual ABAP programs.
Authorization Check in ABAP Programs
A more sophisticated, user-programmed authorization check is possible using the Authority-Check statement. It allows you to check the entries in the user master record for specific authorization objects against any other values. Therefore, if a transaction or program is not sufficiently protected or not every user that is authorized to use the program can also execute all the actions, this statement must be used.
AUTHORITY-CHECK OBJECT object
ID name1 FIELD f1
ID name2 FIELD f2
ID namen FIELD fn.
object is the name of an authorization object. With name1, name2 ... , and so on, you must list all fields of the authorization object object. With f1, f2 ... , and so on, you must specify the values that the system is to check against the entries in the relevant authorization of the user master record. The AUTHORITY-CHECK statement searches for the specified object in the user profile and checks the useru2019s authorizations for all values of f1, f2 ... . You can avoid checking a field name1, name2 ... by replacing FIELD f1 FIELD f2 with DUMMY.
After the FIELD addition, you can only specify an elementary field, not a selection table. However, there are function modules available that execute the AUTHORITY-CHECK statement for all values of selection tables. The AUTHORITY-CHECK statement is supported by a statement pattern.
Only if the user has all authorizations, is the return value sy-subrc of the AUTHORITY-CHECK statement set to 0. The most important return values are:
· 0: The user has an authorization for all specified values.
· 4: The user does not have the authorization.
· 8: The number of specified fields is incorrect.
· 12: The specified authorization object does not exist.
A list of all possible return values is available in the ABAP keyword documentation. The content of sy-subrc has to be closely examined to ascertain the result of the authorization check and react accordingly.
REPORT demo_authorithy_check.
PARAMETERS pa_carr LIKE sflight-carrid.
DATA wa_flights LIKE demo_focc.
AT SELECTION-SCREEN.
AUTHORITY-CHECK OBJECT 'S_CARRID'
ID 'CARRID' FIELD pa_carr
ID 'ACTVT' FIELD '03'.
IF sy-subrc = 4.
MESSAGE e045(sabapdocu) WITH pa_carr.
ELSEIF sy-subrc <> 0.
MESSAGE e184(sabapdocu) WITH text-010.
ENDIF.
START-OF-SELECTION.
SELECT carrid connid fldate seatsmax seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF wa_flights
WHERE carrid = pa_carr.
WRITE: / wa_flights-carrid,
wa_flights-connid,
wa_flights-fldate,
wa_flights-seatsmax,
wa_flights-seatsocc.
ENDSELECT.
Regards
Hitesh -
How to create simple scroll-bar table dashboard in Excel 2003?
How to create simple scroll-bar table dashboard in Excel 2003?
Pl mention from step 1 as I am new to thisHi UltraDev,
We discuss SQL Server PowerPivot for SharePoint related issue in this forum. In your case, I suggest you post the question in the following forum for better support:
Excel IT Pro Discussion:
http://social.technet.microsoft.com/Forums/office/en-US/home?forum=excel
Regards,
Elvis Long
TechNet Community Support -
How to create checkbox group and table dynamically?
HI All
How to create checkbox group and table dynamically?
Regards
Ravihi
check this links for creating tables dnamically
How to Create a table dynamically?
Re: how to create a table dynamically in webdynpro
and for checkboxgroup
IWDTransparentContainer rootContainer =
(IWDTransparentContainer)view.getElement("RootUIElementContainer");
IWDCheckBox check = (IWDCheckBox)view.createElement(IWDCheckBox.class,"Check"+k);
//Here "check"+k k represents a unique value every time u create so that u wont get a duplicate instance
check.setChecked(false);
rootContainer.addChild(check);
or Re: adding checkboxes dynamically
Maybe you are looking for
-
I have all thenecessary updates. I have switched over from a PC to Mac back in April and have nad nothing but problems adapting. I don't know why this worked the first time, and put my videos inti imovie, and now it doesn't recognize it at all. An
-
Material with different Valuation types in WM Stock status
Hi If we are maintaining stocks of different valuation types in a Plant , and the Storage Location in the Plant is Warehouse Managed, then how can we see the stocks in different valuation types in the Warehouse stock? thanks Raj
-
Hi all: i am working on bill of exchange portfolio, the problem is when the bill is bounced at bank, the system doesn't transfer the bill from the bill portfolio to the bounced portofolio. although it posts the document of clearing of the bank subacc
-
Barcode Fonts in Microsoft Report Builder 3.0 or the Reporting Services:
hello team; hope all is well on your end.. I need a good link for downloading Barcode Fonts for Report Builder 3.0 or the Reporting Services thx a bunch JohnE
-
I tried to download adobe Photoshop free trial but when it got to about 70%,It came up 'update failed' and it wont download. I've retried downloading it three times but still says the same thing. please help,Thanks