Inserting 000 into a column
i have to insert three zeros into a column.
if i do it only one zero is getting inserted.
please advice.
cheers,
AJ
Hi,
I assume that you have the datatype for the column as number. It is not a wise idea to store the number in varchar2 format. Having said that, if you have the column as number, you can very well mask it to any format you would like it (based on many requirement like, currency format etc).
To answer your question here, if it is the number format, then you can use the to_char function with a formatter to get the desired format.
SQL> select to_char(0,'0000') from dual;
TO_CH
0000
SQL> select to_char(0,'0,000') from dual;
TO_CHA
0,000
SQL> select to_char(0,'0.000') from dual;
TO_CHA
0.000-Arun
Similar Messages
-
How to insert data into BLOB column using sql
Hi all,
How to insert data into BLOB column directly using sql .
create table temp
a blob,
b clob);
SQL> /
Insert into temp values ('32aasdasdsdasdasd4e32','adsfbsdkjf') ;
ERROR at line 1:
ORA-01465: invalid hex number
Please help in this.Thanks,
P Prakashsee this
How to store PDF file in BLOB column without using indirect datastore -
Inserting data into a column from 2 different tables
Hi,
I need to insert data into a table using 2 other tables. The tables that contain data have identical column names.
Is using a UNION statement the only option?
Also, if I need to insert data into columns from only one of the either tables, how do i do it?
Thanks.For future reference, "doesn't seem to work" is a rather generic description... Posting the particular error message will be quite helpful, though I'm reasonably confident that I know the particular problem here.
First, if only for sanity, you probably want to explicitly list the columns of the destination table in your INSERT statement.
Second, it doesn't make sense to have DISTINCT clauses in queries that are UNION-ed together. A UNION has to do a sort to remove duplicates already.
Third, the two queries you are UNIONing together have to return the same number of columns, with the same names, in the same order.
You probably want something like
INSERT INTO new_table( col1, col2, col3, col4, col5 )
SELECT 'ABC' col1,
a.colA col2,
a.colB col3,
a.colC col4
a.colD col5
FROM table1 a
UNION
SELECT 'ABC' col1,
b.colA col2,
b.colB col3,
b.colC col4
NULL col5
FROM table2 bJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
How to insert document into xmltype column through an http post request with perl
Oracle 11.2.0.3
Windows server 2008r2
Apache tomcat 7.0
Oracle APEX 4.2.1
Oracle APEX Listener 2.0
I would like to insert a XML document into the database through an APEX restful web service. The POST into the web service in done with PERL. The following code will insert an empty record in a table with column of XMLType type.
Perl Code
use strict;
use warnings;
use LWP::UserAgent;
use HTTP:Headers;
my $headers = HTTP::Headers->new();
my $url = "http://host:port:apex/<application_workspace>/<restfull service module>/<uri template>/
my $sendthis = ('<?xml version="1.0" enconding="utf-8"?>
<students>
<row>
<name>Mark</name>
<age>30</age>
</row>
<./students>';)
$headers -> header('Content-Type' => 'text/xml; charset=utf-8');
my $request = HTTP:Request->new('POST', $url, $headers, $sendthis);
$request-> protocol('HTTP/1.1');
my $browser = LWP::UserAgent->new();
my $response = $browser->request($request);
my $gotthis= $response->content();
my $the_file_data = $response->content();
APEX restful service
Method: POST
Source type: PL/SQL
MIME Types allowed: blank
require secure access: none
source:
{declare
doc varchar2(32000);
begin
insert into table <column name>
values(doc);
commit;
end;
Table code
{ create table <tablename>
(column name XMLType>);
The above code will insert an empty column into the table.
Any ideas why?It's a really bad idea to assemble XML using strings and string concatenation in SQL or PL/SQL. First there is a 4K limit in SQL, and 32K limit in PL/SQL, which means you end up constructing the XML in chunks, adding uneccessary complications. 2nd you cannot confirm the XML is valid or well formed using external tools.
IMHO it makes much more sense to keep the XML content seperated from the SQL / PL/SQL code
When the XML can be stored a File System accessable from the database, The files can be loaded into the database using mechansims like BFILE.
In cases where the XML must be staged on a remote file system, the files can be loaded into the database using FTP or HTTP and in cases where this is not an option, SQLLDR.
-Mark -
How to insert signals into multiple columns in db, dbtoolset
I have a labVIEW program that is currenly simulating voltage and a current signal using the DAQ Assistant. I'm using the database connectivity toolset. I am currently able to insert one signal into the database converted to a float(I can insert both into the same column as bianary but it needs to be stored as a usable format and in seperate columns.)
The problem I am having is at the DB Tools Insert Data block. I have the connection, dbTable, error code, and create table boolean being passed into it. Where I am a little lost is how to set the columns I want to store the multiple signals into.
If someone could break that part down for me that would be great. In short, I want to store voltage(channel0) and current(channel1) from the DAQ Assistant into their own respective columns in the db.As I have often pointed out, the easiest solution to this situation is to dump the Database Connectivity Toolkit. Check out this thread and follow the references in it. If the DCT weren't in the way what you are wanting to do would be very easy.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
Insert data into the column which is having null values.
Hi,
I have a column called "Classification_CD" .This column is having NULL values.I want to insert the data into this column.
I tried to write the query as follows. But it is showing the mesg error "SQL Error: ORA-01400 cannot insert NULL into ("ABC"."A_CMP_W"."A_CMP_SEQ_NUM")"
Can any one please help me out to write query to insert the dat afor this.
Thanks.I think you are taking about updating the null value.So you can do this..
SQL> select * from table_a;
ID SCHEDULED MARK PRID
5 07-NOV-10 T05 7
6 18-SEP-10 T06 8
4 31-JAN-11 T02 2
1 18-JAN-11 T01 2
2 18-JAN-11 T02
3 18-JAN-11 T03 1
6 rows selected.See that prid is Null for id 2
SQL> update table_a
2 set prid =10
3 where id =2;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from table_a;
ID SCHEDULED MARK PRID
5 07-NOV-10 T05 7
6 18-SEP-10 T06 8
4 31-JAN-11 T02 2
1 18-JAN-11 T01 2
2 18-JAN-11 T02 10
3 18-JAN-11 T03 1
6 rows selected.
SQL> But remember while updating u should choose a primary key column in
where condition so that only desired row or record is updated..
Regards
Umesh -
Hello all,
I'm pulling my hair out--thank you for any help you can give
me.
I have a form that a person fills out that has a field that
asks "How
many visitors including you" and I'd like them to type in a
number, and
on submit of the form, have that value -2 multiplied by 20
and inserted
into a "total cost" column.
I'm using the standard DW server behaviors and I've searched
the
internet. How do I perform basic math on that value and
insert it into
the database?
If you have any pointers, that would be great.
Thank you!
-JohnJohn R. Lenz wrote:
> Your code below works great, and I just noticed links to
your book were
> available on your web site, and it's in the mail to me.
Looking forward
> to it.
Thanks, hope you find it useful.
> After the form is posted, I'd like to address the person
who posted it
> by their first name and last name, as well as some of
the details. How
> would you go about doing this in the best way? Would you
set a variable
> and echo it on the 'Thank you' page, or are there better
ways of doing
> it with a recordset and filtering it on form submit?
To pass the details to a thank you page, you would need to
store the
information in $_SESSION variables. You could amend the
earlier script
like this:
<?php
session_start();
if (isset($_POST['visitors'])) {
if ($_POST['visitors'] < 3) {
$num = 0;
} else {
$num = $_POST['visitors'] - 2;
$_POST['total_cost'] = $num * 20;
$_SESSION['total_cost'] = $_POST['total_cost'];
$_SESSION['first_name'] = $_POST['first_name'];
$_SESSION['last_name'] = $_POST['last_name'];
?>
In the thank you page, put the following at the top of the
page:
<?php session_start(); ?>
It must go before anything is output to the browser, so put
it above the
DOCTYPE declaration, and make sure there's no space before
it.
You can then use the $_SESSION variables in the thank you
page.
At the end of the page, add this to clear up the session
variables:
<?php
$_SESSION = array();
destroy_session();
?>
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
Inserting files into lob columns stored procedure
i have created a stored procedure that inserts file into the database as a lob object. the source code converts the file into a byte [] stream (c#) and assigns to the parameter . please check the pl/sql stored procdure. is there a way to debug pl/sql code in vs 2005.
PROCEDURE "STARDOC"."INSERTFILE" (
"TITLE" IN VARCHAR2,
"AUTHOR" IN VARCHAR2,
"DESCRIPTION" IN VARCHAR2,
"PUBLISHER" IN VARCHAR2,
"LANGUAGE_ID" IN NUMBER,
"CONTENT" IN BLOB DEFAULT empty_blob(),
"FILENAME" IN VARCHAR2,
"EXTENSION" IN VARCHAR2,
"APPID" IN NUMBER,
"DOC_SIZE" IN NUMBER,
"CONTENT_TYPE_ID" IN NUMBER,
"IDENTIFIER" IN VARCHAR2,
"DOC_ID" OUT NUMBER) IS
docid number;
BEGIN -- executable part starts here
SELECT seq_document_id.NEXTVAL INTO docid FROM dual;
--Documents table
INSERT INTO DOCUMENTS(document_id, content, filename,
extension, retrieval_metadata_id,
content_metadata_id,description)
VALUES (docid,content,filename,extension,docid,docid,description);
--Content Metadata table
INSERT INTO CONTENT_METADATA(content_metadata_id, document_id,
author, title, description,
publisher, language_id, content_type_id)
VALUES (docid, docid, author,
title, description, publisher,
language_id, content_type_id);
--retrieval metadata table
INSERT INTO RETRIEVAL_METADATA(retrieval_metadata_id, identifier)
VALUES (docid,identifier);
--Storage metadata table
INSERT INTO STORAGE_METADATA(storage_metadata_id, application_id,doc_size)
VALUES (docid,appid, doc_size);
EXCEPTION
--rollback when an expetion occurs
WHEN OTHERS THEN
ROLLBACK;
END "INSERTFILE";Yes.
Are you experiencing any issues? From your posts above there is no mention of any issues you are facing that could ba attributed to the LOB size.
Has the procedure been run at least once? -
Insert value into a column based on value of another column
Hi,
I am trying to insert a value into a record based on a column in
the record, using a trigger. The complication arises because
the new value is selected from the same table. For example:
SELECT COL1, COL2, COL3, COL4 from TABLE1
I want to set COL2 and COL3 based on the value of COL4. And to
get the value of COL2 and COL3, I will go back to TABLE1 and set
the condition to TABLE1.COL1 = :NEW.COL4
I cannot seem to execute the trigger as I get the message "ORA-
04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
see it" everytime.
Is this the correct way to achieve what I wanted? Or is there
another way?
Appreciate your feedback. Thank you in advance.Hi,
I am trying to insert a value into a record based on a column in
the record, using a trigger. The complication arises because
the new value is selected from the same table. For example:
SELECT COL1, COL2, COL3, COL4 from TABLE1
I want to set COL2 and COL3 based on the value of COL4. And to
get the value of COL2 and COL3, I will go back to TABLE1 and set
the condition to TABLE1.COL1 = :NEW.COL4
I cannot seem to execute the trigger as I get the message "ORA-
04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
see it" everytime.
Is this the correct way to achieve what I wanted? Or is there
another way?
Appreciate your feedback. Thank you in advance. I'm not sure what you mean when you insert a value into a
record, but if you are setting a value in a column of the same
record using a trigger, then it's easy.
:new.COL2 := ....:new.COL4...
:new.COL3 := ....:new.COL4...
The trigger must be 'INSERT or UPDATE' and 'FOR EACH RECORD'.
If you are setting a different record in the same table, the
solution is much more difficult. -
Can't insert data into NVARCHAR2 column
I have a Oracle 8.1.7 database with character set WE8ISO8859P15 and the same for the national character set. I created a table with one column of the VARCHAR2 type and everything worked fine. But when I change the column type to NVARCHAR2 I get various errors: ORA-12704 (when using JDBC), ORA-00911 (when trying to insert euro symbol using Oracle DBA Studio), ORA-00984 (when trying to insert 'abc' using Oracle DBA Studio). Can anyone tell me what is causing these errors??
i used oracle dba studio to create the table. it's just one column named CONTENT of type NVARCHAR2 (256).
this is what i did with SQL plus:
SQL> insert into test2 values ('test');
insert into test2 values ('test')
ERROR at line 1:
ORA-12704: character set mismatch
SQL> insert into test2 values (to_nchar('test'));
insert into test2 values (to_nchar('test'))
ERROR at line 1:
ORA-00904: invalid column name
SQL> insert into test2 (content) values ('test');
insert into test2 (content) values ('test')
ERROR at line 1:
ORA-12704: character set mismatch
SQL> insert into test2 (content) values (to_nchar('test'));
insert into test2 (content) values (to_nchar('test'))
ERROR at line 1:
ORA-00904: invalid column name -
Inserting date into database column automatically
This may be a silly question. But how to add a date(system date) in to the database column automatically when a user submit a form.???
thanks
sanHi,
Use default values?
SQL>create table t
2 (
3 a number,
4 constraint def_val_b b date default sysdate
5 );
Table created.
SQL>insert into t (a) values (1);
1 row created.
SQL>select * from t;
A B
1 22/11/05
1 row selected.Regards,
Yoann. -
May I take photo, insert into a spreadsheet, input info in several other columns; review and/or print; and download onto my laptop later?
You can play with the 'route' command in an Applications -> Utilities -> Terminal session to specify which route a specific IP address should take.
man 8 route
Google can most likely give you examples you can use to specify routes.
Routes must be setup after each reboot. -
Insert string into date column
I'm writing a bash script that is supposed to insert a series of strings into a table. Problem is I may not know which column the date is in, so I don't want to hard code a to_date function in there.
For instance this row may come in to be inserted:
"06-APR-10 08:51:12","data","data","data","data","data","data","data","data"
Assuming the data is in the proper order, I'm just going to sub out the "," for ',' which will let me insert everything just fine, except obviously it borks on the date.
How do I insert the date this way as a string using the default internal call to to_date?? I know I can do it with '06-APR-10' and it works, but I need to get a little more specific with hour minute and second.user12947249 wrote:
I'm writing a bash script that is supposed to insert a series of strings into a table. Problem is I may not know which column the date is in, so I don't want to hard code a to_date function in there.If you don't know which string maps to which column, how do you expect to have any data reliability? Even if you manage to load the data without error, how can an application make any sense of it?
I'm curious because if you have a method to map the columns, that could be used to help you (maybe) and if you don't have a method ... then i don't see this post as being your number one problem :) -
How To Insert Cells Into One Column Only
Can anyone advise me, how to insert a cell (or multiple cells) into +just one column+ whilst leaving everything else on the sheet exactly as it is?
I'm migrating from Excel and can't find this functionality in Numbers
Thanks in advance for any helpThank you for taking the time to reply, thereby removing the misery of me continuing to search for this absent function!
I really wanted to like the iWork apps! I recently rebuilt one of my rigs and had the intention of making it a Microsoft-free computer - hence the purchase of iWork.
However, the last few days of 'learning curve' I have stumbled upon an increasing number of incompatibilities and limitations when compared to Excel, and the lack of the function to insert a single cell into a sheet is the final deal-breaker for me, sadly.
So, reluctantly, I am going to install my Microsoft Office 2008 suite and get back to where I was before. I will continue to look at the iWork apps but I suspect they'll fall to the wayside.
Once again, many thanks for confirming what I was reluctantly concluding. -
How to insert fragment into xml column generated from query
I'm trying to generate xml from some relational data and then insert a sub node into an xml column. Here's some sample code that obviously doesn't work. I'm trying to figure out the syntax where the ???? exist.
/* create test tables*/
DECLARE @person TABLE
id int NOT NULL PRIMARY KEY CLUSTERED,
info xml NULL
DECLARE @roles TABLE
id int NOT NULL,
role_name varchar(20) NOT NULL,
PRIMARY KEY
id,
role_name
/* insert test values */
INSERT INTO @person (id, info)
VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
(2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
INSERT INTO @roles (id, role_name)
VALUES
(1,'Admin'),
(1,'User'),
(2,'Editor'),
(2,'User');
/* make sure that xml comes back correctly*/
SELECT
role_name AS name
FROM @roles AS role
WHERE id = 1 -- works for each id
FOR XML AUTO, ROOT ('roles');
UPDATE p
SET info.modify('insert ???? as last into (/person)[1]')
FROM @person p
INNER JOIN @roles r
ON p.id = r.id
/* desired output in the info column for id = 1*/
<person>
<name>
<first_name>Joe</first_name>
<last_name>Smith</last_name>
</name>
<roles>
<role name="Admin" />
<role name="User" />
</roles>
</person>
Any ideas?this?
DECLARE @person TABLE
id int NOT NULL PRIMARY KEY CLUSTERED,
info xml NULL
DECLARE @roles TABLE
id int NOT NULL,
role_name varchar(20) NOT NULL,
PRIMARY KEY
id,
role_name
/* insert test values */
INSERT INTO @person (id, info)
VALUES (1, '<person><name><first_name>Joe</first_name><last_name>Smith</last_name></name></person>'),
(2, '<person><name><first_name>Tim</first_name><last_name>Jones</last_name></name></person>');
INSERT INTO @roles (id, role_name)
VALUES
(1,'Admin'),
(1,'User'),
(2,'Editor'),
(2,'User');
/* make sure that xml comes back correctly*/
SELECT
role_name AS name
FROM @roles AS role
WHERE id = 1 -- works for each id
FOR XML AUTO, ROOT ('roles');
UPDATE p
SET info.modify('insert sql:column("x") as last into (/person)[1]')
FROM @person p
CROSS APPLY(SELECT role_name FROM @roles WHERE id = p.id FOR XML PATH(''),ROOT('roles'),TYPE)r(x)
select * from @person
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page
Maybe you are looking for
-
Boa tarde. Estamos com o seguinte problema. Na elaboração de uma proposta na F110 de 5 documentos de uma mesmo fornecedor todos com somente 1 parcela, apresentou o seguinte erro : LOG DE EXECUÇÃO Erro interno: saldo-doc não é zero / empresa BR11 forn
-
I have a Mac OS 10.4.11. I had a glitch while I was trying to register to a new WordPress and that site sent me to Firefox and told me to download. Before checking compatibility with my operating system, I download and put it in my applications folde
-
Source and target directory file name should be same
Hi, How can i generate the same file name in target directory without date and Timestamp. for eg., Source File name : yeswanth.txt and target File name also : yeswanth.txt Note : here source side the file yeswanth.txt is constant and whenever it move
-
Hi , i'm having a little problem with list types (As the title may suggest :)) , ihave class X which implements Interface Y , now i have a function that recieves a list of type X List<X> listX and another fucntion that recieves a List<Y> , i can't se
-
Does Business Objects XI still support RDC for Crystal Reports?
Post Author: DLO34 CA Forum: Integrated Solutions My company develops an application which uses Crystal Reports to present data to the user. We have been using the RDC API through our internal C code for a while now. From the documentation I have fou