Storing WAVE file into database from sql plus.
dear all
I have create a table with two attributes,sl_no number and song long raw type.
what will be the insert command to insert a .wav file into the database.if not then you can give me some alternate solution also.
thanks.
You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
The documentation can be found on technet at
urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
[\url]
An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
Good Luck,
Eric Kamradt
Similar Messages
-
Storing image files (.gif) into database from sql plus
dear all
I have to store image files into a table with BLOB attribute.
What will be the insert command to insert a .gif file into the database.
thanks.You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
The documentation can be found on technet at
urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
[\url]
An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
Good Luck,
Eric Kamradt -
How to pass table type variable into function from SQL*PLUS ?
How to pass a table type variable from sql*plus prompt into a function ?
Thanx in advance.Krishna,
Do you mean like this?SQL> DECLARE
2 TYPE t_tbl IS TABLE OF VARCHAR2(20);
3 l_sample_tbl t_tbl;
4
5 FUNCTION print_contents ( p_tbl IN t_tbl )
6 RETURN VARCHAR2
7 IS
8 l_string VARCHAR2(1000);
9 BEGIN
10 FOR i IN 1..p_tbl.COUNT LOOP
11 IF (i = 1) THEN
12 l_string := p_tbl(i);
13 ELSE
14 l_string := l_string || ', ' || p_tbl(i);
15 END IF;
16 END LOOP;
17 RETURN (l_string);
18 END print_contents;
19
20 BEGIN
21 l_sample_tbl := t_tbl();
22 l_sample_tbl.EXTEND;
23 l_sample_tbl(1) := 'one';
24 l_sample_tbl.EXTEND;
25 l_sample_tbl(2) := 'two';
26 l_sample_tbl.EXTEND;
27 l_sample_tbl(3) := 'three';
28 l_sample_tbl.EXTEND;
29 l_sample_tbl(4) := 'four';
30 l_sample_tbl.EXTEND;
31 l_sample_tbl(5) := 'five';
32 DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
33 END;
34 /
one, two, three, four, five
PL/SQL procedure successfully completed.
SQL> HTH,
T. -
Able to connect to database from SQL plus but not from Oracle SQL developer
Hi
I have two database editions in my system Oracle XE and Oracle EE. I am able to connect to EE database through SQL plus but not through SQL developer.Please tell me how to do it.
All settings are good.I am able to connect to the database before installing XE.I need both for my work(different projects).
And the default listener started is XE's.Please tell me how to change the default one to EE or tell me how to connect through SQL developer??
Regards
HarshaI Solved it.
I copied the text from listener.ora for EE
and added it in the other one.
It works after restart. -
Save .wav file into database through script
Hi,
I want to store a .wav file into a database through script. Is that possible to do it through the ccx script?
Thanks,
HowYeeHi,
At this moment, script can save the file only to Custom directory of UCCX. It's not possible to save it to external DB.
Regards
GP. -
How can i load file into database from client-side to server-side
i want to upload file from client-side to server-side, i use the following code to load blob into database.
if the file is in the server-side, it can work, but if it in the client-side, it said that the system cannot find the file. i think it only will search the file is in the server-side or not, it will not search the client-side.
how can i solve it without upload the file to the server first, then load it into database??
try
ResultSet rset = null;
PreparedStatement pstmt =
conn.prepareStatement ("insert into docs values (? , EMPTY_BLOB())");
pstmt.setInt (1, docId);
pstmt.execute ();
// Open the destination blob:
pstmt.setInt (1, docId);
rset = pstmt.executeQuery (
"SELECT content FROM docs WHERE id = ? FOR UPDATE");
BLOB dest_lob = null;
if (rset.next()) {
dest_lob = ((OracleResultSet)rset).getBLOB (1);
// Declare a file handler for the input file
File binaryFile = new File (fileName);
FileInputStream istream = new FileInputStream (binaryFile);
// Create an OutputStram object to write the BLOB as a stream
OutputStream ostream = dest_lob.getBinaryOutputStream();
// Create a tempory buffer
byte[] buffer = new byte[1024];
int length = 0;
// Use the read() method to read the file to the byte
// array buffer, then use the write() method to write it to
// the BLOB.
while ((length = istream.read(buffer)) != -1)
ostream.write(buffer, 0, length);
pstmt.close();
// Close all streams and file handles:
istream.close();
ostream.flush();
ostream.close();
//dest_lob.close();
// Commit the transaction:
conn.commit();
conn.close();
} catch (SQLException e) {Hi,
Without some more details of the configuration, its difficult to know
what's happening here. For example, what do you mean by client side
and server side, and where are you running the upload Java application?
If you always run the application on the database server system, but can't
open the file on a different machine, then it sounds like a file protection
problem that isn't really connected with the database at all. That is to
say, if the new FileInputStream (binaryFile) statement fails, then its not
really a database problem, but a file protection issue. On the other hand,
I can't explain what's happening if you run the program on the same machine
as the document file (client machine), but you can't write the data to the
server, assuming the JDBC connection string is set correctly to connect to
the appropriate database server.
If you can provide some more information, we'll try to help.
Simon
null -
Storing a Blob into MySql from a JTextArea
I'm using Java 1.4.1, MySql 4.0.12, and MyConnector/J 3.06
I have an application with a JTextArea and I want to put the contents of the JTextArea into the database stored as a Blob Object. The only reason I'm using Blob is because varchar is limited in lenght by 255 characters.
The problem I am having is actually creating the Blob Object. I get a null pointer exception no matter what I do.(Even when there is text in the JTextArea) Please take a look at my code and please help me out if you can.
I'm not sure if I'm using the java Blob correctly as it cannot be instantiated and it's an interface not a class.
Please give me any suggestions including if there is a better way to doing this without using a Blob object. Thanks in advance.
// create a new Blob Object, must initialize to something
Blob tempBlob = null;
// viewOrdData.notes is the JTextArea
if (viewOrdData.notes.getText().length() > 0) {
// THIS IS THE LINE WHERE I GET THE NULL POINTER EXCEPTION
// I tried initial position both 0 and 1
tempBlob.setBytes(0,viewOrdData.notes.getText().getBytes())
stmt.executeUpdate(
"UPDATE WORKORDER "+
"SET NOTES = "+tempBlob+" "+ // NOTES is of type Blob
"WHERE WRKID = "+viewOrdData.workOrderID); // primary keyNow, Storing a Blob into Database from a JTextArea or any text components becomes easy with the SerialBlob class( javax.sql.rowset.serial.SerialBlob - JDK 1.5).
For eg..
For Storing a Blob to Database
pstmt.setBlob(1,new SerialBlob(jtextArea.getText().getBytes()));For Retrieving a Blob to JTextArea
SerialBlob sblob = new SerialBlob(rs.getBlob("FieldName"));
jTextArea.setText(new String(sblob.getBytes(1, (int)sblob.length())));Hope this serves this problem well.
Regards,
R.Amirdha Gopal. -
Seek help to format spool file from SQL*PLUS
I am running a Unix shell script to call a Oracle 11g SQL script from a Oracle database. In this SQL script, I need to connect to many different remote databases to select data, then sool these records as one big text file to a directory. Then email the file to related Group users. In the spool file, there is a line on the top of each page like this:
DUMMY
DB_NAME
I know this is caused by connect to remote database in SQL*PLUS. My connection string is like this:
Conn system/password@Oracle_SID
How can I remove these lines or how to skip these lines into spool file? Please advise. Thanks in advnce. Wish all of you Happy New Year!!!Hi,
It sounds like you have some kind of formatting (such as SQL*Plus TTITLE) producing the output you don't want. If that's the case, temporarily stopping the spooling might not help you. Find out what is causing the output that you don't want. You say that you know it is caused by the CONNECT statements, but it must be more than that. I've written scripts with CONNECT statements that don't have anything like what you reported at the top of each page; in fact, they don't even have pages: the output is one continuous stream. Find out what's putting the unwanted output there, and that will be a big clue as to how you can stop it.
You say that you know the unwanted titles are there because of the CONNECT statements. If so, use database links instead of CONNECT. You don't have to use dbms_scheduler or utl_file; just eliminate the CONNECT statements. (I'm not saying that there's anything wrong with dbms_scheduler or utl_file; you should definitely investigate those tools. I'm just saying that using database links is independent of them.)
What would happen if you did all your connecting to different databases at the OS level? Can you write a shell script that connects to each database in turn, and runs a SQL*Plus script in each one. Each SQL*Plus script would have a SPOOL or SPOOL ... APPEND command, or maybe you could build the SPOOL into a LOGIN.SQL script. -
How to view a stored procedure from sql plus
Can anyone please tell what is the command for viewing the content of the stored procedure from sql plus ?
ThanksHi,
I use this simple script to retrieve.......
EDTRAD@T_E_S_9-->l
1 select text from all_source where name = 'GET_MAN' -- proc name here
2* order by line asc
EDTRAD@T_E_S_9-->/
TEXT
FUNCTION get_man (in_man SSBOSS.CLNTWORK.manager%type)
RETURN varchar2 IS
CURSOR get_man(in_man SSBOSS.CLNTWORK.manager%type) IS
SELECT name
FROM ssboss.clntwork
WHERE agency = 'TM'
AND manager = in_man
AND manager is not null
AND manager != '**OB**';
v_man SSBOSS.CLNTWORK.name%type := null;
BEGIN
OPEN get_man(in_man);
FETCH get_man INTO v_man;
IF get_man%notfound THEN
v_man := 'Manager Not Found !';
RETURN (v_man);
CLOSE get_man;
END IF;
RETURN (v_man);
CLOSE get_man;
END;
21 rows selected.
EDTRAD@T_E_S_9--> -
Calling stored proc (with 2 IN and 3 OUT) - from SQL Plus
This is the signature of my stored proc:
CREATE OR REPLACE PROCEDURE myschema.myproc
p_usr_name IN VARCHAR2,
p_send_tmstmp IN DATE,
p_ret_value OUT NUMBER,
p_err_code OUT VARCHAR2
)If I need to call it from sql plus, how do I need to pass the arg?
This is what I am doing
execute myschema.myproc('abc123','02-MAY-2008');
What is wrong here? If someone could help. Thx!Try something like this
var usr_name varchar2(30)
var send_tmstmp varchar2(11)
var ret_value number
var err_code varchar2(10)
begin
:usr_name := 'abc123';
:usr_name := '02-MAY-2008';
myschema.myproc ( p_usr_name => :usr_name,
p_send_tmstmp => TO_DATE( :usr_name, 'DD-MON-YYYY' ),
p_ret_value => :ret_value,
p_err_code => :err_code);
end;
print ret_value;
print err_code; -
How to create database from .sql file
how to create database from .sql file..?? i put the sintax query in a sql file.. and i want to call it in java code..
ho to do it..??why do you want to do this from java?
i just don't see the point.
find your dba and have him/her run it for you -
How execute this stored procedure from SQL PLUS???
Hello folks....
Help me please...
I have this procedure....
CREATE OR REPLACE PROCEDURE TEST(COD OUT VARCHAR2, NUM OUT
VARCHAR2, ID OUT VARCHAR2)
AS
BEGIN
END;
SO, I4D LIKE TO EXECUTE IT FROM SQL PLUS::
BUT, I DONT KNOW HOW TO DO..PLEASE SEND ME A SAMPLE..
THANK UThank u man!!!
look, my error before was :
SQL> set serveroutput on
SQL> declare
SQL> cod varchar2(100);
SQL> num varchar2(100);
SQL> id varchar2(100);
SQL> begin
SQL> TEST( cod, num, id );
SQL> EXEC DBMS_OUTPUT.put_line( cod || ' ' || num || ' ' ||
id );
SQL> end;
SQL> /
i put the EXEC....
thank u!!! -
Importing Database from SQL Server into Oracle 8i
Hello Friends,
Cuurentlly we are using SQL Server as our application database, Now we want to switch on at Oracle 8i,bcz of some problems,
If anybody had done so,then please help me in solving this problem,
I wana Import whole database from SQL server to Oracle
Lot of thanksHi,
Use the SQL Server Enterprise Manager to export all the tables from SQL to oralce.
When selecting the target database use the Oracle native driver (the name is not on top of my head) and not the ODBC one.
You will have problems with datatypes. Make sure to edit the mappings for the proper datatype if required.
If you have ntext columns, make sure they are translated to CLOB and not long.
Regards,
Wasim. -
How to read a whole text file into a pl/sql variable?
Hi, I need to read an entire text file--which actually contains an email message extracted from a content management system-- into a variable in a pl/sql package, so I can insert some information from the database and then send the email. I want to read the whole text file in one shot, not just one line at a time. Shoud I use Utl_File.Get_Raw or is there another more appropriate way to do this?
how to read a whole text file into a pl/sql variable?
your_clob_variable := dbms_xslprocessor.read2clob('YOUR_DIRECTORY','YOUR_FILE');
.... -
Storing PDF file into DB & restoring back to Filesystem
Hi Everybody,
I need to store PDF files into Database (Oracle 8.1.6 on Windows NT). This I could do using DBMS_LOB Package. Now, my problem is bringing back the PDF files to OS filesystem.
I feel my problem will be solved if I have UTL_LOB Package Object in my Database. Where can I get the script or utility that installs the said Object in my Database. Kindly send me the script/utility if anybody has.
Thanks & Regards,
Durai.look,
http://stackoverflow.com/questions/2347842/storing-pdf-files-as-binary-objects-in-sql-server-yes-or-no
Please use Marked as Answer if my post solved your problem and use
Vote As Helpful if a post was useful.
Maybe you are looking for
-
"Macbook Pro 17-inch" OR "15-inch 2.0Ghz + 23-inch display" ?
I'm ready to upgrade my iMac G4 and would like to change to a Macbook Pro. The decision i'm working on making is whether to invest in the 17-inch MBP or go for the 15-inch + 23-inch display. Both options cost about the same. The combination of laptop
-
What is wrong with my iPod.. and how can i fix it?
ok.. my 5G iPod was working fine.. then i couldnt get it to eject from my iBook.. on my computer screen it said that it was ejected.. but i iPod never said ok to disconnect. a few moments later and my iPod was back on my computer screen.. it did this
-
QA32: Stock In Quality But no Inpsection Lot
Greeting.. I have raw maetrial which i recievd against Purchase order , and its showing under qulity stock in stock overview.....But in QA32 i m not getting the Lot for this..no where i m founding the Lot of this material.. How to make th
-
Using invoke nodes to change a control on a server vi
I am trying to pass a parameter to a vi running in parallel with my main vi. I am using invoke nodes to do this without any problems. In server.vi I want to respond to a change in the control using an event structure. I have found that when passing t
-
Hi I have 2 ISE 1.2 I configured ISE1(192.168.1.1) as primary for PAN, MNT and PSN and it work fine Now I am configuring ISE2(192.168.2.1) as secondary PAN, MNT and PSN In normal situation, the user are authenticated on ISE1 My goal : If ISE1 is unav