How to insert a record in to oracle table from Java which has a oracle LONG Field?
The problem is only 80 char's inserted in to the LONG FIELD which happend to me when i run the same insert statement from SQL plus.
Here is the code....
java.io.File inputFile = new java.io.File("input.txt");
int inputFileLen = (int) inputFile.length();
java.io.InputStream ipStream = new java.io.FileInputStream(inputFile);
System.out.println(inputFileLen);
PreparedStatement myStmt = conn.prepareStatement("insert into LONG_EXAMPLE (notes,name)values(?,?)");
myStmt.setAsciiStream(1, ipStream, inputFileLen);
myStmt.setString(2,"Steve");
int res = myStmt.executeUpdate();
myStmt.close();
Note : Here the size of the input.txt 250 bytes , 1KB.
Thanks in advance......:-)
Cheers,
Vetri !
Hien
I had a similar requirement to you and put the code on a push button. In my case the reports are being run interactively to the screen and then printed, and I have no way to know whether the report had actually been printed, so we rely on the user pressing the button. Of course there is a danger that the user forgets to press the button, but in our situation that would not be disasterous. Whatever method is used, I don't think there is any way to be sure that it has actually come out of the printer.
Similar Messages
-
How to Insert a record in a database table in debugging mode in production
Hi,
How to Insert a record in a database table in debugging mode in production ?
Waiting for kind response.
Best Regards,
Padhy
Moderator Message : Duplicate post locked.
Moderator message : Warning. Don't create multiple threads for same question.
Edited by: Vinod Kumar on May 12, 2011 11:02 AM
Edited by: Vinod Kumar on May 12, 2011 11:04 AMHi Senthil,
Regards,
Phani Raj Kallur
Message was edited by: Phani Raj Kallur -
How to insert 20 records only in one table
hi to all,
i want insert 20 records only in a table,but suppose i want to enter 21th record it will not inserted .
suppose delete one record then insert, it will insert.
but always count(*) is not greater than 20.
is there any solution for that,
pls help meYes there is a solution for that using a materialied view:
SQL> select * from v$version;
BANNER
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> drop table t purge;
Table dropped.
SQL> drop materialized view t_mv;
Materialized view dropped.
SQL> create table t (
2 x integer,
3 y varchar2(30)
4 );
Table created.
SQL> CREATE MATERIALIZED VIEW LOG on t
2 WITH ROWID (x, y)
3 including new values;
Materialized view log created.
SQL> CREATE MATERIALIZED VIEW t_mv
2 REFRESH FAST ON COMMIT AS
3 SELECT count(*) cnt
4 FROM t;
Materialized view created.
SQL> alter table t_mv ADD CONSTRAINT chk check(cnt<=20);
Table altered.
SQL> insert into t select object_id, object_name from all_objects where rownum <
21;
20 rows created.
SQL> commit;
Commit complete.
SQL> insert into t values(21,'KO');
1 row created.
SQL> commit;
commit
ERROR at line 1:
ORA-12008: error in materialized view refresh path
ORA-02290: check constraint (TEST.CHK) violated
SQL>
SQL> select count(*) from t;
COUNT(*)
20
SQL>Not sure that trigger based solution works due to multi versioning read consistency. -
How to insert null record (some col) in table using loop
Hi,
How to insert null record (for some columns) in table using loop.
sample data of x_tab
order_id order_name
231 xxx
123
345
111 vvvv
Thanks,
Lakshman
Edited by: kolipaka on Jul 5, 2012 1:37 PMYou have a table
CREATE TABLE tab (
col1 NUMBER,
col2 NUMBER,
col3 NUMBER,
col4 NUMBER
col5 NUMBER)Now you insert:
INSERT INTO tab (col2, col4) VALUES (5, 7);col1, col3 and col5 are NULL by default (there is no DEFAULT clause for these columns so they are NULL). -
How to insert a JPG file into a Table from a Form?
I create a Schema and a Table as follows:
SQL> create user myphoto identified by myphoto;
User created.
SQL> grant connect,resource to myphoto;
Grant succeeded.
SQL> create table myphoto.photo_table
2 (photo_id varchar2(10) primary key,
3 photo_content blob);
Table created.
I would like to build an Oracle Form with a Text Item to enter the full path and filename to be uploaded and inserted into the photo_table; and a Push Button to insert the jpg file into the photo_table.
Can any one give me details on how this could be done?Hi,
have a look at webutil on otn.oracle.com/products/forms ---> Webutil
Webutil has the capability to load files into the database.
Frank -
How to insert new record in the database table using the Jdeveloper
Hi Masters
I am new Bee in j2EE developing side and i ahve oracle jdeveloper 9i version is 9.0.4
And now I wann to know that how can i create the web application that will enter the Data in the HTML FORM and save that data into the Table emp plz tell me step by step
thx in advancethe steps to follow -
download JDeveloper 10.1.2 from OTN (9.0.4 is very old and has some features that won't be in the next releases).
Then follow the ADF Workshop from the JDeveloper home page on OTN.
(If you have to use 9.0.4 then look for the archives of JDeveloper on OTN)
for example:
http://www.oracle.com/technology/products/jdev/viewlets/viewlet-archive0903.html -
How to insert a record to the z-table.
Hi Experts,
I have created one z-tabe with fields
refnum, and
status.
if the refnum is >200 ; Status field should get the value as "TRUE" else "FALSE".
could any one help me on this.
regards,
Sunilhi,
try this.
data : itab type standard table of (name of ur ztable) with header line.
select * from (ztable) into table itab.
loop at itab.
if itab-refnum > 200.
itab-status = 'true'.
else.
itab-status = 'false'.
endif.
modify table itab[] from itab index sy-tabix.
endloop.
update (ztable) from table itab.
hope this gives some idea. -
Insert same record on two different tables (no master detail)
Hi all,
I'd like to know how to insert 1 record into two different
tables.
the first table is corni_dati the second is cornidati_prev
anytime someone inserts a new record both tables should be
filled.
if ((isset($HTTP_POST_VARS["MM_insert"])) &&
($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO corni_dati (corni_id,
disciplina,
codice_modulo, insegnanti, classi, obiettivi, prerequisiti,
ud1, ud2,
ud3, ud4, ud5, ud6, metodologia, collegamenti, verifiche,
verifiche_note, durata, periodo_inizio, periodo_fine, note,
indirizzo,
modnum, modulo_titolo, `data`, compilato, descrizione) VALUES
(%s, %s,
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,
%s, %s, %s,
%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['corni_id'],
"int"),
GetSQLValueString($HTTP_POST_VARS['disciplina'],
"text"),
GetSQLValueString($HTTP_POST_VARS['codice_modulo'], "text"),
GetSQLValueString($HTTP_POST_VARS['insegnanti'],
"text"),
GetSQLValueString($HTTP_POST_VARS['classi'],
"text"),
GetSQLValueString($HTTP_POST_VARS['obiettivi'],
"text"),
GetSQLValueString($HTTP_POST_VARS['prerequisiti'], "text"),
GetSQLValueString($HTTP_POST_VARS['ud1'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud2'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud3'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud4'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud5'],
"text"),
GetSQLValueString($HTTP_POST_VARS['ud6'],
"text"),
GetSQLValueString($HTTP_POST_VARS['metodologia'], "text"),
GetSQLValueString($HTTP_POST_VARS['collegamenti'], "text"),
GetSQLValueString($HTTP_POST_VARS['verifiche'],
"text"),
GetSQLValueString($HTTP_POST_VARS['verifiche_note'], "text"),
GetSQLValueString($HTTP_POST_VARS['durata'],
"int"),
GetSQLValueString($HTTP_POST_VARS['periodo_inizio'], "text"),
GetSQLValueString($HTTP_POST_VARS['periodo_fine'], "text"),
GetSQLValueString($HTTP_POST_VARS['note'],
"text"),
GetSQLValueString($HTTP_POST_VARS['indirizzo'],
"text"),
GetSQLValueString($HTTP_POST_VARS['modnum'],
"text"),
GetSQLValueString($HTTP_POST_VARS['modulo_titolo'], "text"),
GetSQLValueString($HTTP_POST_VARS['data'],
"date"),
GetSQLValueString($HTTP_POST_VARS['compilato'],
"text"),
GetSQLValueString($HTTP_POST_VARS['descrizione'], "text"));
mysql_select_db($database_itiscorni, $itiscorni);
$Result1 = mysql_query($insertSQL, $itiscorni) or
die(mysql_error());
$insertGoTo = "creacodice_doc.php";
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo));If you are doing this then you really should have a look at
your database
design. Read up on the first 3 normal forms.
Pat.
"darrel" <[email protected]> wrote in message
news:ee77jg$302$[email protected]..
>
>
> --
>> Hi all,
>> I'd like to know how to insert 1 record into two
different tables.
>
> In your SQL query, just use two inserts:
>
> INSERT into TABLE1...; INSERT into TABLE2...
>
> Darrel
> -
How to insert multiple records?
I have dynamically checkboxes, which get the data from database. I have used a FOR loop to store each value of the checkbox to session variables, i.e.
session.setAttribute("Slangs"+a,request.getParameter("langsID"+a)); (p/s: a is a counter, I also set a hidden variable to store the number of record in DB)
Now, I wanna insert these records to the table called CusLangs which has CusID(PK) and Langs(PK). I wanna construct a insert.jsp, so that those checkboxes that I selected can be written into table CusLangs.
Anyone know how to do that?
Thanks.
From
jeffYou have a checkboxes with the same name in your html/jsp.When you post to a servlet/jsp, use request.getParameterValues("checkboxname ) to get String [], ie.
<html>
<input type="checkbox" name="sampleCheck" value="1">
<input type="checkbox" name="sampleCheck" value="2">
</html>
Servlet/ JSP
String check[] = request.getParameterValues("sampleCheck");
query = "Insert into CusLangs (CusID) values (?') ";
stmt = connection.prepareStatement(query);
for(int i=0, i < check.length, i++) {
stmt.setString(1, check[0]);
int x = stmt.executeUpdate();
Hope this will help. -
How to insert multiple records in a single query
Dear all,
Can you please tell
how to insert multiple records in a single query ??INSERT INTO table_name (column_1, column_2) VALUES ('value_A', 'value_B')OR
INSERT INTO table_name
(column_1, column_2)
SELECT 'value_A', 'value_B' FROM DUAL
UNION ALL
SELECT 'value_C', 'value_D' FROM DUAL
;Edited by: Benton on Nov 9, 2010 1:59 PM -
How to insert a record in ROOSPRMSC table? (accidentally deleted)
Calling an InfoPackage in BW causes short dump, while fixing the short dump issue, accidentally
deleted the "ROOSPRMSC" table entries.
Could you tell me how to insert a record in "ROOSPRMSC" table???Hi Senthil,
Regards,
Phani Raj Kallur
Message was edited by: Phani Raj Kallur -
Insert a record in Qualified Lookup Table
Hello everyone,
I need code to insert a record in Qualified Lookup Table where the non-qualifier is a record of type Country. Other fields are qualifiers.
I tried using QualifiedLookupValue.createQualifiedLink(). However, this only helps to insert in the qualifier values, how can I insert the non-qualifier (Country) value?
Any idea?
Many thanks in advance,
BaezHi guys,
Maybe the answer comes late but i'm recently working on this and the API works for me to create and update qualifier values.
Suppose recordMain is the main record, fldQFT is the qualified lookup field in main table, fldQualifier is the qualifier field in QFT table.
To add qualifier value you can use:
QualifiedLookupValue qualifiedLookupValue = new QualifiedLookupValue();
int index = qualifiedLookupValue.createQualifiedLink(recordMain.getId());
qualifiedLookupValue.setQualifierFieldValue(index, fldQualifier, MdmValue);
recordMain.setFieldValue(fldQFT, qualifiedLookupValue);
To update qualifier value, use:
QualifiedLookupValue qualifiedLookupValue = (QualifiedLookupValue) recordMain.getFieldValue(fldQFT);
qualifiedLookupValue.setQualifierFieldValue(index, fldQualifier, MdmValue);
recordMain.setFieldValue(fldQFT, qualifiedLookupValue);
Regards,
James -
Insert data into oracle table from XML file
I need to insert data into oracle table from XML file
If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
Thanks in advanceThe XML DB forum provides the best support for XML topics related to Oracle.
Here's the FAQ on that forum:
XML DB FAQ
where there are plenty of examples of shredding XML into Oracle tables and such like. ;) -
Can I run a Unix shell when insert some record on a specific table?
Can I run a Unix shell when insert some record on a specific table?
I need to run a Unix shell when a record be insert on a table. Is there a way in order to do that?
THanks,
Carlos.1. Make a backup of the extproc.c file in the c:\orant\rdbms80\extproc
directory.
2. Create a file called extern.c in the c:\orant\rdbms80\extproc directory.
The "extern.c" file :
#include <oci.h>
#define NullValue -1
#include<stdio.h>
#include<string.h>
long __declspec(dllexport) OutputString(context ,
path , path_ind ,
message , message_ind,
filemode , filemode_ind ,
len , len_ind )
char *path;
char *message;
char *filemode;
int len;
OCIExtProcContext *context;
short path_ind;
short message_ind;
short filemode_ind;
short len_ind;
FILE *file_handle;
int i ;
char str[3];
int value;
/* Check whether any parameter passing is null */
if (path_ind == OCI_IND_NULL || message_ind == OCI_IND_NULL ||
filemode_ind == OCI_IND_NULL || len_ind == OCI_IND_NULL ) {
text initial_msg = (text )"One of the Parameters Has a Null Value!!! ";
text *error_msg;
/* Allocate space for the error message text, and set it up.
We do not have to free this memory - PL/SQL will do that automatically. */
error_msg = OCIExtProcAllocCallMemory(context,
strlen(path) + strlen(initial_msg) + 1);
strcpy((char *)error_msg, (char *)initial_msg);
/*strcat((char *)error_msg, path); */
OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
/* OCIExtProcRaiseExcp(context, 6502); */
return 0;
/* Open the file for writing. */
file_handle = fopen(path, filemode);
/* Check for success. If not, raise an error. */
if (!file_handle) {
text initial_msg = (text )"Cannot Create file ";
text *error_msg ;
/* Allocate space for the error message text, and set it up.
We do not have to free this memory - PL/SQL will do that automatically. */
error_msg = OCIExtProcAllocCallMemory(context,
strlen(path) + strlen(initial_msg) + 1);
strcpy((char *)error_msg, (char *)initial_msg);
strcat((char *)error_msg, path);
OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
return 0;
i = 0;
while (i < len)
/* Read the hexadecimal value(1). */
str[0] = message;
i++;
/* Read the hexadecimal value(2). */
str[1] = message[i];
/* Convert the first byte to the binary value. */
if (str[0] > 64 && str[0] < 71)
str[0] = str[0] - 55;
else
str[0] = str[0] - 48;
/* Convert the second byte to the binary value. */
if (str[1] > 64 && str[1] < 71)
str[1] = str[1] - 55;
else
str[1] = str[1] - 48;
/* Convert the hex value to binary (first & second byte). */
value = str[0] * 16 + str[1];
/* Write the binary data to the binary file. */
fprintf(file_handle,"%c",value);
i++;
/* Output the string followed by a newline. */
/* fwrite(message,len,1,file_handle); */
/* Close the file. */
fclose(file_handle);
3. Use the make.bat available in the c:\orant\rdbms80\extproc directory. You
need to run vcvars32.bat file before running this batch file. This will
create a dll file.
4. Configure the tnsnames.ora and the listener.ora files.
The tnsnames.ora should contain the following entries.
extproc_connection_data.world =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = IPC)
(KEY = ORCL)
(CONNECT_DATA = (SID = extproc)
The listener.ora should contain the following entries.
# P:\ORANT\NET80\ADMIN\LISTENER.ORA Configuration File:p:\orant\net80\admin\listener.ora
# Generated by Oracle Net8 Assistant
LISTENER8 =
(ADDRESS = (PROTOCOL = TCP)(HOST = winnt_nsc)(PORT = 1521))
SID_LIST_LISTENER8=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = winnt_nsc)
(SID_NAME = ORCL)
(SID_DESC =
(SID_NAME = extproc)
(PROGRAM = extproc)
5. Login from sqlplus and issue the following statements.
create library externProcedures as 'C:\orant\RDBMS80\EXTPROC\extern.dll';
Create or replace PROCEDURE OutputString(
p_Path IN VARCHAR2,
p_Message IN VARCHAR2,
p_mode in VARCHAR2,
p_NumLines IN BINARY_INTEGER) AS EXTERNAL
LIBRARY externProcedures
NAME "OutputString"
With context
PARAMETERS (CONTEXT,
p_Path STRING,
p_path INDICATOR,
p_Message STRING,
p_message INDICATOR,
p_mode STRING,
p_mode INDICATOR,
p_NumLines INT,
p_numlines INDICATOR);
This is the pl/sql block used to write the contents of the BLOB into a file.
Set serveroutput on before running it.
SQL> desc lob_tab;
Name Null? Type
C1 NUMBER
C2 BLOB
lob_tab is the table which contains the blob data.
declare
i1 blob;
len number;
my_vr raw(10000);
i2 number;
i3 number := 10000;
begin
-- get the blob locator
SELECT c2 INTO i1 FROM lob_tab WHERE c1 = 2;
-- find the length of the blob column
len := DBMS_LOB.GETLENGTH(i1);
dbms_output.put_line('Length of the Column : ' || to_char(len));
-- Read 10000 bytes at a time
i2 := 1;
if len < 10000 then
-- If the col length is < 10000
DBMS_LOB.READ(i1,len,i2,my_vr);
outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'wb',2*len);
-- You have to convert the data to rawtohex format. Directly sending the buffer
-- data will not work
-- That is the reason why we are sending the length as the double the size of the data read
dbms_output.put_line('Read ' || to_char(len) || 'Bytes');
else
-- If the col length is > 10000
DBMS_LOB.READ(i1,i3,i2,my_vr);
outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'wb',2*i3);
dbms_output.put_line('Read ' || to_char(i3) || ' Bytes ');
end if;
i2 := i2 + 10000;
while (i2 < len ) loop
-- loop till entire data is fetched
DBMS_LOB.READ(i1,i3,i2,my_vr);
dbms_output.put_line('Read ' || to_char(i3+i2-1) || ' Bytes ');
outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'ab',2*i3);
i2 := i2 + 10000 ;
end loop;
end; -
Insert multiple rows into a same table from a single record
Hi All,
I need to insert multiple rows into a same table from a single record. Here is what I am trying to do and I need your expertise. I am using Oracle 11g
DataFile
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
The data needs to be loaded as
Field1 Field2
1 1001
1 2001
1 3001
1 4001
2 1002
2 2002
2 3002
2 4002
ThanksYou could use SQL*Loader to load the data into a staging table with a varray column, then use a SQL insert statement to distribute it to the destination table, as demonstrated below.
SCOTT@orcl> host type test.dat
1,"1001,2001,3001,4001"
2,"1002,2002,3002,4002"
SCOTT@orcl> host type test.ctl
load data
infile test.dat
into table staging
fields terminated by ','
( field1
, numbers varray enclosed by '"' and '"' (x))
SCOTT@orcl> create table staging
2 (field1 number,
3 numbers sys.odcinumberlist)
4 /
Table created.
SCOTT@orcl> host sqlldr scott/tiger control=test.ctl log=test.log
SQL*Loader: Release 11.2.0.1.0 - Production on Wed Dec 18 21:48:09 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 2
SCOTT@orcl> column numbers format a60
SCOTT@orcl> select * from staging
2 /
FIELD1 NUMBERS
1 ODCINUMBERLIST(1001, 2001, 3001, 4001)
2 ODCINUMBERLIST(1002, 2002, 3002, 4002)
2 rows selected.
SCOTT@orcl> create table destination
2 (field1 number,
3 field2 number)
4 /
Table created.
SCOTT@orcl> insert into destination
2 select s.field1, t.column_value
3 from staging s, table (s.numbers) t
4 /
8 rows created.
SCOTT@orcl> select * from destination
2 /
FIELD1 FIELD2
1 1001
1 2001
1 3001
1 4001
2 1002
2 2002
2 3002
2 4002
8 rows selected.
Maybe you are looking for
-
I do not know how to use i dvd to burn a disk
I would like to make a copy of some of my dvd movies that I have and I do not know where to start. How do I import the movie to the computer and then burn it to a new disk? Thanks for any help I can get. I am new to mac and it has been a rough change
-
Why am I getting flooded with calls from a deactivated verizon wireless number?
Im not a verizon customer, but after spending several hours on the phone with their customer support to no avail, Im turning to the community for help. The past two days Ive been flooded with calls from verizon wireless numbers in MO (mostly 636 area
-
Crystal Reports Error, Developer Edition, XI R2
Post Author: squiggly12 CA Forum: Deployment I have a non embedded report sitting on a network server, and I have a program that when a menu link is clicked, it calls a .net dll which then popluates a .net 2.0 dataset, then crystal will load that tab
-
Having a problem with Nokia 5800 XM and connections in McDonalds . Could someone walk me through the normal connection please . I have tried withHandy Wi but still get stuck and am not getting to the Clouds log in page to set up user name etc . jje
-
I can highlight an entire album, I can rename the album, but iTunes will not show new name on the list. When I select a song, iTunes tells me it cannot locate the tune. I believe I have over 50 albums and over 700 songs where this is a problem. I hav