Updating or inserting database problem
Hi,
I have a problem when i try to insert or update records within database from java, i m using ms access.
I can retrive the data from the table but when i insert or update it , the code executes without any error but has no effect on the table.
I would be thankful if u guyz help me out .
The code is below :
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");//loading drivers
Connection conn = DriverManager.getConnection("jdbc:odbc:client");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("insert into client (name,hours,minutes) values ('ik',2,34)");
/* int c = s.executeUpdate("insert into client (name,hours,minutes) values ('ik',2,34)");
rs.absolute(2);
rs.updateString("Name","dla");
rs = s.executeQuery("commit");*/
rs.close();
s.close();
conn.close();
Thanks for reply, i appreciate the help u guyz hav givin me
they wer helpful upto some extent but the actual problem with
my coding was that statment s variable is used with to different
sql queries ,
when i used s variable with a single query the base table was affected with the coding changes.
Thanks once again guyz....!
Similar Messages
-
i have got this error
Error inserting valuejava.sql.SQLException: General error
dring inserting record in databse
here is my code
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.sql.*;
import java.util.Date;
import java.lang.String;
public class sign extends HttpServlet
public void doPost(HttpServletRequest request,HttpServletResponse res) throws ServletException,IOException
Connection conn;
conn=null;
ResultSet rs,rs1;
res.setContentType("text/html");
PrintWriter out =res.getWriter();
rs=null;
String UserName=request.getParameter("UserName");
String Password=request.getParameter("Password");
String Password2=request.getParameter("Password2");
String prn=request.getParameter("prn");
String FirstName=request.getParameter("FirstName");
String MiddleName=request.getParameter("MiddleName");
String LastName=request.getParameter("LastName");
String Address1=request.getParameter("Address1");
String City=request.getParameter("City");
String Phone=request.getParameter("Phone");
String Email=request.getParameter("Email");
String CName=request.getParameter("CName");
String Year=request.getParameter("Year");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn =DriverManager.getConnection("jdbc:odbc:mydsn");
PreparedStatement stat1=conn.prepareStatement("INSERT INTO login values(?,?)");
stat1.setString(1,UserName);
stat1.setString(2,Password);
PreparedStatement stat=conn.prepareStatement("INSERT INTO student values(?,?,?,?,?,?,?,?,?,?,?,?)");
stat.setString(1,UserName);
stat.setString(2,Password);
stat.setString(3,prn);
stat.setString(4,FirstName);
stat.setString(5,MiddleName);
stat.setString(6,LastName);
stat.setString(7,Address1);
stat.setString(8,City);
stat.setString(9,Email);
stat.setString(10,Phone);
stat.setString(11,CName);
stat.setString(12,Year);
stat.executeUpdate();
stat1.executeUpdate();
rs.close();
conn.close();
catch(Exception E)
out.println("Error inserting value"+E);
there are two table one is login and other is student..Here is html code :::
<head>
</head>
<body>
<div id="header">
<div id="logo">
<h1><span class="ds27"> Student Managment</span></h1>
<div id="menu">
<ul>
<p>
<li >Home</li>
<li>Fourm</li>
<li class="active">Register student</li>
<li>Campus info</li>
<li>Log out</li>
</p>
</ul>
</div>
<!-- start header --></div>
<!-- end header --><!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
<h1 class="title">Welcome To New Arts Commerce & Science</h1>
<p class="descr"><small>Posted on January 24th, 2009 by Swapnil adsure</small></p>
<p class="descr">
<table border="1" width="400">
<form name="form1" method="POST" >
<SCRIPT language="JavaScript" TYPE="text/javascript">
function validate()
{var r = document.form1;
var email_pat= /\w+@\w+\.\w{1,3}/;
var name_pat = new RegExp("[^a-zA-Z]");
if( r.UserName.value=="")
alert("UserName cannot be blank");
return;
if( r.Password.value.length<=6)
alert("Password Strength too low!! ");
return ;
if( document.form1.Password.value!= document.form1.Password2.value)
alert("The two passwords do not match");
return ;
if(r.prn.value=="")
alert("PRN number cannot be blank");
if((r.FirstName.value=="") || (r.FirstName.value.length < 3) || (name_pat.test(r.FirstName.value)))
alert("First Name Could not be Blank and must contain only ALPHABATES");
return;
if((r.lastName.value=="") || (name_pat.test(r.lastName.value)) || (r.lastName.value.length < 3) )
alert("Last Name Could not be Blank and must contain only ALPHABATES");
return;
if( r.Address1.value=="")
alert("Address cannot be blank");
return ;
if( r.City.value=="")
alert("City cannot be blank");
return ;
if( r.Phone.value=="")
alert("Phone Number cannot be blank");
return ;
if( r.Email.value=="")
alert("Email ID cannot be blank");
return ;
if(r.CName.value=="")
{alert("Class Name cannot be blank");
return ;
if(r.Year.value=="")
{alert("Year cannot be blank");
return ;
document.form1.method ="post";
document.validate.action="http://localhost:8080//servlet/sign.class";
document.form1.submit();
</SCRIPT>
<tr>
<td>User Name
<input type="text" align="middle" size="13" name="UserName"></td>
</tr>
<tr>
<td>Password
<input type="password" align="middle" size="13" name="Password"></td>
</tr>
<tr>
<td>Confirm Password
<input type="password" align="middle" size="13" name="Password2"></td>
</tr>
<tr>
<td >PRN
<input type="text" align="middle" size="13" name="prn"></td>
</tr>
<tr>
<td>First Name
<input type="text" align="middle" size="13" name="FirstName"></td>
</tr>
<tr>
<td>Middel name
<input type="text" align="middle" size="13" name="MiddleName"></td>
</tr>
<tr>
<td>Sur Name
<input type="text" align="middle" size="13" name="LastName"></td>
</tr>
<tr>
<td>Address
<input type="text" align="middle" size="13" name="Address1"></td>
</tr>
<tr>
<td>City
<input type="text" align="middle" size="13" name="City"></td>
</tr>
<tr>
<td>Phone Number
<input type="text" align="middle" size="13"></td>
</tr>
<tr>
<td>Email id
<input type="text" align="middle" size="13" name="Email"></td>
</tr>
<tr>
<td>Class name
<input type="text" align="middle" size="13" name="CName"></td>
</tr>
<tr>
<td>year of Appering
<input type="text" align="middle"" size="13" name="Year"></td>
</tr>
<tr>
<td>
<input type="submit" value="Submit" name="B1" onclick="validate()">
<input type="reset" name="c" value="Cancel">
</td>
</tr> </form></table>
</p>
</div>
</body>
</html>
In this page IT does not call This lines:
document.form1.method ="post"
document.validate.action="http://localhost:8080//servlet/sign.class";
document.form1.submit() -
Hi
I have access DB shared on Win 2008 R2 and application written in vb6. On machine with Win 8.1 application not respond after UPDATE or INSERT command once for 5 minutes, once 10 minuters, once its all ok - max 1 second. On other client in local LAN with
Win 7, Vista or XP application run with no problem. This app with local DB on Win 8.1 also run with no problem.
LAN is GBit, NIC on Win 8.1 machine - Realtek GBE Family.
Any ideas?
Thanks :-)It seems that there is no problem in your code, it seems that you get something wrong with the access database confuguration on your server. I suggest that you ask to Access for Developers forum.
https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to use the mirrored and log shipped secondary database for update or insert operations
Hi,
I am doing a DR Test where I need to test the mirrored and log shipped secondary database but without stopping the mirroring or log shipping procedures. Is there a way to get the data out of mirrored and log shipped database to another database for update
or insert operations?
Database snapshot can be used only for mirrored database but updates cannot be done. Also the secondary database of log shipping cannot used for database snapshot. Any ideas of how this can be implemented?
Thanks,
PreethaHmm in this case I think you need Merge Replication otherwise it breaks down the purpose of DR...again in that case..
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Problem in updating to the database with JBoss
Hi,
We have created a datasource in JBoss to connect to a certain database. The data source works fine when retrieving the data from the database but fails when we try to update or insert the data. Below is part of the error trace:
Caused by: javax.naming.NameNotFoundException: rmsDs not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java(Compiled Code))
at org.jnp.server.NamingServer.getBinding(NamingServer.java(Inlined Compiled Code))
at org.jnp.server.NamingServer.getObject(NamingServer.java(Inlined Compiled Code))
at org.jnp.server.NamingServer.lookup(NamingServer.java(Compiled Code))
at org.jnp.server.NamingServer.lookup(NamingServer.java(Compiled Code))
at org.jnp.server.NamingServer.lookup(NamingServer.java(Compiled Code))
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:701)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:361)
Can any one help me in this regard as soon as possible??
Thanks in advance..
Regards,
RoopaHi,
We have created a datasource in JBoss to connect to a
certain database. The data source works fine when
retrieving the data from the database but fails when
we try to update or insert the data. Below is part of
the error trace:
Caused by: javax.naming.NameNotFoundException: rmsDs
not bound
at
t
org.jnp.server.NamingServer.getBinding(NamingServer.ja
va(Compiled Code))
at
t
org.jnp.server.NamingServer.getBinding(NamingServer.ja
va(Inlined Compiled Code))
at
t
org.jnp.server.NamingServer.getObject(NamingServer.jav
a(Inlined Compiled Code))
at
t
org.jnp.server.NamingServer.lookup(NamingServer.java(C
ompiled Code))
at
t
org.jnp.server.NamingServer.lookup(NamingServer.java(C
ompiled Code))
at
t
org.jnp.server.NamingServer.lookup(NamingServer.java(C
ompiled Code))
at
t
org.jnp.interfaces.NamingContext.lookup(NamingContext.
java:610)
at
t
org.jnp.interfaces.NamingContext.lookup(NamingContext.
java:701)
at
t
org.jnp.interfaces.NamingContext.lookup(NamingContext.
java:572)
at
t
javax.naming.InitialContext.lookup(InitialContext.java
:361)
Can any one help me in this regard as soon as
possible??
Thanks in advance..
Regards,
RoopaPlease check yourself
Are you using the same datasoure name that used for "select" query for "insert
and update " query ?.
thanks,
nvseenu -
Problems updating the BAM database
Hi Guys,
I have an activity that runs for a long time and after executing for about 15-16 mins it causes the following exception.
Did somebody else also faced this problem ever? I have tried configuring all possible timeout parameters but all in vain.
Any help would be highly appreciated.
Thanks,
MK
EXCEPTION DETAILS
Problems updating the BAM database. Reason:Unable to connect to the database.
Caused by: A lock could not be obtained within the time requested
fuego.analyzer.UpdaterRuntimeException: Unable to connect to the database.
at fuego.analyzer.UpdaterRuntimeException.cannotConnecToDatabase(UpdaterRuntimeException.java:80)
at fuego.analyzer.UpdaterRunner.synchronizeMetadata(UpdaterRunner.java:494)
at fuego.analyzer.UpdaterRunner.run(UpdaterRunner.java:273)
at fuego.analyzer.UpdaterRunner.runUpdater(UpdaterRunner.java:176)
at fuego.server.service.BAMRunnerService.runUpdater(BAMRunnerService.java:62)
at fuego.server.execution.BAMUpdater.execute(BAMUpdater.java:33)
at fuego.server.execution.DefaultEngineExecution$AtomicExecutionTA.runTransaction(DefaultEngineExecution.java:290)
at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:465)
at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:543)
at fuego.transaction.TransactionAction.start(TransactionAction.java:216)
at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:116)
at fuego.server.execution.DefaultEngineExecution.executeAutomaticWork(DefaultEngineExecution.java:56)
at fuego.server.execution.EngineExecution.executeAutomaticWork(EngineExecution.java:42)
at fuego.server.execution.ToDoItem.executeAutomaticWork(ToDoItem.java:265)
at fuego.server.execution.ToDoItem.run(ToDoItem.java:536)
at fuego.component.ExecutionThread.processMessage(ExecutionThread.java:752)
at fuego.component.ExecutionThread.processBatch(ExecutionThread.java:732)
at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:138)
at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:130)
at fuego.fengine.ToDoQueueThread$PrincipalWrapper.processBatch(ToDoQueueThread.java:429)
at fuego.component.ExecutionThread.work(ExecutionThread.java:816)
at fuego.component.ExecutionThread.run(ExecutionThread.java:395)
Caused by: SQL Exception: A lock could not be obtained within the time requested
at com.ibm.db2cs.m.j.generateCsSQLException(Unknown Source)
at com.ibm.db2cs.m.b.wrapInSQLException(Unknown Source)
at com.ibm.db2cs.m.b.handleException(Unknown Source)
at com.ibm.db2cs.m.d.handleException(Unknown Source)
at com.ibm.db2cs.m.t.handleException(Unknown Source)
at com.ibm.db2cs.m.s.closeOnTransactionError(Unknown Source)
at com.ibm.db2cs.m.s.movePosition(Unknown Source)
at com.ibm.db2cs.m.s.next(Unknown Source)
at fuego.jdbc.FaultTolerantResultSet.next(FaultTolerantResultSet.java:553)
at fuego.analyzer.Updater.loadInstanceInfoValues(Updater.java:1039)
at fuego.analyzer.Updater.loadInstanceInfoValues(Updater.java:988)
at fuego.analyzer.Updater.loadInstanceInfo(Updater.java:982)
at fuego.analyzer.Updater.synchronize(Updater.java:252)
at fuego.analyzer.UpdaterRunner.synchronizeMetadata(UpdaterRunner.java:480)
... 20 moreGood morning justinmm357,
I would be more than happy to help delink the secondary email address from your My Best Buy™ account. Please send me a private message with the information below, by clicking on the blue button in my signature, and I will make sure that everything is up-to-date.
Name
Phone #
Mailing address
Email address (primary and secondary)
Thank you for reaching out to us on the forum and for being a My Best Buy™ member!
Derek|Social Media Specialist | Best Buy® Corporate
Private Message -
Data is not updated in the database
hi.. to all..
i'm using the following code ...... but the data is not updated in the database.. the output window get closed as soon as i clicked save button...
i don't know wat's problem with the program...
Plz help me.. to get resolve this problem..
import java.applet.*;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import sun.jdbc.odbc.*;
public class Customerdetails extends Frame implements ActionListener
TextField ccod,cname,add,phno,conp,email,fax;
Label l1,l2,l3,l4,l5,l6,l7;
Button save,exit;
Connection con;
ResultSet rs;
Statement stmt;
String s1,s2,s3,s4,s5,s6,s7;
public Customerdetails()
super("CustomerDetails");
setSize(700,750);
setLayout(null);
setBackground(new java.awt.Color(245, 117, 105));
l1=new Label("Customercode");
l2=new Label("CompanyName");
l3=new Label("Address");
l4=new Label("PhoneNumber");
l5=new Label("Contact person");
l6=new Label("EmailAddress");
l7=new Label("FaxNumber");
l1.setBounds(20,100,100,70);
l2.setBounds(20,180,100,70);
l3.setBounds(20,270,100,70);
l4.setBounds(20,340,100,70);
l5.setBounds(20,420,100,70);
l6.setBounds(20,500,100,70);
l7.setBounds(20,580,100,70);
ccod=new TextField();
cname=new TextField();
add=new TextField();
phno=new TextField();
conp=new TextField();
email=new TextField();
fax=new TextField();
ccod.setBounds(200,120,150,50);
cname.setBounds(200,200,150,50);
add.setBounds(200,280,150,50);
phno.setBounds(200,360,150,50);
conp.setBounds(200,440,150,50);
email.setBounds(200,520,150,50);
fax.setBounds(200,600,150,50);
Button save= new Button("Save");
Button exit= new Button("Exit");
save.setBounds(200,680,100,40);
exit.setBounds(350,680,100,40);
add(l1);
add(ccod);
add(l2);
add(cname);
add(l3);
add(add);
add(l4);
add(phno);
add(l5);
add(conp);
add(l6);
add(email);
add(l7);
add(fax);
add(save);
add(exit);
save.addActionListener(this);
exit.addActionListener(this);
setVisible(true);
addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent w) {System.exit(0);}});
public void actionPerformed(ActionEvent ae)
Customerdetails cud= new Customerdetails();
if(ae.getSource()==save)
s1=ccod.getText();
s2=cname.getText();
s3=add.getText();
s4=phno.getText();
s5=conp.getText();
s6=email.getText();
s7=fax.getText();
try
String query = "insert into Customerdetails (Customercode,CompanyName,Address,PhoneNumber,Contact person,EmailAddress,FaxNumber)"+ "values('"+s1+"','"+s2+"','"+s3+"','"+s4+"','"+s5+"','"+s6+"','"+s7+"')";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:prism");
stmt=con.createStatement();
rs=stmt.executeQuery(query);
stmt.close();
catch(ClassNotFoundException e)
System.out.println(e);
catch(SQLException e)
System.out.println(e);
else if(ae.getSource()==exit)
System.exit(0);
else
System.exit(0);
public static void main(String args[])
Customerdetails cud= new Customerdetails();
}This doesn't look right:
,FaxNumber)"+ "values(because it's equal to ,FaxNumber)values(and your SQL server won't understand it, put a whitespace between.
/M -
Using an on update or insert trigger on a SAP table
Hi all,
A question for you regarding using a database trigger in and SAP system.
We are needing to export data for our datawarehouse. Currently we export all the data. That data is getting quite large tho and time is becoming an issue.
One suggestion has been to add a custome field to an existing SAP table to hold a flag to indicate the record has changed but not been extracted. Thenput a trigger on the table in question so that the new field is updated upon update or insert of the record. Then when the extract runs, it will only extract those records with the flag set, then reset the flag.
we are using ERP 6 and SQL Server 2005 (or soon to as we will be upgrading next month).
Any suggestions regarding triggers? Or other options for flagging changed records in large table so we don't have to extract all records every time?
Thanks
Laurie
Edited by: Laurie McGinley on Oct 27, 2008 10:51 PMHi Laurie,
just really shouldn't consider to put triggers into your application.
The problem here is the very nature of triggers to do things 'in the background'.
If you have problems due to the trigger, you won't see it anywhere in the SAP environment.
In a while you probably forget about the trigger at all and then nobody can see, what is happening to the database, just because something is changed "in the background".
Besides that you don't get support for this from SAP, you will make your life a lot harder.
Tabledefinitions may change - your trigger might break.
Put application logic where it belongs - to the application layer!
regards,
Lars -
How to create a thread safe and concurrent form that updates data to database.
Hi ,
I am creating an application which will store information from 4 or 5 text boxes in the database.
At the same instance of time atleast 300 users will be trying to update to the database.
That is trying to execute the same code.
I am worried if there will be any issue of object lockign or my page giving some error or performance issue.
How can I solve this issue.
Regards
VinodSQL Server manages simultaneous access to data itself, when it comes to executing a single query. It locks/unlocks tables/records automatically. So, if you are using a single UPDATE, INSERT or DELETE command, usually you won't need anything to take care
of synchronization, but a problem named "Concurrency issue" which I explained a little ahead.
However, if you are updating more than one table, you must use transactions, so that your changes are applied atomically. This can be done both in database level in T-SQL and also in application level in C#, VB, etc.
In T-SQL you want to use BEGIN TRAN, COMMIT TRAN, ROLLBACK TRAN commands and in C# you want to use TransactionScope.
You should pay attention that, transactions indeed have a hit on the performance of your database. But using them is indispensable. To prevent performance degradation, you have to tune your database and queries which itself is another big topic.
One thing that is more important is a problem known as concurrency issue.
If more than one user tries to update a single record, each one might overwrite the update of another user without being even notified of this. Suppose user A and B both try to update a record. They are not aware of each other working with the application.
They open a record in edit mode in the application. Edit it and then click the "Save" button. When the application saves the record with the data provided by each user, one data will be lost definitely. Because it will be overwritten with the data
another user has provided and his Save command, executes later than the first user.
There are multiple ways to avoid concurrency issue. One of them is using Timestamp (old method) and RowVersion (newer method) column in a table. They can help you detect a change in a record since its last time read. But they are unable to detect what column
or columns are changed.
You can get better answers for this if you ask a solution for concurrency issue in a SQL Server forum.
Regards
Mansoor -
Using of bulk insert create problem
How to use the bulk insert statement in my jsp and which should be updated into the database.
I've tried this one:
bulk insert test from test1.txt with (fieldterminator=':')but it gives an error as:
u don't have permission to use bulk statement.
Could any1 get me rid off from this problem.
in advance thanks.....Most likely the person responsible for permissions in your database could help you out there. If you're here looking for a way to execute commands that you aren't authorized to execute, you are wasting your time.
-
Button /Execute Database Problems
I am trying to do an Update to my database using a button. When I choose the execute type on button the database does not show up and my only connection option is WSDL. I am connecting through OLEDB and can read data from the db no problem. Just need to do basic update, insert , etc.
Thanks
BIt looks like a data connection isn't something that you can call using a button whose control type is Execute; that only seems to be supported for WSDL (although I may be wrong here, that's how it seems to be behaving).
Is there a way you can set up a WSDL that you can call to update your data?
SteveX
Adobe Systems -
Updating and inserting on Long Raw column
Hi All,
My source table contains LONG RAW column in XX databse. I have to fetch the data from this table in YY Databse using DB link and insert into same structured table. The problem is, i can not access the LONG RAW data for some rows which the size exceeding above 32k.
My requirement is, i have to fetch and insert or update the record(Source and target table structure is same and dtabase is different).
Please suggest the best way of handle this problem.
Please let me know if you need more information.
Thanks
Ram
Edited by: ram on Oct 19, 2008 2:11 PM
Edited by: ram on Oct 19, 2008 2:12 PMWe using the procedure to insert and update. Procedure will called to update or insert only one record at a time from XX databse to YY database.
We are not using SQL * PLUS for this operation.
Thanks
Ram -
ORA-03114 when updating or inserting
We are testing a forms application that has been 100% generated
through Designer6, running on version 8.1.5 database.
In one screen there are several blocks linked to different base
tables. If you try and update or insert into one block, the app
crashes with the ora-03114 disconnect error. You get kicked out
of everything.
There are pre-update and pre-insert triggers on this block but
the processes called therein see to run ok. I am a bit stuck on
why this is happening..it never used to and we havent changed
the source code! All the permissions seem to be intact.
Any suggestions?Hello,
There are some information in metalink about error linked to "_intel_fast_memcpy.A+18".
Mainly information about bugs ;)
I don't have any Windows Oracle database here, so I can't test, but, don't you have to CONVERT the database in order to switch from 32bits to 64bits? Did you check the Endianness problem against V$TRANSPORTABLE_PLATFORM or V$DB_TRANSPORTABLE_PLATFORM ?
In fact I'm not sure there's a conversion phase needed.. but the 32 to 64 bits phase might be what tricks you down.
Yoann. -
Creating process for multiple Date fields for update or insert in APEX
hello there,
could someone please help me?
i have a form on Apex based on view that is based on three tables and updating and inserting ok using trigger instead of.
i have a problem now as in my form i have around 75 fileds (items) incuding 30 or more date fields which could be populated or left blank or update later.
so for each date field i have two boxs; one for date, input as dd/mm/yyyy (text field) and second for time, input as 23:45. All dates will be insert or update manually by user. so as i mentioned not all date fields could be poulated at one stage.
so i have created some process and validations and all of them work fine but i came accross if date left blank then (:) giving me problem so i have done following further process for each date field. In real table all the date fields have data type date.
declare
v_my_var date; -- for first date field
str_dy VARCHAR2(10);
dt_indx date;
str_tm VARCHAR2(20);
tm_indx date;
begin
str_dy := :p4_first_date
str_tm := str_dy||' '||substr(:p8_first_date_hh,1,2)||':'||substr(:p8_first_date_HH,4,2);
dt_indx := to_date(str_tm,'DD/MM/YYYY HH24:MI');
IF str_dy is not null then
v_my_var :=dt_indx;
ELSE
v_my_var := NULL;
END IF;
update table 1 set my_date = v_my_var where d_id= :p4_d_id;
end;
above code work fine but one date field of course therefore i have to do same code for each date field with changes and initialise variable again and again for each field.
so i like to ask is there any easy way that is more professional. i was thinking about the procedure and using collection or similar but honestly not much experience on that so could some one please help me?
I will be very thankful.
KRgdsHi,
You can do the needful by re-using the code if you can give the item names as P8_DATE1, P8_DATE_hh1, P8_DATE2, P8_DATEhh2 etc..So your item name just differs by a sequence.
Now you write function which will return desired date value taking above items as input. Pass item names to this function, get session state using APEX_UTIL.GET_SESSION_STATE('item_name') API.
Now modify you code as
FOR i IN 1..30
LOOP
v_date_array[i] = f_get_date('P8_DATE'||i, 'P8_DATEhh'||i);
END LOOP;
....Now you have all date valus in array. Just write one update as follows
UPDATE TABLE1
SET date1 = my_date_array[1], date2 = my_date_array[2]..
WHERE ....Hope it helps :)
Cheers,
Hari -
Creation of a Single button for both Update and Insert
Hi,
I want to create a button which performs both Insert and Update function. As of now i have 2 seperate buttons. Can I combine them in to one by writing a procedure which checks for the data in the database...If the record exists, then it should update the record, if not it should insert...Please guide me
Regards,
PaHi,
If I am inserting in to the table a new record, how do I check for that column in the table...
It should work this way..
I have a list of users in a page, if I click on any user name, it will redirect me to another screen which will allow me to create a record for the selected user name. I want to check the selected user name in the table. If it is already existing then need to update, else insert.
Regards,
Pa
Maybe you are looking for
-
USER STATUS For Inquiry at Item level in VA12.
Dear Sir/Madam, In Customer Inquiry we have maintained User Status at item level as 10,20,30,40 as radiaobutton. Now we have to trigger event to initiate workflow as User changes User status from 10 to 20 like that.Currently if user changes status fr
-
Frequent Messages "Server Can't Find Site"
Could this be a router issue? The Network is connected via cable modem to two notebooks. I get frequent messages "server can't find site." Any ideas?
-
J2dsk1.4.2_02 Plug-in does not work on Microsoft IE 6.0
Hello, If anyone would help, Please ? In this WEB site http://java.sun.com/docs/books/tutorial/essential/threads/clock.html J2sdk1.4.2_02 Java Console throwed ClassNoFoundException. Caused by IoException. Open HTTP connection failed. This WEB shall s
-
Installing Windows 7 thru Parallels
I installed Parallels, am am starting to install Window 7 (Professional). Do I use the 32 bit or 64 bit disc?
-
Just purchase ipad3, trying to play you tube favorites but can't set up a play list (username /password not recognised) Tried downloading apps such as SoundBox but no joy Can anybody help?