Insert into Oracle table thru UNIX - linux 2.6.9-89


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert into Oracle table thru UNIX - linux 2.6.9-89
# 1  
Old 03-15-2010
Insert into Oracle table thru UNIX - linux 2.6.9-89

Hi,
I am trying to insert a record into a table (say dips_tbl) which resides in Oracle DB through a ksh script. I want to insert records into few of the table columns-not all. I'll give an e.g. for the date column "CREATE_DATE".

For that I first execute
Code:
SQL1="SELECT SYSDATE FROM DUAL" 
 
sqlplus -s << EOF > ${RESULT_1}
${CONNECT}
set verify off
set feedback off
set echo off
set pagesize 0
set linesize 250
${SQL1};
${SQL2};
exit;
EOF


Then I retrieve the value and store it in a variable:
Code:
TODAY_DATE=`cat RESULT_1 | head -1` (RESULT_1 has other sql command's executed results too)

Construction of the SQL statement for an "insert":
Code:
SQL3="INSERT INTO dips_tbl(COL1,COL2,COL3,CREATE_DATE,COL4,COL5) VALUES(${COL1},${COL2},${COL3},${TODAY_DATE},${COL4},${COL5})"

When I execute SQL3 statement; I get an error in the RESULT_2 as:
Code:
INSERT INTO dips_tbl(COL1,COL2,COL3,CREATE_DATE,COL4,COL5) VALUES(<"some value1">,<some value2>,       <some value3>,"15-MAR-10",<some value4>,<some value5>)
                                                                                                                                      *
ERROR at line 1:
ORA-00984: column not allowed here

I have quoted (" ") all the varchar values. But still it throws the same error. How to resolve the above error? Please help.

-dips

Last edited by pludi; 03-15-2010 at 05:07 AM.. Reason: code tags, please...
# 2  
Old 03-15-2010
for var char, use single quotes instead doubles.
something like,
Code:
'$col1','$col2'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Needed: UNIX shell variables to store Oracle table records

Hello Folks, I'm working on a requirement to automate the process of generating report(csv file) using metadata info stored in an Oracle table and E-mail it to respective people. Meta data table: Report_ID,Report_SUB_ID,Report_DB,Report_SQL,Report_to_email_Id 1,1,DEV,'select * From... (2 Replies)
Discussion started by: venkat_reddy
2 Replies

2. UNIX and Linux Applications

UNIX spool command not extracting complete record from the Oracle table

Hello All, I'm trying to spool an oracle table data into a csv file on unix server but the complete record is not being extracted. The record is almost 1000 characters but only 100 characters are being extracted and rest of the data getting truncated. I'm setting below options : SET... (4 Replies)
Discussion started by: venkat_reddy
4 Replies

3. Shell Programming and Scripting

How to lock Oracle table through UNIX?

Hi frndz, Can anyone provide me some input or pseudo code for my req as mentioned below... I am loading 2 files through unix script into oracle table...as i am doing some updates also i am getting an error where both files try to update the table simultaneously and my script fails.. so i... (3 Replies)
Discussion started by: gnnsprapa
3 Replies

4. Shell Programming and Scripting

Insert script result into Oracle Table

Hi All, I want to insert STAT and ENDTIME values for each job in joblist into TBL_DAILY_STATUS table. Eg: insert into tbl_daily_status values(STAT,ENDTIME); Please help me on this. #!/bin/ksh joblist="com_abc_job com_abc_dot_job com_abc_seq com_abc_det" for i in $joblist do... (8 Replies)
Discussion started by: vichuelaa
8 Replies

5. Shell Programming and Scripting

Delete oracle table from UNIX script

Hi, Is it possible to delete oracle table datas using a UNIX script/Shell script? how can we do this?? I have oracle Database and i have to delete millions of record everyday.. adn it is taking hours togather to execute this. Will the delete query triggered from UNIX be faster can we expect any... (1 Reply)
Discussion started by: Codesearcher
1 Replies

6. Shell Programming and Scripting

select values from db1 table and insert into table of DB2

Hi I am having three oracle databases running in three different machine. their ip address is different. from one of the DB am able to access both the databases.(means am able to select values and insert values in to tables individually.) I need to fetch some data from DB1 table(say DB1 ip is... (2 Replies)
Discussion started by: aemunathan
2 Replies

7. Shell Programming and Scripting

Insert value to ORACLE table from sqlldr log

This is the sample sqlldr log: ------------------------------------------------------------------------------------------------------------ SQL*Loader: Release 9.2.0.7.0 - Production on Sun Feb 8 23:37:02 2009 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. Control... (13 Replies)
Discussion started by: aimy
13 Replies

8. Shell Programming and Scripting

unix file to oracle table

Hi , Can anyone help me regarding loading a unix file data to oracle database table using shell scripts? I wanted to grep only this data from a spool file sql_test.txt 99 00:00:00:01 but if I use grep I am getting format sql_test.txt 99 rows selected. Elapsed:... (2 Replies)
Discussion started by: ran16
2 Replies

9. UNIX for Advanced & Expert Users

unix script for update or insert records from a file to a oracle table

Hi, I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me the commands and also... (1 Reply)
Discussion started by: unihp1
1 Replies

10. Programming

How can i load or insert a table in oracle from c language thru unix environment

I'm having a oracle server and i'm having a table in that. I'm having a linux server which is in network with the oracle server. I need to write a c program in linux env when on execution loads the table with the text file given as input. Please explain me the flow of process in that and also... (6 Replies)
Discussion started by: rramprasad
6 Replies
Login or Register to Ask a Question