Insert Record creates extra blank record
Hi, all. I'm trying to figure out what I've got going on.
I have setup a php/mysql job log system.
The problem: At random moments, my insert record page will create a blank record in my db. It doesn't do every time, nor every other time. It may only happen once in a day, maybe three times in a day. Never is it consistent.
I know this is a 'can-o-worms', but I'm trying to figure out where to start.
What are possible causes, etc.. Just some clue.
Thanks
I can post code I guess, but I think it has to do with Dreamweaver testing dynamic data automatically. I've turned that option off to see what happens. Any knowledge of that sort of thing.
Similar Messages
-
PHP URL Variable from Insert Record Issue
I have a very simplistic forum style website I have put together. Everything is functionally properly except for one aspect. The basic structure is a page that lists the existing threads (ie: ThreadA, ThreadB, and ThreadC). I have the name of these threads stored in a MySQL database table that is used to generate a repeating dynamic table to grow as the number of threads increases. If the user clicks on one of these links they are taken to a page that displays all of the comments pertaining to that thread. All of the comments are stored in another MySQL database table. I perform a query on this comments page to filter the information in the comments database by the thread name which is passed over from the first page via a URL variable. The link attached to the name of the thread in the repeating table that generates the URL variable is "comments.php?thread=<?php echo $row_threads['threadName']; ?>" This works perfectly, If the user clicks on ThreadB they are taken to the comments page where only the comments pertaining to ThreadB have been filtered and displayed. After the user inserts a comment form ThreadB the comments page reloads displaying the newly created comment.
Also, on the first page, the user has the option to create a new thread; call it ThreadD. The name of this new thread has to be inserted into two tables; one in the master threads table and one in the comments page any time someone adds a comment. (I'm sure there is a better way to structure this, but this was all I could figure out and for my purposes at hand it is sufficient). When the user is taken to this new comment page I have a query set up to pull the last entry in the threads table from the logged in user, ie the newly created thread topic. I have dragged this query to the page to make sure it is pulling the correct thread heading, and it works just fine. What I'm wanting to have happen is after the user enters the first comment I'm wanting them to be redirected to the main comments page with their new comment listed; giving the illusion that the new comment and existing comments page are the same. I'm trying to pass the newly created thread name, ThreadD, in the URL to the main comments page just like I do if they select it from the existing threads page. Under the insert record wizard I click the 'browse' button to select the comments.php page. I then select 'parameters' to add the thread name query as the URL parameter. The generated code is "comments.php?thread=" . $row_threadName['threadName'] . "". The user does go to the main comments page but the URL variable is not coming with it. What I'm left with in the address bar is ..."/comments.php?thread=&" , but it should be ..."comments.php?thread=ThreadD". I tried copying and pasting the URL link from the existing threads page since that works perfectly, and when I do that the main comments page shows up blank after being redirected from the new comments page. If I hard code this, for testing purposes, into the redirect after insertion section (ie: "comments.php?thread=ThreadD") everything works perfectly and the URL in the address bar of the main comments page is "...comments.php?thread=ThreadD&" I noticed the extra "&", but didn't give it much thought since the site is giving me the behavior I'm looking for. My question is, how do I get this new comment page to pass the variable of the newly created thread name to the main comments page to behave like it does when the thread is selected from the list of existing threads? I know it has to do with how the URL variable is either being generated or built from my query, or how I have it listed in the redirect section of the insert wizard, but I can't figure out where I am going wrong. Please let me know if there are any questions or if I need to clarify any aspect. Any and all help is always appreciated. Thank you.Ok, so just to summarize so I am understanding this correctly. You have an ordering page for tires/wheels. A customer places an order for tires/wheels and the data is submitted successfully and this includes a symbol for measurement (in.). But on another summary page the symbol is returning a blank value.
If this is correct we need to see:
- First, the code that is inserting the symbol to the database table in question
- Second, the query and code where you are printing the data to the screen. -
Insert Record in Master-Detail block
I am using JDev 10.1.2, Struts, ADF and JSP
I have a Master-Detail relationship. As the master table(Course) is browsed , the details(Students) record keep changing. Now I want to insert records to the detail (Students) block alone. I am generating the Students id using Sequence, but I want use the Course Id that is being browsed for the new record inserted. How do I do this.
I used the 'Read Only Dynamic Table' for the Details table and used the create button and forward it to create jsp. When I click on create button, it does go to the create jsp, but the the row is not blank. what do I have to do.
Any help will be appreciated.Hi Shay,
Thanks for the response. At least I'm getting some response after so long a time.
I'm not sure what are you looking at. But this is what I have.
I have a browseCourse.jsp that displays the courses in the master and students in the detail. I have a create button for the detail, and my code looks like this.
public class BrowseCourseAction extends DataForwardAction
public void onCreate (DataActionContext actionContext)
actionContext.getHttpServletRequest().getSession().setAttribute("type", "create");
if (actionContext.getEventActionBinding() != null)
actionContext.getEventActionBinding().doIt();
actionContext.setActionForward("createstudent");
when the user click on create button it shows the createstudent.jsp. My question is how to set the course id for the new student that is about to be created.
What do I have to do for this? -
I have created a Emp table as,
CREATE TABLE [dbo].[@EMP] (
[Code] [nvarchar] (8) COLLATE SQL_Latin1_General_CP850_CI_AS NOT NULL ,
[Name] [nvarchar] (100) COLLATE SQL_Latin1_General_CP850_CI_AS NULL ,
[DocEntry] [int] NOT NULL ,
[Canceled] [char] (1) COLLATE SQL_Latin1_General_CP850_CI_AS NULL ,
[Object] [nvarchar] (20) COLLATE SQL_Latin1_General_CP850_CI_AS NULL ,
[LogInst] [int] NULL ,
[UserSign] [int] NULL ,
[Transfered] [char] (1) COLLATE SQL_Latin1_General_CP850_CI_AS NULL ,
[CreateDate] [datetime] NULL ,
[CreateTime] [smallint] NULL ,
[UpdateDate] [datetime] NULL ,
[UpdateTime] [smallint] NULL ,
[DataSource] [char] (1) COLLATE SQL_Latin1_General_CP850_CI_AS NULL ,
[U_Emp_Code] [int] NULL ,
[U_Emp_Name] [nvarchar] (30) COLLATE SQL_Latin1_General_CP850_CI_AS NULL ,
[U_Salary] [int] NULL
I have created this table through sap b one i.e User Table Setup.The type of the above table is master.I have inserted Emp_Code,Emp_Name and Salary columns in the table.The code for inserting record in this table is as follows-
Dim objUDO As SAPbobsCOM.UserTable
Dim lngStatus As Long
Try
objUDO = oCompany.UserTables.Item("Emp")
objUDO.UserFields.Fields.Item("U_Emp_Code").Value = 1
objUDO.UserFields.Fields.Item("U_Emp_Name").Value = "Dilip"
objUDO.UserFields.Fields.Item("U_Salary").Value = 1000
lngStatus = objUDO.Add
If lngStatus = 0 Then
SBO_Application.MessageBox("Record Added Successfully")
Else
SBO_Application.MessageBox(oCompany.GetLastErrorDescription)
End If
Catch ex As Exception
SBO_Application.MessageBox(ex.Message)
End Try
On execyting this code I got error as
Invalid Code.
How do I insert record in this table ?Hi,
Add this code before add other fields
objUDO = oCompany.UserTables.Item("Emp")
objUDO.Code = 1
objUDO.Name = 1
objUDO.UserFields.Fields.Item("U_Emp_Code").Value = 1
objUDO.UserFields.Fields.Item("U_Emp_Name").Value = "Dilip"
objUDO.UserFields.Fields.Item("U_Salary").Value = 1000
Code and Name is auto created by SAP when you add a user defined table and Code is the internal key. These 2 fields cannot be blank.
Regards,
Cherine
Edited by: Cherine Chen on Feb 20, 2008 9:14 AM -
How to insert record inside the internal table in below code
Hi all,
My requirement is to find the sub-total and need to insert in between the internal table.
You can see the output ....where I want the sub-total F2 when 1 & 2 combindely , 3 , 4& 5 combindely .Please check it and let me know is it possible
when i am using modification it is not creating extra row inside the table instead it is modifying one row and putting the total there.
For ex: the origianl output is
F1 F2 F3
A 1 1
B 1 1
F 2 1
D 3 1
E 4 1
C 5 1
We want to display all the total of f2 of 1-2 , 3 , 4-5
so expcected output is
F1 F2 F3
A 1 1
B 1 1
F 2 1
* 3 ->This is the sub-total of 1& 2 of f2
D 3 1
* 1 ->this is the sub-total of 3
E 4 1
C 5 1
* 2 -> this is the sub-total of 4 & 5
= space
But coming output is
A 1 1
B 1 1
* 3 -> it is modifying the F row and inserting the total .Total is comong correct but is shoule insert instead of modifying the record!!
* 1
E 4 1
* 2
Please help how to insert the row total at the end of the chage of field
Please find the below code ..Due to space problem i am attaching below
SasHere is the solution ....i Got the answer Thanks for your helping hands friends
REPORT YTEST_MODIFY.
DATA: BEGIN OF ITAB OCCURS 1,
TOT TYPE C,
F1 TYPE C,
F2 TYPE C,
F3 TYPE I ,
END OF ITAB.
DATA: BEGIN OF JTAB OCCURS 1,
F1 TYPE C,
F2 TYPE C,
F3 TYPE I ,
END OF JTAB.
START-OF-SELECTION.
ITAB-F1 = 'A'.
ITAB-F2 = 1.
ITAB-F3 = 1.
APPEND ITAB.
ITAB-F1 = 'B'.
ITAB-F2 = 1.
ITAB-F3 = 1.
APPEND ITAB.
ITAB-F1 = 'C'.
ITAB-F2 = 5.
ITAB-F3 = 1.
APPEND ITAB.
ITAB-F1 = 'D'.
ITAB-F2 = 3.
ITAB-F3 = 1.
APPEND ITAB.
ITAB-F1 = 'E'.
ITAB-F2 = 4.
ITAB-F3 = 1.
APPEND ITAB.
ITAB-F1 = 'F'.
ITAB-F2 = 2.
ITAB-F3 = 1.
APPEND ITAB.
SORT ITAB BY F2.
LOOP AT ITAB.
WRITE:/1 ITAB-F1 ,
8 ITAB-F2 ,
10 ITAB-F3 .
ENDLOOP.
LOOP AT ITAB.
IF ITAB-F2 = 1 OR ITAB-F2 = 2.
ITAB-TOT = 1.
MODIFY ITAB.
ELSEIF ITAB-F2 = 3.
ITAB-TOT = 3.
MODIFY ITAB.
ELSEIF ITAB-F2 = 4 OR ITAB-F2 = 5.
ITAB-TOT = 4.
MODIFY ITAB.
ENDIF.
ENDLOOP.
SKIP 2.
SORT ITAB BY TOT.
DATA : L_SUM(2) TYPE C,
L_ROW(2) TYPE C.
LOOP AT ITAB.
MOVE-CORRESPONDING ITAB TO JTAB.
APPEND JTAB.
L_SUM = L_SUM + ITAB-F3 .
AT END OF TOT.
CLEAR JTAB.
JTAB-F3 = L_SUM .
APPEND JTAB.
CLEAR L_SUM.
ENDAT.
ENDLOOP.
LOOP AT JTAB.
WRITE:/1 JTAB-F1 ,
8 JTAB-F2 ,
10 JTAB-F3 .
ENDLOOP.
* DATA: a TYPE i , b .
* LOOP AT itab.
* IF b = 0.
* a = a + itab-f3.
* ENDIF.
* AT END OF tot.
* MOVE space TO itab-f1.
* MOVE space TO itab-f2.
* MOVE a TO itab-f3.
* MODIFY itab .
* CLEAR a.
* b = 1.
* ENDAT.
* b = 0.
* ENDLOOP.
* LOOP AT itab.
* MOVE-CORRESPONDING itab TO jtab.
* APPEND jtab.
* ENDLOOP.
* ULINE.
* LOOP AT jtab.
* WRITE: / jtab-f1 , jtab-f2 , jtab-f3.
* ENDLOOP. -
Validate 2 E-mail address fields in insert record form
Hello,
I have used the Insert Record Form Wizard to create a form, including using the Validate Form Server Behavior to validate many fields.
I can't figure out how to compare & validate 2 E-mail address fields.
After the form was created I opened the existing Validate Form Server Behavior - Advanced tab and built the condition {sub_email2} != {sub_email} but this had no affect on submitting the form.
The other thing I tried was creating a new Compare Transaction Field behavior with the same condition {sub_email2} != {sub_email}, this also seemed to have no affect.
I am just a beginner, so I admit to not really knowing what I'm doing, for me ADDT has been a great aid.
The other thing I noticed, when I tried both the items above, besides not affecting being able to submit the form with different E-mail addresses. The red asterisks indicating a required field, would disappear.
Here is the form http://www.oescahealthregistry.org/forms/pedigree_submission.php this version of the form does NOT include either of my attempts to validate the E-mail fields.
Thanks in advance for your help.
DennisHi,
A compare statement should work fine. As an example I made small form that inserts name and email (2 fields) using Insert record wizard.
Name field is required, email field is required and checks that its a valid email structure ([email protected]). I then finish the wizard.
<input type="text" name="email" id="email" value="<?php echo KT_escapeAttribute($row_rsemail['email']); ?>" size="32" />
<?php echo $tNGs->displayFieldHint("email");?> <?php echo $tNGs->displayFieldError("email", "email"); ?>
I then add the extra field to the form that the 2nd email will be entered into, this one I called email2, I then copied the display hint and fielderror code from the first email and placed it behind the 2nd email box and changed the text to reflect email2. Which probably doesnt matter but I put it there anyway.
<input name="email2" type="text" id="email2" size="32" />
<?php echo $tNGs->displayFieldHint("email2");?> <?php echo $tNGs->displayFieldError("email2", "email2"); ?>
Now that I have both email fields in the form, I go to the developer tools under server behavior and select compare transactions fields under form validation.
I hit the + to add a field I then choose email for field, then == for condition, then {POST.email2} for compare to. I enter in an error message and hit ok.
Thats it the form is ready.
The first email field will check against email validation and the 2nd email will check against the first email.
I hope that helps.
Take note that the database actually only has 2 fields to enter data. Then 2nd email field is only for validation.
Message was edited by: Albert S. -
Error while inserting records in sqlLite database
Hi all
I am building a hybrid web app in SMP using phonegap and html.
I am trying to insert records in sql database but i get an error with an undefined error code
Please see below :
function openDatabaseFoo() {
db = window.openDatabase(clientDBName, clientDBVersion, clientDBDisplayName, clientDBMaxSize);
function createDBTables() {
db.transaction(function(tx) {
// Create mine table
var fooCreate = 'CREATE TABLE IF NOT EXISTS ' + fooTable+ ' (empNo, empName)';
tx.executeSql(fooCreate , [],
function (tx, resultSet) {
//success
var msg = 'Sucessfully created';
alert(msg);
logSuccessMessage(msg);
function (err) {
//error code
var msg = "Error creating table = " + err.code;
alert(msg);
logErrorMessage(msg);
the creation of tables is happening properly because i am getting a success message in the alerts.
I am getting the error when i am trying to insert records in the above table
function insertDataTable(){
db.transaction(function(tx) {
var insertSql = 'INSERT INTO ' + fooTable + ' (empNo, empName) VALUES ("1603","baker")';
tx.executeSql(insertSql, [],
function (tx, resultSet) {
//success
var msg = 'Sucessful insertingdata.';
alert(msg);
logSuccessMessage(msg);
function (err) {
//error code
var msg = "Error inserting data sql = " + insertSql + " Error code = " + err.code;
alert(msg);
logErrorMessage(msg);
can some one please help.Also guide me where can i check the sqlLite database logs to see more about the error.
I would really appreciate the help.I have been onto this since past few days now
Regards
ShwetaWhat is err.code, or the value of msg when the error occurs?
Thanks,
Andrew. -
How to insert records in user defined tables through DI Server API
Hi All,
I have created a UDO using some userdefined tables .I am able to insert records in the user defined tables using DI API but problem is that now I want to insert records in those tables using DI Server API but I dont know how to do that please give me some way to do that
Thanks and Regards
UtpalThe AddObject message is :
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Header>
<SessionID>...</SessionID>
</env:Header>
<env:Body>
<dis:AddObject xmlns:dis="http://www.sap.com/SBO/DIS">
<BOM>
<BO>
<AdmInfo>
<Object>...</Object>
</AdmInfo>
</BO>
</BOM>
</dis:AddObject>
</env:Body>
</env:Envelope>
How to use it with a user defined table ? -
Hello
How do I insert a record with the image filename into a database, then send the data just entered as an email?
I was able to do this before but now this new CS3 seems so complicated!
I am unable to just use an insert record behavior then add form fields and change the insert or update recored behavior like before.
Please can I be shown some actual working tutorials on this?
This search function on this forum does not work as I tried to search for this exact statement "insert record and email" and no records appear.
CheersOk, here is the entire page:
<br />
<br /><?php require_once('Connections/cnreviva.php'); ?>
<br /><?php<br />// Load the common classes<br />require_once('includes/common/KT_common.php');<br /><br />// Load the tNG classes<br />require_once('includes/tng/tNG.inc.php');<br /><br />// Make a transaction dispatcher instance<br />$tNGs = new tNG_dispatcher("");<br /><br />// Make unified connection variable<br />$conn_cnreviva = new KT_connection($cnreviva, $database_cnreviva);<br /><br />$editFormAction = $_SERVER['PHP_SELF'];<br />if (isset($_SERVER['QUERY_STRING'])) {<br /> $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);<br />}<br /><br />// *** Mail form as Text format ***<br />if (isset($_POST["FX_sendForm"]) && $_POST["FX_sendForm"] == "frmupload") {<br /> $format = strtolower("Text");<br /> if ($format != "html") $format = "plain";<br /> $filefield = "uploadfile";<br /> $top = "\r\n";<br /> $body = "\r\n";<br /> $excludeArray = array("button","button_x","button_y","uploadfile","FX_sendForm","MM_insert","MM_update"); <br /> $i = 0;<br /> while ($i<sizeof($_POST)) {<br /> if (!in_array(key($_POST),$excludeArray)) {<br /> if (is_array(pos($_POST))) {<br /> $postVar = implode(", ", pos($_POST));<br /> } else {<br /> $postVar = pos($_POST);<br /> } <br /> $body .= strtoupper(key($_POST)) . ": " . stripslashes($postVar) . "\r\n";<br /> }<br /> $i++;<br /> Next($_POST);<br /> } <br /> $bottom = "\r\n";<br /> $from = $_POST["email"];<br /> // set parameters<br /> $recipient = "[email protected]";<br /> $subject = "Test";<br /> $message = $top . $body . $bottom;<br /> // set extra parameters<br /> $headers = "From:" . $from . "\r\n";<br /> $headers .= "Cc:\r\n";<br /> $headers .= "Bcc:\r\n";<br /> require_once("FXInc/FX_mailForm_php.inc");<br /> // send all<br /> mail($recipient, $subject, $message, $headers);<br /> $body = urlencode(str_replace("\r\n", "<br>", $body));<br /> $redirect = "thankyou.php";<br /> if ($redirect) header("Location: " . $redirect);<br />}<br /><br />// Make an insert transaction instance<br />$ins_tblfeedback = new tNG_insert($conn_cnreviva);<br />$tNGs->addTransaction($ins_tblfeedback);<br />// Register triggers<br />$ins_tblfeedback->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");<br />$ins_tblfeedback->registerTrigger("END", "Trigger_Default_Redirect", 99, "thankyou.php");<br />// Add columns<br />$ins_tblfeedback->setTable("tblfeedback");<br />$ins_tblfeedback->addColumn("name", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("email", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("city", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("country", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("shoe_size", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("feedback", "STRING_TYPE", "POST", "");<br />$ins_tblfeedback->addColumn("activate", "STRING_TYPE", "POST", "", "N");<br />$ins_tblfeedback->addColumn("photo", "FILE_TYPE", "FILES", "uploadfile", "");<br />$ins_tblfeedback->setPrimaryKey("id", "NUMERIC_TYPE");<br /><br />// Execute all the registered transactions<br />$tNGs->executeTransactions();<br /><br />// Get the transaction recordset<br />$rstblfeedback = $tNGs->getRecordset("tblfeedback");<br />$row_rstblfeedback = mysql_fetch_assoc($rstblfeedback);<br />$totalRows_rstblfeedback = mysql_num_rows($rstblfeedback);<br />?>
<br />
<br />
<br />
<br />
<br />
<br />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<br />
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<br />
<script src="includes/skins/style.js" type="text/javascript"></script>
<br />
<br />
<br />
<br />
<form action="%3C?php%20echo%20$editFormAction;%20?%3E" method="post" name="frmupload" id="frmupload">
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table width="300" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>Name
<br />
<br />
<input type="text" name="name" id="name" length="20" value="" /></td>
</tr>
<tr>
<td>Email
<br />
<br />
<input type="text" name="email" id="email" length="20" value="" /></td>
</tr>
<tr>
<td>City
<br />
<br />
<input type="text" name="city" id="city" length="20" value="" /></td>
</tr>
<tr>
<td>Country
<br />
<br />
<input type="text" name="country" id="country" length="20" value="" /></td>
</tr>
<tr>
<td>Image
<br />
<br />
<input name="uploadfile" type="file" id="uploadfile" /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<?php<br /> echo $tNGs->getErrorMsg();<br />?>
<input type="submit" name="button" id="button" value="Submit" />
</td>
</tr>
</table>
<br />
<input type="hidden" name="FX_sendForm" value="frmupload" />
<br /></form>
<br />
<p> </p>
<br />
<br /> -
Insert record works for me, but not my client...
This is odd - I basically have an ADDT insert record page to add a database record, which as far as I know worked just as it should.
But my client is saying it doesn't work on her machine - apparently when she hits 'add record' instead of going to the page confirming the record has been added, its just reloading a blank form on the add record page.
I've just double checked on my machine, and it definitely works for me.
She's definitely using the correct the URL.
Its just using mySQL / PHP / phpMyAdmin
Is there any reason at all that this should be the case, or any ideas what is causing it and what a solution might be?
Thanks.Well, apparently its working for her now in Firefox, so looks like it may have something to do with IE8. I noticed on her screenshot there was something called Internet | Protected Mode : On - so maybe that's being over zealous in some way.
-
Unable to insert record in table
Hi,
I want to insert record in database table, but when I execute insert command(at When List changed trigger) as select from query and issue commit, the form trying to insert record from datablock which is obviously having empty items, how can I commit at database level not at form level.
*******************Below the SQL Statement issued by Form******************
INSERT INTO BILL_OF_MATERIALS_TABLE(PROJECTNO,GROUP_,ITEM,STATUS,QUANTITY,UNIT_PRICE,REASON_FOR_CHANGE,REMARKS,AWARD_COPY,LOCKED,VO_COPY) VALUES (:1,:2,:3,:4,:5,:6,:7,EMPTY_CLOB(),:9,:10,:11) RETURNING ROWID,PROJECTNO,GROUP_,ITEM,STATUS,QUANTITY,UNIT_PRICE,REASON_FOR_CHANGE,REMARKS,AWARD_COPY,LOCKED,VO_COPY INTO :12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23
***************Error Raised by Form********
ORA-01400: cannot insert NULL into ("CAPEX"."BILL_OF_MATERIALS_TABLE"."ITEM")Remember that when you write "commit;" within your forms code then Forms interprets it as a commit_form statement. That's why the form-level commit is launched as you mentionned.
So if you want to make a database commit then I think that you should create a stored procedure which makes the insert , and you call this stored procedure within your forms code.
Try it. -
Inserting Record In same table through triggers.
Hi,
I've a table cus_mst ( cus_div_cd vachar2(1), cus_cd varchar2(5), cus_nm varchar2(100) )
Records are inserted in this table through forms ...
We need to automatically insert a record with a diff div_cd for any record inserted in the table .
If div_cd 'I' is entered automatically a record with div cd 'S' with other coulmns having same values should get inserted .
In case div_cd is 'S' then record with div_cd 'I' should get created.
Eg : If in insert ( 'S', 'A0001', 'ABC COmpany' ); another record with values ( 'I', 'A0001', 'ABC Comapny' ) gets created;
One way to do is to insert records in a view ( on the table ) and use instead of trigger to insert the corresponding record. But that is not possible as development team has to change form and use view instead of table.
Have tried doing it by populating a collection in-each-row trigger and then using statment level trigger to insert from the collection. But this leads to recursive error.
Would be great to get more insights into this..
thanks
cheers
JaaniHi,
Within the following script you need to make adjustments according to your needs about the columns you need to test. But this might help you.
Sorry for the layout. But I was not able to adjust it in a short time.
drop table ad_test
create table ad_test ( col1 varchar2(1), col2 varchar2(5), col3 varchar2(100) )
create or replace package ad_test_pkg is
procedure initialize_postpone ;
procedure postpone_record( r_atst in ad_test%rowtype ) ;
procedure handle_postponed_records ;
end ad_test_pkg ;
create or replace package body ad_test_pkg is
type type_atst is table of ad_test%rowtype index by binary_integer ;
t_atst type_atst ;
procedure initialize_postpone is
begin
t_atst.delete ;
end initialize_postpone ;
procedure postpone_record( r_atst in ad_test%rowtype ) is
begin
t_atst(t_atst.count) := r_atst ;
end postpone_record ;
procedure handle_postponed_records is
cursor c_test( cpiv_col1 in ad_test.col1%type ) is
select 'x'
from ad_test
where col1 = cpiv_col1
r_test c_test%rowtype ;
r_atst ad_test%rowtype ;
begin
for i in t_atst.first .. t_atst.last
loop
r_atst := t_atst(i) ;
if r_atst.col1 = 'I'
then
r_atst.col1 := 'S' ;
else
r_atst.col1 := 'I' ;
end if ;
open c_test( cpiv_col1 => r_atst.col1 ) ;
fetch c_test into r_test ;
if c_test%found
then
close c_test ;
else
close c_test ;
insert into ad_test
( col1
, col2
, col3
) values
( 'S'
, r_atst.col2
, r_atst.col3
end if ;
end loop ;
end handle_postponed_records ;
end ad_test_pkg ;
create or replace trigger test_ad_bis
before insert on ad_test
begin
ad_test_pkg.initialize_postpone ;
end ;
create or replace trigger test_ad_air
after insert on ad_test for each row
declare
r_atst ad_test%rowtype ;
begin
r_atst.col1 := :new.col1 ;
r_atst.col2 := :new.col2 ;
r_atst.col3 := :new.col3 ;
ad_test_pkg.postpone_record( r_atst => r_atst ) ;
end ;
create or replace trigger test_ad_ais
after insert on ad_test
begin
ad_test_pkg.handle_postponed_records ;
end ;
insert into ad_test values ( 'I', 'A0001', 'ABC COmpany') ;
select * from ad_test ;
Greets,
Ad
Edited by: loaddev on 10-nov-2010 4:47 -
How to insert records into the Table?
Dear Sir,
I'm new to JDeveloper. Now I managed to create a Frame in JDeveloper with many Text fields and a button. In the back end, I have a procedure to insert records to a table, to which I pass the values of the fields as parameters. Now I'm not getting the steps to call the PL/SQL Stored procedure when I click on the button. I'm using Oracle 9i JDeveloper version 9.0.3.1. and Oracle 9i Database.
Please give me the complete steps to achieve my task - it is quite urgent.
Thanking You in advance.
Regards,
Senthil .A. Perumal.The JDBC tutorial will show you how to call a stored procedure from Java:
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm
One more thing, why are you using such an old version of JDeveloper? any reason not to upgrade to the 10.1.3 version of JDeveloper?
Also you might want to look into ADF and how it makes these type of database interactions easier.
See this demo:
http://www.oracle.com/technology/obe/obe1013jdev/adf_swing/master_detail_page_adfswing_bc.htm -
Add date stamp to insert record
This should be easy. I would think it's a standard procedure but 5 hours of searching the net, the forums, and experimenting has left me with a loss.
I've created a simple form with 3 fields, firstName, lastName, eMail
I've created a SQL database and table with the fields id, date, firstName, LastName, eMail
The id is an int and the primary key, date is set to datetime the rest are varchar
I've created a successful Insert Record behavior and now all I want to do is to update the date field with the datetime value when the record is added.
Things I've tried include a java script to create a date variable, SQL NOW in various forms, a ton of other complex solutions. I've added hidden fields to the form, which got me the closest when I manually entered a value in the same format that I see in the SQL table when I add a row to the table from the PHP admin page.
Please tell me this is not going to require 30 lines of code and another half day of fussing around.Hi Rick,
Please tell me this is not going to require 30 lines of code and another half day of fussing around.
with ADDT it´s pretty easy: just make sure that your datetime column gets ADDT´s "datetime" placeholder {NOW_DT} inserted as "entered value":
Open the Insert Record Transaction dialog box, select the date column and define these settings:
- Submit as: Date
- Get value from: Entered Value
- Value: {NOW_DT}
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver -
Insert Record not saving values
Hi,
I am extremely new to Dreamweaver. I am using MX2004.
I am trying to work with a remote database that I created in
MySQL and I am using PHP.
I created a PHP page added my form, added my input fields,
and used the Insert Record wizard to get to my database on the
server. I also went to the columns section and where it says
‘Fieldname’ Does Not Get a Value. I went and chose my
value from the drop-down Value box. It now says
‘Fieldname’ Gets Value From
‘FORM.Fieldname’ as ‘Text’ I have done that
for all the columns that I am asking the users to fill in including
the fields that are NOT NULL.
The problem is once I test it, it is not putting the data in
the database. When I go back and look at my columns in the Insert
Record Server Behaviors, many of my columns have reverted to
‘Fieldname’ Does Not Get a Value.
For some reason my values are not being saved.
Can someone help with this?
Thanks,
SocapriceThanks Mike. I've sloghtly modified my question and reposted
here:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=12&catid=263&threadid =1322354&enterthread=y
Do you have any thoughts on this?
Cheers,
Roger.
Maybe you are looking for
-
Bills Recivables-NO open item and Reverse the Contingint Liability
Hi Gurus, I have some problem in uploading the accounts. 1.I am trying to post the Bills Recivable at F-36,but when i click on Choose process open items,there is no suitable open item to assign my bills recivable. 2.I had one Bills which is issued in
-
Instance faulted out even all activities are completed successfully
Hi , My BPEL flow is showing all processes as completed but even then I am not able to see output on the response tab and the error pops as timed out . The State of bpel instance is also faulted but when i go to audit trail or the flow I can see that
-
Change Screen layout of T-code: F-02
Hi friends, I want change screen layout of standard SAP transaction code F-02. Please let me know is it possible or not. If possible then which transaction code /path I will use. I want add one more field in header level. Thanks & Regards, Hemant Kum
-
hi all just a simple question. the procedure illustrated in SBW about "status concept" is valid for cockpit datasources? thanks, Stefania
-
Domain aliasing with iMS 5.2?
We're testing iMS 5.2 with direct ldap to ds 5.1 and need to do a domain alias. We have our-name.com and ourname.com. We always use ourname.com but some still use the original our-name.com so we would like it to work as an alias. Vanity domain isn't