Trigger SEQ column for every new value of ID it should start from 1
I have
table table_A
(ID NUMBER,
SEQ NUMBER,
DETAIL VARCHAR2(2000))
In this table ID and SEQ are combined primary key
Data looks like
ID SEQ DETAIL
1000 1 COMMENTS1
1000 2 COMMENTS2
1001 1 COMMENTS3
1002 1 COMMENTS4
1002 2 COMMENTS5
1002 3 COMMENTS6
1003 1 COMMENTS7
I have ID as oracle generated seq Number , but I need trigger to generate SEQ column value for every new value of ID it should start from 1
This is probably not something you would want to do in a trigger. You would generally be much better off storing ID and detail in the table and generating SEQ in a view, i.e.
CREATE VIEW my_view
AS
SELECT id,
DENSE_RANK() OVER( PARTITION BY id ORDER BY <<something>>) seq,
detail
FROM table_AUnless you can guarantee that only one session will be inserting data at a time, I don't see how you could make a trigger work here.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Similar Messages
-
How to add a default value in a site column for every item in a document library
HI
i created a content type with some site columns ,
and included in a Document library.
Process ( content type)
-ProcessNo
-ProcessName
after that i uploaded 100 Documents but not added value in a site column process name.
now how i add a default value in a site column for every document in a document library
adilHI
i get below error when i change the script
PS C:\scripts> C:\Scripts\updatedefaultvalue.ps1
Cannot index into a null array.
At C:\Scripts\updatedefaultvalue.ps1:8 char:7
+ IF($i[ <<<< "Title"] -eq $null)
+ CategoryInfo : InvalidOperation: (Title:String) [], RuntimeExce
ption
+ FullyQualifiedErrorId : NullArray
$web = Get-SPWeb http://tspmcwfe:89/
$list = $web.Lists["test"]
$item = $list.Items | Where { $_["Name"] -eq "Emc" }
foreach($i in $items)
IF($i["Title"] -eq $null)
$i["Title"] = "test"
$i.Update()
adil
Why are you piping a where in the items? Do you only want to add the "test" to ones matching
a name?
If you have ISE installed on your server I recommend you put your code in there and debug it.
If this is helpful please mark it so. Also if this solved your problem mark as answer. -
How do i increase my key ID +1 for every new user
what iam trying to do is that for every new user that register on my app will get a key id.. that is +1 higher then the old highest id.. i have done this i JavaDB but in mysql i get an exception
here is my sql Q:
sql = "insert into " + mytest_TABLE + "(" + mytest_ID + ", " + mytest_NAME
+ ") values ((case when (select max(" + mytest_ID + ") from " + mytest_TABLE + ")"
+ "IS NULL then 1 else (select max(" + mytest_ID + ") from " + mytest_TABLE + ")+1 end), "
+ encodeSQL(firstName) + ")";
here is my exception:
by the way mytest is my table..
java.sql.SQLException: You can't specify target table 'mytest' for update in FROM clause
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270)
at cont.tt.updateContact(tt.java:49)
at cont.tt.jButton3ActionPerformed(tt.java:179)
at cont.tt.access$200(tt.java:6)
at cont.tt$3.actionPerformed(tt.java:140)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
sry for my bad english..
really hope someone can help me outYou need an 'Identity' column. In MySQL, you need to enable autoincrement and don't insert a value in the column while adding records; MySQL will auto increment the value.
People on the forum help others voluntarily, it's not their job.
Help them help you.
Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
(Yes I know it's on JavaRanch but I think it applies everywhere)
---------------------------------------------------------------- -
Include report header for every new page.
Hi expert,
I have create a report with two buttons, 'previous page' and 'next page'. when i click the buttons, my report will go to another new page. I am using NEW-PAGE in my report.
My problem now is, how can i include TOP-OF-PAGE for every new page in my report? When i click on the button, the TOP-OF-PAGE will not trigger by my report.
Pls advise how to solve it.
Thanks in advance.top-of-page will get triggered in spool request only when u run in background.
-
Changing customer number in alv top of page for every new customer
hi experts,
in alv grid display top-of- page, how to change customer number customer name for every new customer.
please help me.
Regards
Naveen.You may look into this blog
http://help-abap.blogspot.com/2008/09/salv-model-5-add-header-top-of-page.html
This is has been contributed by one of the SCN contributor Naimesh Patel.
a® -
Mail to be send for every new pur group
Hi ,
I have to send mail to recipients of the purchase grp ekgrp..
right now im able to send mail to all purchase orders of the pur.group, individually.
but my requirement demands that
the mail has to triggered for every new pur.group, all the pur orders wthin that group has to come in the mail body of that purchase group.
now actually one loop is already running, plz avoid nested loops.. and help me out asap.
I give you the following code .
all respective data declared above.
FORM form_send_mail .
SELECT ekgrp smtp_addr FROM zmmtr_ekko INTO TABLE it_zmmtr_ekko.
SORT it_final by ekgrp.
LOOP AT it_final." into wa_final.
CLEAR: wa_objtxt,wa_reclist,wa_doc_chng,wa_objpack,g_tab_lines.
REFRESH:it_objtxt,it_reclist,it_objpack.
Mail Subject
wa_doc_chng-obj_descr = c_subject.
*Mail sensitivity
wa_doc_chng-sensitivty = c_p.
*Fetching employee name
READ TABLE it_zmmtr_ekko WITH KEY ekgrp = it_final-ekgrp.
IF sy-subrc = 0.
g_email = it_zmmtr_ekko-smtp_addr.
ELSE.
CONCATENATE c_message it_final-ekgrp INTO g_message SEPARATED BY space.
WRITE: g_message.
CONTINUE.
ENDIF.
MOVE c_hi TO wa_objtxt.
APPEND wa_objtxt TO it_objtxt.
CLEAR wa_objtxt.
APPEND wa_objtxt TO it_objtxt.
CONCATENATE c_po it_final-ebeln INTO wa_objtxt SEPARATED BY space.
APPEND wa_objtxt TO it_objtxt.
CLEAR wa_objtxt.
APPEND wa_objtxt TO it_objtxt.
DESCRIBE TABLE it_objtxt[] LINES g_tab_lines.
READ TABLE it_objtxt into wa_objtxt index g_tab_lines."INTO wa_objtxt INDEX 1."g_tab_lines.
wa_doc_chng-obj_langu = c_en.
*Size of message body
wa_doc_chng-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( wa_objtxt ).
*Creation of the entry for the compressed document
CLEAR wa_objpack-transf_bin.
wa_objpack-head_start = 1.
wa_objpack-head_num = 0.
wa_objpack-body_start = 1.
wa_objpack-body_num = g_tab_lines.
wa_objpack-doc_type = c_raw.
APPEND wa_objpack TO it_objpack.
*Completing the recipient list
*target recipent
REFRESH: it_reclist.
CLEAR: wa_reclist.
wa_reclist-receiver = g_email.
wa_reclist-rec_type = c_u.
APPEND wa_reclist TO it_reclist.
AT NEW ekgrp.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = c_x
commit_work = c_x
IMPORTING
sent_to_all = g_sent_to_all
TABLES
packing_list = it_objpack
contents_txt = it_objtxt
receivers = it_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
ENDAT.
CASE sy-subrc.
WHEN 0.
WRITE: / c_mail ,g_email,c_mail0,it_final-ekgrp, it_final-ebeln, it_final-lifnr.
SKIP 1.
WHEN 1.
WRITE: / c_mail1."chk mail content and do it..
SKIP 1.
WHEN 2.
WRITE: / c_mail2.
SKIP 1.
WHEN 3.
WRITE: / c_mail3.
SKIP 1.
WHEN OTHERS.
WRITE: / c_mail4.
SKIP 1.
ENDCASE.
ENDLOOP.
WRITE: / c_mail5.
SKIP 1.
ENDFORM. " FORM
Rgds,The newly created database should automatically get picked up the maintenance plan.
http://sqlmag.com/sql-server/inside-database-maintenance-plans
No need to manually update the plan. I feel you need to have valid full backup for its successive Diff or Transaction log backup.
Are you getting any error in the job history?
-Prashanth -
According to material num,for every new material num one line space.
Hi,
please give suggestion how to get vertical lines without breaking as shown below.
I want according to material number(AT1),for every new material number one line space have to be there.
I used 'skip' so the verical line is breaking for every new material.
Material Number | Material Description
_____________ |______________________________________________
| AT1 | Catalyst - 18165-RNA-A013-Y2
| AT2 | Catalyst - 18165-RNA-A013-Y2
| AT3 | Catalyst - 18165-RNA-A013-Y2 (COPY)
| AT4 | Catalyst - 18165-RNA-A013-Y2
| AT5 | Catalyst - 18165-RNA-A013-Y2
| CGW0001 SUBSTRATE 148 X 84 X 67 - 400/6/S/0.699L
| CGW0001 SUBSTRATE 148 X 84 X 67 - 400/6/S/0.699L
| CGW0001 SUBSTRATE 148 X 84 X 67 - 400/6/S/0.699L
CGW0001 SUBSTRATE 148 X 84 X 67 - 400/6/S/0.699L
| CGW0001 SUBSTRATE 148 X 84 X 67 - 400/6/S/0.699L
| CGW0001 SUBSTRATE 148 X 84 X 67 - 400/6/S/0.699L
| CGW0001 SUBSTRATE 148 X 84 X 67 - 400/6/S/0.699L
I need line continous but for every new material to material gap.
Thanks,
sree.Hi,
write code like this.
write : /1 sy-vline,120 sy-vline.
give the line size for ex 120
reward if usefull -
Any way to PERMANENTLY zoom Firefox a certain amount, rather than having to re-zoom-in again every time for every new webpage?
== This happened ==
Every time Firefox openedhttps://addons.mozilla.org/en-US/firefox/addon/6965
http://urandom.ca/nosquint/ -
I upgraded my iphone to 5.0.1 and ever since, it has decided to delete old text messages. Only with one contact though, not everybody. So for every new text message I send this person, an old one gets removed. Why? I don't want this to happen.
Connect the phone directly to the computer, not a hub.
Disconnect all other USB devices except keyboard and mouse.
Disable your firewall
Disable your antivirus
In iTunes if it recognizes the phone click "Restore"
If it doesn't recognize the phone:
Disconnect the phone from the phone end, leave the USB cable plugged into the computer
Hold the HOME and SLEEP buttons until the screen turns black, excactly 10 seconds, then release the SLEEP but continue holding the HOME (If an Apple logo appears you have held SLEEP too long; do it over)
While holding HOME connect the cable to the phone
As soon as iTunes recognizes the phone release the HOME button and it should restore.
If neither procedure works note the exact error message and post it. -
When I started my new iPad 2 I could not start from a previous backup because the os on the new iPad is not the latest 7.x used to backup the previous ipad2 to install the new os I had to start the iPad as new. But now I cannot backup from the previously backup ipad
Hi there,
You may find the troubleshooting steps in the articles below helpful.
iCloud: Troubleshooting restoring an iCloud backup
http://support.apple.com/kb/ts4036
iOS: If you can't back up or restore from a backup in iTunes
http://support.apple.com/kb/ts2529
-Griff W. -
Trigger is not updateing the :new value in the table
Hi,
I've greated a row trigger that will trigger on insert statements.
The last thing the trigger will do is to update the :NEW.role_id value in the inserted row, see the trigger bellow.
The trigger was mutation so I had to add the 'PRAGMA AUTONOMOUS_TRANSACTION;' to avoid the mutation error.
When performing test with controlled insert statements the trigger is working without problems, but when I my J2EE application is inserting rows to the table the role_id value is nog updated, see the trigger below and the :NEW.role_id := nRole_id; part. The role_id for the new row is empty. What can be the problem?
CREATE OR REPLACE TRIGGER MSP_36.M2_USER_ALERT_INSERT_TRG_SCA
BEFORE INSERT
ON MSP_36.M2_USER_ALERT
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
ex_not_valid_role_name EXCEPTION;
/* Variables */
nAlertTypeId M2_USER_ALERT.alert_type%TYPE;
isLogical boolean;
validRole boolean;
nRole_id M2_ROLE.role_id%TYPE;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
BEGIN
SELECT distinct at.alert_type INTO nAlertTypeId
FROM M2_USER_ALERT ua, M2_ALERT_TYPE at,M2_ALERT_TYPE_PROPERTIES atp
WHERE ua.alert_type = at.alert_type
AND at.alert_type = atp.ALERT_TYPE_ID
AND ua.alert_type = :NEW.alert_type
AND upper(atp.property_name) = 'LOGICAL'
AND upper(atp.property_value) = 'TRUE';
isLogical := true;
EXCEPTION
WHEN no_data_found THEN
isLogical := false;
NULL;
END;
IF (isLogical = true) THEN
BEGIN
SELECT distinct ro.role_id INTO nRole_id
FROM M2_ROLE ro, M2_USER_ALERT
WHERE ro.name = :NEW.name;
EXCEPTION
WHEN no_data_found THEN
validRole :=false;
RAISE_APPLICATION_ERROR(-20001,'LOGICAL UserAlert: Role with id'|| nRole_id || ' does not exist.');
NULL;
END;
validRole := true;
IF (isLogical = true AND validRole = true AND :NEW.status = 1) THEN
INSERT INTO M2_USER_ROLE (user_id,role_id)
VALUES (:NEW.user_id,nRole_id);
:NEW.role_id := nRole_id;
END IF;
END IF;
commit;
END;
Many thanks,
MichaelI only get a empty column that include now data. The first insert is working correct so I know that the role_id is valid and working. Can there be problem with commit or my AUTONOMOUS_TRANSACTION running this from JDBC ?
EXAMPLE data from
M2_USER_ROLE
===================
USER_ID = ROLE_ID =
===================
20 = 10040 =
1259756 = 10040 =
===================
Example partly data from
M2_USER_ALERT
=========================================================
USERALERT_ID = USER_ID = ALERT_TYPE = NAME = ROLE_ID =
=========================================================
3725 = 1259756 = 10288 = MG_Test = =
=========================================================
When inserted from the application the role_id is empty and I've taken the same SQL from the library cache and run it with same BIND variables and then it's working.
Michael -
Defining column for chart category values
Problem
I want to produce a chart from a table imported from Excel. The data imported perfectly but since the X axis values (just a series of years) are in a column Numbers appears to treat them as another data series, this situation is compounded by the fact some of data columns are non contiguous.
I've tried creating a new table with just two columns, the labels and values, copied from the original table but the new columns are still treated as two series.
I tried creating a new table with a header column and row. Then tried referencing one of the value cells in the original table for the header column. That produced a copy of the whole row but no category data.
Questions:
Is it possible to define a column as the X axis category labels as you can with Excel charts?
If not then how do you create a set of X axis values/labels with an imported table.
Thanks
RBI solved the problem by copying each column and pasting it into Numbers.
In this way I was able to put the X axis data into the header column without a problem.
The problem I had must have been caused by opening the excel file with Numbers.
FYI:
I tested this with one column of data and the X values.
Then pasted in the other columns and found that to add the new series to the chart all you have to do is drag the column selection in the table over the newly added columns. Delightfully simple!
Thanks for suggestion.
RB -
Variable field in Header for every new page
Hi Friends.
I am printing a new page on every new material no encountered . At the same time the HEADER has a field called Container name which is different for each material so this header field needs to be update each time when a new page is called to print .
How to handle this ? Please advise .
In my z calling program I am using this logic .
If old_matnr <> new_matnr
PERFORM PRINT USING 'MAIN' 'NEW_PAGE'.
endif.
Thanks!!
HariIf you have created a seperate window for header then you cant pass a changing field . Instead keep that header window in the main window that will serve your purpose.
you need to put the condition
if &page& eq '1'.
header code.
endif.
Reward points if useful.
Regards,
Nageswar -
Opinion: new Package for every new custom Component?
Hi there,
I am just thinking of some possibilities to structurize my Components I made.
I wonder if it is useful/good programming to define a new package for each new custom Component?
So if I define a new MyComponent class extending JFrame should I make a new package:
"mycomponent"
containing these subfolders:
"view"
"model"
"controler"
subfolging "controler" in:
"listeners"
"adapters"
"events"
Is there any sense to do so? I think this would be the best way to structurize one's components.
But if you do, you have to include millions of packages if you want to use one of these components :(.
Please post, what you think.
Thank you
Sincerely
Karlheinz Toninope ;). I would most certainly not want to put every file in a single directory.
But I like sturctured things. If things belong to each other, it should be visible at once, that they have something to to with each other. And the best method I can figure you is putting them in one package.
The subpackages should be created, because of the model, that is used for all swing componentd (UI-delegete, MVC...) so that each structural component is where it belongs to.
I don't like it if tere are 100 events one object could possibly create and you don't know the events from the component (of course you can guess by the name Event :)), but if they are in the same package, you would have to scroll a long way to get the thing you want (either m, v or c).
So this is why I would do it ;).
Anyway: do includes make the program run slower (I have read many threads about it, but there are way to many opinions, so I would be grateful if you post your opinions here, thx ;).
Thanks for your answer,
Sincerely
Karlheinz Toni
p.s.: why wouldn't you put them in a seperate directory (just overkill?), would you use classes that are structured like this if you are looking for a implementation of something and find it in this structure? -
NOT specify new DataSource for every new stored procedure?
I'm in a solution where I'm having multiple reports, and I want to create my reports one at a time, create a stored procedure for it, then create a report for that stored procedure, then go on to the next report in the same way. The problem is that
in Visual Studio, the DataSource does not update to recognize the new stored procedure, so I have to keep creating a new data source each time. Is there any way around this so I don't have to create a million data sources?Hi jiwakersm,
I will answer your questions one by one:
Report Builder vs Report Designer:
• Report Builder is available in two versions: stand-alone and ClickOnce. The stand-alone version is installed on your computer by you or an administrator. The ClickOnce version is installed automatically with SQL Server 2012 Reporting Services (SSRS)
and downloaded to your computer from Report Manager or a SharePoint site integrated with Reporting Services.
• Report Designer in Business Intelligence Development Studio is a report authoring environment that is hosted in Microsoft Visual Studio.
If we want to
create an .rdlc report file, we should use ReportViewer control in an application project or a Web site. If we want to open an .rdlc report file, we should open the project or web site in Visual Studio. Note that Report Builder and Report Designer are not
included in Visual Studio.
As to the Report Data pane, we should click one report in the Solution Explorer, then select Report Data after clicking View button in the menu pane. The document said that “create a data source reference, and then select the new option.” means we should
create a shared data source in advance (we can create it in Solution Explorer), then use it as data source. If you are create .rdlc report in Visual Studio, we couldn’t create shared data source. But we can create one data source, then use it to create several
reports in the same project.
Hope this helps.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Maybe you are looking for
-
Help, how do I get iPad Photos to sort the way I want?
I'm at wits end! After a week of constant sync/re-sync/re-name-stripping out all EXIF data, I'm still at the mercy of some random sort order for some of my photos. I have read: http://support.apple.com/kb/HT4221 - which seems to indicate that it read
-
Hi, I lost all of my data on my PC, and my music/photos/videos are all on my iPod. I can't afford to pay for software to do this. But is there any way I can get my Videos/Photos off the iPod proprietary format, and back onto my Vista PC? I already go
-
Why is getting patches so slow
We have a patch proxy setup to speed up installation of patches. But it struck me that downloading a patch for the first time to cache it is surprisingly slow. So I looked into it and observed that patch 113886-34 which was downloading at the time ha
-
Why mi ipod don´t sync my recently played
hi y have problems with my ipod don´t sync my recently played
-
I have a bit of a problem with my aperture library, probably something silly I did, but would appreciate some advice. Here is the situation, something happened, I clicked restore masters (or something like that), and then aperture spend the night pla