Forte names in an SQL Insert
The user doc (Accessing Databases p.67) suggests I should be able to do the
following:
vTableName : TextData = anObject.GetDBTableName();
SQL INSERT INTO :vTableName VALUES ( :aDataArray );
But the compiler complains that the colon before vTableName is a syntax
error. Is there a way to have my table name come from a variable??
TIA,
Eric
I have already told you what variable is throwing the NPE. Why it is doing it we cannot say from the posted code. There is far too little information.
As I said, however, having a statement as an instance variable is a very bad practice, and is bound to cause problems.
There is very little overhead to creating a statement, so there is absolutely no reason not create one every time you need one, and also no reason to hang onto one in an instance variable, either.
Similar Messages
-
SQL or PL/SQL : dynamically insert table name in a SQL Statement
Hi,
We have a strange requirement - we need to dynamically use the table names in a SQL Query. E.g:
select * from :table_name
The table_name will be chosen from a list. I have tried this in SQL as well as PL SQL - but, I have been unsuccessul so far.
Can you guys please help me solve this puzzle ?
I hope I have explained my quesion clearly - if not, please do let me know if some more details are necessary.
Regards,
RamkyThe following is the anonymous block that im using in a report in HTMLDB. My problem is Line Number 9. The bind variable contains the chosen table name at
the run time.
Variable "qry_stmt" contains the query to be returned, so that result set for that query will be displayed in the report.
If I hard code the table name(rather that passing it through bind variable) in the
qry_stmt string, Im getting the result sets for that query. But if I pass through
bind variable at run time, its still generating the string correctly( im printing
using a print statement at line number 14). But its returing the following report
error
report error:
ORA-01403: no data found
Please advice/help me in this.....
declare
qry_stmt varchar2(1000);
p_table varchar2(30) := 'EMP';
P_ENAME varchar2(1000);
begin
IF :p2_TABLE_NAMES IS NOT NULL THEN
qry_stmt := 'select * from '||TRIM(:P2_TABLE_NAMES); -- Line Num 9
execute immediate qry_stmt; --into P_ENAME;
ELSE
qry_stmt := 'SELECT 1 FROM dual ';
END IF;
htp.p(qry_stmt);--Line Num 14
return qry_stmt;
EXCEPTION WHEN NO_DATA_FOUND THEN
NULL;
end;
Thanks and Regards,
Ramky -
SQL Insert Error Error in allocating a connection. Cause: No PasswordCreden
Friends,
While testing my connection in the Sun java Application Server , I get the following error .
"SQL Insert Error Error in allocating a connection. Cause: No PasswordCredential found "
Can somebody please guide ?
regards
DhirajIf you are using Netbeans, then this link might help:
http://forum.java.sun.com/thread.jspa?forumID=136&threadID=598423
Otherwise, have you try this ?
Verify your sun-ejb-jar.xml does not use default-resource-princinpal element:
<res-ref-name>jdbc/pdisasdb</res-ref-name>
<jndi-name>jdbc/pdisasdb</jndi-name>
<default-resource-principal>
<name>myname</name>
<password>geheim</password>
</default-resource-principal>
</resource-ref> -
SQL insert statement in java with Excel file
Dear all,
I wrote a program is as the follow:
import java.io.*;
import java.sql.*;
public class handleExcel
Connection con = null;
Statement stmnt = null;
public handleExcel()
String excel = "C:\\EGS\\app_files\\info_update_form_exported_data.xls";
try
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String str="jdbc:odbc:DRIVER=Microsoft Excel Driver (*.xls);DBQ=" + excel + ";";
String sql = "insert into [Sheet1$] (Name, Age, Test1, Test2, Test3) values ('mary','16','aa','bb','vv')";
con = DriverManager.getConnection(str, "", "");
stmnt = con.createStatement();
stmnt.executeUpdate(sql);
catch(Exception e)
System.out.println("con is error!!");
e.printStackTrace();
public static void main(String[] args)
handleExcel TestHpc = new handleExcel();
But when I run it, the error is as the follow:
java.sql.SQLException: [Microsoft][ODBC Excel Driver]
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
at sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(JdbcOdbcStatement.java:288)
at hk.gov.edb.util.handleExcel.<init>(handleExcel.java:31)
at hk.gov.edb.util.handleExcel.main(handleExcel.java:97)
Please help me to solve this problem. Thank you so much for your help!
Regards,
kzyoHi
You can use the[b] jakarta POI api in order to read/write Excel file from java. Pure Java, no drivers nedeed.
I tested and ok.
Hope this helps -
Apostrophe in a String bombs a SQL insert
I am having an issue with a Customer String parameter that is being used in a SQL INSERT. The customer name may from time to time have an apostrophe in it that causes our SQL INSERT to bomb on a missing comma error. I have tried to do this two separate ways:
1)
String query = "INSERT into CUSTOMER VALUES(" + account[0].custAcctNbr + ",'" + account[0].companyNm + "'," +
"'IN',null," + salesPerson[0].salespersonID + "," + "null,null,null,null,null," +
"null,null,null,null,null,null,null,null,null)";
This works until an apostrophe is in the companyNm varaiable.
2)
PreparedStatement insertCustomer = bcc_conn_cust.prepareStatement(
"INSERT into CUSTOMER VALUES(?,?,?,null,?,null,null,null,null,null,null,null,null,null,null,null,null,null,null");
insertCustomer.setInt(1,Integer.parseInt(account[0].custAcctNbr));
insertCustomer.setString(2,account[0].companyNm);
insertCustomer.setString(3,"IN");
insertCustomer.setInt(4,salesPerson[0].salespersonID);
insertCustomer.executeUpdate();
This also works when there is no apostrophe. However both bomb when it is present. Is there anyway to get around this, short of parsing a company name every single time we insert a new customer?Do you have any idea why this is not working? yes, whatever driver you are using isn't implementing this properly.
variable I am using is a String variable, that has a
value of Bates' Brownies. According to all I read, it
seems I have used the Prepared Statement correctly but
it is giving me that missing comma error. I would
really rather not have to search every single company
name as it is entered.well unless you can either find another driver or fix the one you've
got i can't see what else you can do...
here is some code to help you along with that.
private String replaceQuotes(String toReplace){
StringBuffer buff = new StringBuffer(toReplace);
for(int i=0;i<buff.length();i++){
if(buff.charAt(i)=='\''){
buff.insert(i,'\'');
i++;
return buff.toString(); -
Setting column names in a sql statement
hello everyone i hope someone can help me.
i want a sql statement that gets the column names from a arraylist for example
String sql = ("INSERT INTO Cust (and i want this part to get what is in the arraylist) values (?, ?, ?)");
is there any way i can do this?
thanks for your time
lofttyhello again
well when i try to compile it i get an error saying [ODBC SQL server driver] COUNT field incorrect or syntax error.
what is the problem here?
and regarding my previous question my arraylist holds three names (firstname, lastname and postcode) now i want to be able to add 10 values to the column name firstname, then i want to add 8 values to the column name lastname and then 9 values to column name postcode.
i hope this is a better understanding if not let me know and i will try and explain again.
thanks for your time
loftty
StringBuffer sb = new StringBuffer("INSERT INTO Cust (");
Iterator it = arr.iterator();
while (it.hasNext())
String col = (String) it.next();
sb.append(col);
if (it.hasNext())
sb.append(',');
sb.append(") values (?, ?, ?)");
String sql = sb.toString();
PreparedStatement prepStmt = con.prepareStatement(sql);
prepStmt.setString(1, "hello");
prepStmt.setString(2, "hi");
prepStmt.setString(3, "bye");
prepStmt.executeUpdate();
prepStmt.close(); -
How to put database name/server name insted of SQL
Hi,
I need to put a data base name/server name insted of SQL>, means
if DATABASE NAME is db1, then
db1>. insert into ----
Thanks & Regards,
VenkatHi,
Thank u. But I am looking with out my set SQL... Query. Automatically data base name comes at there. Becuase i am loading data into diffrent servers before run the script, for my reference, is it into correct server or not.
When ever i exit it Return to SQL>. I need always at there. -
SQL insert scripts generation from repository data xml file
Hi All,
I want to generate sql insert scripts from repository data xml file which contain <add-item>elements.
Example: data xml file is contains
<add-item item-descriptor="user" id="741">
<set-property name="gender"><![CDATA[female]]></set-property>
<set-property name="emailStatus"><![CDATA[__NULL__]]></set-property>
<set-property name="receiveEmail"><![CDATA[__NULL__]]></set-property>
<set-property name="email"><![CDATA[[email protected]]]></set-property>
<set-property name="password"><![CDATA[a694cb1d6d011eddc444acb77338c1df6a22bac5de26330e2fe1d20f15f97ed6]]></set-property>
<!-- rdonly derived <set-property name="abandonedOrderCount"><![CDATA[0]]></set-property> -->
<set-property name="locale"><![CDATA[de_DE]]></set-property>
<set-property name="userType"><![CDATA[1]]></set-property>
<set-property name="autoLogin"><![CDATA[__NULL__]]></set-property>
<set-property name="lastName"><![CDATA[Springford]]></set-property>
<set-property name="member"><![CDATA[true]]></set-property>
<set-property name="dateOfBirth"><![CDATA[7/18/1951 00:00:00]]></set-property>
<!-- rdonly derived <set-property name="age"><![CDATA[61]]></set-property> -->
<set-property name="registrationDate"><![CDATA[5/16/1996 00:00:00]]></set-property>
<set-property name="login"><![CDATA[sally]]></set-property>
<set-property name="lastActivity"><![CDATA[6/9/1999 00:00:00]]></set-property>
<set-property name="homeAddress"><![CDATA[741]]></set-property>
<set-property name="passwordSalt"><![CDATA[sally]]></set-property>
<set-property name="generatedPassword"><![CDATA[__NULL__]]></set-property>
<set-property name="firstName"><![CDATA[Sally]]></set-property>
<set-property name="lastPasswordUpdate"><![CDATA[__NULL__]]></set-property>
</add-item>
Thanks
SivaHI Rohan,
Thanks for reply..
I have checked the startSQLRepository script by using this we can export or import repository data from xml to repository.But in startSQLRepository there is no attribute to generate sql
insert scripts from data xmls but there is a option to get the sql scripts(-ouputSQL). -
Export as SQL INSERT generates dud SQL
When I attempted to export data from a table as SQL INSERT statements it generated the statements with single quotes around the table name:
SQL> Insert into 'JOHN_SMITH' values ('162142','89')
2 /
Insert into 'JOHN_SMITH' values ('162142','89')
ERROR at line 1:
ORA-00903: invalid table name
SQL> Fortunately my text editor can do the necessary global replace :)
SQL> Insert into "JOHN_SMITH" values ('162142','89')
2 /
1 row created.
SQL> I am using Raptor #919
Cheers, APCWanted to clarify the table in insert - in the EA4 release, we will not wrap the table name in quotes at all, if you want to preserve multi-byte characters or mixed case table names, you need to wrap the table name in double quotes. We just removed the single quotes we had incorrectly put in. This makes it consistent with creating and modifying a table - i.e. you provide the quotes if you want them.
-- Sharon -
I am trying to take data from a form and insert it into the mySQL db.
this is my update stuff:
s = "INSERT INTO users ";
s += " "(" id"," name"," email"," age"," gender"," zipcode"," username"," password")"";
s += " VALUES "("'"+name+"'"," '"+email+"'"," '"+age+"'"," '"+gender+"'"," '"+zipcode+"'"," '"+username+"'"," '"+password+"'")"";
PreparedStatement stmt = conn.prepareStatement();
stmt.executeUpdate(s);
out.write("Updating");
And then I get this error:
Ex-Message :Syntax error or access violation, message from server: "You have an error in your SQL syntax near '' at line 1" Ex-Code :1064 Ex-SQLState:42000 Ex-Next :null
Any ideas?Your prepared statement should look something like this:
s = "INSERT INTO users ";
s += " (name, email, age, gender, zipcode, username, password)";
s += " VALUES (?,?,?,?,?,?,?)";
stmt.setString( 1, "value for name" );
stmt.setString( 2, "value for email" );
stmt.setInt( 3, 44);
// some info on how to set the type of a parameter value:
// http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html#JDBC208
...http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html#JDBC207
Try to fill out the following value for name:
"(=enter)
UNION select 1 as 'one' --"
I am not sure if prepared statements take care of sql insertion
http://www.sensepost.com/misc/SQLinsertion.htm
If it doesn't I would replace the ' with '' (1 single quote with 2 single quotes) -
Hi,
Brand new to CF - using CF9. Have SQL Server 2005 database. Only one table. Using CF for frontend. Do not know proper syntax to get INSERT to work. Keep getting "Element XXXXXX is undefined in FORM."
Database name is RAWH.
Columns for insert are:
startdate
enddate
TypeHrs
NoOfHours
projects
justification
Frontend has forms and fields which are:
Form Field (value)
firstDates startdate
firstDates enddate
typHrs TypeHrs
noHrs NoOfHours
none projects
none justification
Do not know how to code for INSERT - have this for now - which obviously does not work:
<cfquery name="RAWH" datasource="RAWH">
INSERT INTO RAWH
(startdate, enddate, TypeHrs, NoOfHours, projects, justification)
VALUES
(#Form.firstDates#, '#Form.startdate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#')
</cfquery>
What am I doing wrong?
Get this:
Element FIRSTDATES is undefined in FORM.
The error occurred in D:\ColdFusion9\wwwroot\RAWH1\RAWH1.cfm: line 5
3 : (startdate, enddate, TypeHrs, NoOfHours, projects, justification)
4 : VALUES
5 : (#Form.firstDates#, '#Form.startdate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#')
6 : </cfquery>
7 :
Really appreciate any help - thank you. BTW - datasource is in CF Admin.
John
RAWH
Microsoft SQL Server
OKIan & Dan,
Thanks. I added "<cfdump var="#form#">" and the result is "struct [empty]."
I altered the form/input code thusly,
<form id="beginDate" name="beginDate" onclick="function compareDate(); method="post"
style="width: 1px; height: 1px;">
<td><input style="width: 70px" type="text" id="startdate" name="startdate" /></td>
</form>
<form id="endnDate" name="endDate" onclick="function compareDate(); method="post"
style="width: 1px; height: 1px;">
<td><input style="width: 70px" type="text" id="enddate" name="enddate" /></td>
</form>
Should this be a cfform? I also made separate forms for startdate and enddate rather than one form for both.
The cfquery is this:
<cfquery name="RAWH" datasource="RAWH">
INSERT INTO RAWH
(startdate, enddate, TypeHrs, NoOfHours, projects, justification)
VALUES
(#Form.beginDate#, '#Form.startdate#', '#Form.endDate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#', 'projects', 'justification')
</cfquery>
Still the same result -
Element BEGINDATE is undefined in FORM.
The error occurred in D:\ColdFusion9\wwwroot\RAWH1\RAWH1.cfm: line 7
5 : (startdate, enddate, TypeHrs, NoOfHours, projects, justification)
6 : VALUES
7 : (#Form.beginDate#, '#Form.startdate#', '#Form.endDate#', '#Form.enddate#', #Form.typHrs#, '#Form.TypeHrs#', #Form.noHrs#, '#Form.NoOfHours#', 'projects', 'justification')
8 : </cfquery>
9 :
What am I doing wrong?
Dan - you said that I do not have a form until I submit one - I get this error by opening the web page (F12). There is no onsubmit coding done.
Sorry guys, I am lost with this.
Thank you,
John -
Help with sql insert single quotes
String insert = "INSERT INTO users(firstName, lastName, emailAdd, password) VALUES("+ firstNameForm + "," + lastNameForm + "," + emailForm + "," + passwordForm + ")";
Statement stmt = conn.createStatement();
int ResultSet = stmt.executeUpdate(insert);
I have that sql insert statment in my servlet the servlet compiles fine but does not insert into the users table, i have been told that it is something to do with single quotes in sql statement, can anybody help me out?Or can i change my sql table is there a autonumber which would increase everytime this servlet runs?make your field autoincrement :-)
example
ALTER TABLE `users` CHANGE `user_id` `user_id` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT To insert record in the table.
example:
you have a table test and got two fields,
id = (INT) autoincrement
name = VARCHAR / TEXT etc.
to insert data to the table test try something like this:
String SQLStatement = "INSERT INTO test";
SQLStatement += "(name)";
SQLStatement += " VALUES (?)";
statement = Conn.prepareStatement(SQLStatement);
statement.setString(1, "Duke");
statement.executeUpdate();
statement.close();
Conn.close();Note we dont provide the field for id on our sql statement since it is set as auto-increment ;-)
regards,
Message was edited by:
jie2ee -
SQL INSERT problem - help please
Hello,
I'm having a problem with INSERT statement.
There is a "ShowFinal.jsp" page, which is a list of candidates who selected from the second
interview. The user picked some candidates from the list and conduct the 3rd interview. After
he check suitable candidates(who are selected from the 3rd interview) from the list , enter
basic salary for every selected candidate, enter date of interview and finally submit the form.
These data should be save into these tables.
FinalSelect(nicNo,date)
EmpSalary(nicNo,basicSal)
In this "ShowFinal.jsp" page, it validates the following conditions using JavaScript.
1) If the user submit the form without checking at least one checkbox, then the system should be
display an alert message ("Please select at least one candidate").
2) If the user submit the form without entering the basic salary of that candidate which was
checked, then the system should be display an alert message ("Please enter basic salary").
These are working well. But my problem is how to wrote the "AddNewFinal.jsp" page to save these
data into the db.
Here is my code which I have wrote. But it points an error.
"AddNewFinal.jsp"
String interviewDate = request.getParameter("date");
String[] value = request.getParameterValues("ChkNicno");
String[] bs = request.getParameterValues("basicSal");
String sql ="INSERT INTO finalselect (nicNo,date) VALUES(?,?)";
String sql2 ="INSERT INTO EmpSalary (nicNo,basicSal) VALUES(?,?)";
for(int i=0; i < value.length; i++){
String temp = value;
for(int x=0; x < bs.length; x++){
String basic = bs[x];
pstmt2 = connection.prepareStatement(sql2);
pstmt2.setString(1, temp);
pstmt2.setString(2, basic);
int RowCount1= pstmt2.executeUpdate();
pstmt1 = connection.prepareStatement(sql);
pstmt1.setString(1, temp);
pstmt1.setString(2, interviewDate);
int RowCount= pstmt1.executeUpdate();
Here is the code for "ShowFinal.jsp".
<form name="ShowFinal" method="POST" action="AddNewFinal.jsp" onsubmit="return checkEmpty() &&
ValidateDate();">
<%-- Loop through the list and print each item --%>
<%
int iCounter = 0; //counter for incremental value
while (igroups.hasNext()) {
Selection s = (Selection) igroups.next();
iCounter+=1; //increment
%>
<tr>
<td style="background-color:ivory" noWrap width="20">
<input type="checkbox" name="<%= "ChkNicno" + iCounter %>"
value="<%=s.getNicno()%>"></td>
<td style="background-color:ivory" noWrap width="39">
<%= s.getNicno() %> </td>
<td style="background-color:ivory" noWrap width="174">
<input type="text" name="<%= "basicSal" + iCounter %>" size="10"> </td>
</tr>
<%
%>
Date of interview<input type="text" name="date" size="17"></td>
<input type="submit" value="APPROVE CANDIDATE" name="B1" style="border: 1px solid #0000FF">
</form>........................................................
Here is the error generated by TOMCAT.
root cause
java.lang.NullPointerException
at org.apache.jsp.AddNewFinal_jsp._jspService(AddNewFinal_jsp.java:70)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
I have goto the file "AddNewFinal_jsp.java". The line 70 points to the following line.
for(int i=0; i < value.length; i++){ [/b]
Please can someone help me to solve this problem? Please help me to do this task.
Thanks.Hi Casabianca ,
It is clearly that your problem is not on the database end, more like a servlet/jsp issue.
I will not comment on the javascript portion, but rather the 2 jsps.
a simple way to trace what's go wrong is to check the final result (the html code) of the first jsp (showFinal.jsp), and compare against what is expected by the 2nd jsp (AddNewFinal.jsp). Most browser do provide "view source" on the page visited.
the following code
<input type="checkbox" name="<%= "ChkNicno" + iCounter %>" value="<%=s.getNicno() %>">
<input type="text" name="<%= "basicSal" + iCounter %>"
would likely to be "translated" to html code something as follow:
<input type="checkbox" name=""ChkNicno0" value="nicNo>">
<input type="text" name="basicSal0">
the original code in "AddNewFinal.jsp" using
request.getParameterValues("ChkNicno");
which looking for a none exist http request parameter (sent as "ChkNicno0",etc but look for "ChkNicno"), which has explained before.
the second attempt to use String[] value = request.getParameterValues("ChkNicno" + iCounter); give Cannot resolove symbol :iCounter. because iCounter never defined in the 2nd jsp!
Most of the error message do give clue to cause of error... : )
not too sure on your intension, assume you wish to update only those selected (checked) row to db.
some suggestions:
1) <input type="text" name="ChkNicno" size="10"> </td>...
<input type="text" name="basicSal" size="10"> instead.
then use javascript to based on checked element index (refer to javascript spec for more details), for those index not checked, clear off the correspond index "basicSal" field value.
e.g. ChkNicno[1] is not checked, empty basicSal[1] value before submission.
This will give us only selected rows values.
2) retain the code
String[] value = request.getParameterValues("ChkNicno");
String[] bs = request.getParameterValues("basicSal");at 2nd jsp, as now the http request will pass parameters using "ChkNicno" and "basicSal".
3) some change to the code for optimization
for(int i=0; i < value.length; i++){
String temp = value;
for(int x=0; x < bs.length; x++){
String basic = bs[x];
pstmt2 = connection.prepareStatement(sql2);
pstmt2.setString(1, temp);
pstmt2.setString(2, basic);
int RowCount1= pstmt2.executeUpdate();
pstmt1 = connection.prepareStatement(sql);
pstmt1.setString(1, temp);
pstmt1.setString(2, interviewDate);
int RowCount= pstmt1.executeUpdate();
to
pstmt1 = connection.prepareStatement(sql);
pstmt2 = connection.prepareStatement(sql2);
for(int i=0; i < value.length; i++){
String temp = value;
for(int x=0; x < bs.length; x++){
String basic = bs[x];
pstmt2.setString(1, temp);
pstmt2.setString(2, basic);
int RowCount1= pstmt2.executeUpdate();
pstmt1.setString(1, temp);
pstmt1.setString(2, interviewDate);
int RowCount= pstmt1.executeUpdate();
preparestatement created once should be sufficient as we do not change the sql statement throughout the loop.
there are better solutions out there, this just some ideas and suggestions.Do try out if you wish.
Hope it helps. : ) -
Rep-1401: formula name : Fatal Pl/SQL error occured
Hi,
I am using report builder 6.0 and recently came across a error while running the report. Rep-1401:<formula name> : Fatal Pl/SQL error occured.
I created a formula column in the report. In that i have three local variable.
f_val number := 0;
s_val number := 0;
t_val number := 0;
t_val := f_val/s_val ; --> this gives the above fatal error.
t_val := (f_val + 1)/s_val; --> this gives the above fatal error
t_val := f_val/(s_val + 1); ---> no error
if i change the value of s_val
s_val := 1;
t_val := f_val/(s_val - 1) ; ----> this gives the above fatal error.
Can anyone help me to solve this problem or is it report builder bug.
Please help me, as i desperately need help.
ThanksThanks for ur reply.
I used nvl too, but the same error occurred.
For the information in my question I by mistake typed
t_val := (f_val + 1)/s_val; --> this gives the above fatal error.
but when the value of f_val = zero and s_val is zero why it gives fatal error when i divide, i used nvl on both the variable while dividing but still got the same error.
but if s_val is greater than zero then no error occurs.
please help me, I feel it is a bug. -
How to resolve ORA-00001 Error in SQL Insert?
Hi all, I need your appreciated help.
I make a plsql procedure that is inserting a row according cursor value, I'm having oracle error ORA-00001: unique constraint (constraint_name) violated.
You may see this message if a duplicate entry exists at a different level: in RDBMS MySQL I have the syntax IGNORE to resolve this duplication error... and in Oracle ?
Thanks for your time and hints.
Miguelitouser6317803 wrote:
How to resolve ORA-00001 Error in SQL Insert?ORA-00001 means table has unique/primary key/index and you are trying to insert a row with key value that already exists in the table. I'll assume table COUNTRIES has primary key on COUNTRY_ID. Then change SQL to:
SQL = "INSERT INTO COUNTRIES(COUNTRY_ID,COUNTRY_NAME,REGION_ID) SELECT 'BZ','BLZ',3 FROM DUAL WHERE NOT EXISTS(SELECT 1 FROM COUNTRIES WHERE COUNTRY_ID = 'BZ')"There is a good chance table COUNTRIES also has unique key/index on COUNTRY_NAME. If so use:
SQL = "INSERT INTO COUNTRIES(COUNTRY_ID,COUNTRY_NAME,REGION_ID) SELECT 'BZ','BLZ',3 FROM DUAL WHERE NOT EXISTS(SELECT 1 FROM COUNTRIES WHERE COUNTRY_ID = 'BZ' OR COUNTRY_NAME = 'BLZ')"SY.
Maybe you are looking for
-
Hi Error in posting error is Posting period 002 2008 is not open?? how to open posting period?? regards
-
Navigation for an online portfolio website
Hello, I am creating a webpage to be my online portfolio for my graphic design work. I used a template, which originally uses a flash slideshow to navigate through the portfolio pieces. I would like to have it html instead, and give the user the abil
-
Can't Print after Software Update
After completing an Apple software update which included Epson printer software update 2.7 I am unable to print. I get an error message; Error:/Library/Printers/EPSON/InkjetPrinter2Filter/rastertoescpll.app/Contents/ MacOS/rasertoescpll failed. Can y
-
Spell checking (iOS4) only available in English?
I can't seem to get the spell checking feature enabled. My language is Danish. Any knowledge on this topic?
-
Firefox 10.0.2 how to save adobe tv tutorials
I am able to view the videos online, I wish to save them so I can look at them again without going online.