Oracle Database: INSERT INTO with TO_DATE function
Hello,
I am writting a procedure in shell script as,
Where DATEGEN is unix string variable which I need to use into INSERT INTO statement.
I am receiving error message as,
How can I assign string variable to date_gen DATE; in procedure?
How can I use this date into INSERT statement?
Could you please help me out in inserting data into table with TO_DATE function.
Please help me out...
Thanks in advance.
....
I am writting a procedure in shell script as,
Where DATEGEN is unix string variable which I need to use into INSERT INTO statement.
I am receiving error message as,
...
Change this line in your script -
to this -
(A)
Quote:
How can I assign string variable to date_gen DATE; in procedure?
Before you understand how you can assign a string to a DATE variable, you need to understand that it's not a good practice to do so. Because you are relying on Oracle's implicit conversion rules by doing so.
So instead of doing that, declare the variable as a string and assign a string to it.
(B)
Quote:
How can I use this date into INSERT statement?
Just stick in the variable in your INSERT statement.
Of course, if you follow (A), then you'll have to convert your variable (which is a string) to a date first.
TO_DATE => converts string to date TO_CHAR => converts date to string
You are using TO_DATE to convert a DATE (the variable date_gen) to a DATE. Again, that's not a good practice.
tyler_durden
Note:
(Oracle actually allows a date to be converted to a date using the TO_DATE function; it's an unintended consequence of implicit conversion.)
Now I am receiving error for $DATEGEN as,
Its not taking value of $DATEGEN.
here is script part,
If i changed the code as,
Here are the values, but its not reflecting in date_gen variable.
Last edited by Poonamol; 10-21-2010 at 03:41 AM..
Reason: code modified
Good evening
I nned your help pls, In an unix server i want to connect to a remote oracle databse server by sqlplus.
I tried to find out the user/passwd and service name by env variable and all Ive got is this:
ORACLE_SID_REPCOL=SCL_REPCOL
ORACLE_SID=xmeta
ORACLE_SID_TOL=SCL_PROTOLCOL... (2 Replies)
Hi guys, I would like to seek help on inserting data whenever the switch is on or off to my sensor mySQL database in phpMyAdmin from my control.php. I'm using Raspberry PI as my hardware and follow a few tutorials to create my own Web Control Interface, it works perfectly without insert method.... (1 Reply)
Hello,
I am trying to execute an SQL query from shell script.
A part of script is something like this:
fromDate=`echo $(date +"%F%T") | sed "s/-//g" | sed "s/://g"`
$ORACLE_HOME/sqlplus -s /nolog <<EOD1
connect $COSDBUID/$COSDBPWD@$COSDBSID
spool... (4 Replies)
I installed Oracle 10 software on Solaris 11 Express, everything was fine execpt I can't create database using dbca.rsp file. I populated file with following options.
OPERATION_TYPE = "createDatabase"
GDBNAME = "solaris_user.domain.com"
SID = "solaris_user"
TEMPLATENAME = "General... (0 Replies)
Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database.
I need to write the korn shell program on Red Hat Enterprise Linux server.
Oracle database is 10g. (15 Replies)
Hi guys ,
I m trying to store the output of vmstat 1 10 into a database.
I have done the necessary homework to connect bash to interact with the database.
Program logic.
1)storing the output of vmstat 1 10 to a file named abc.txt
2)I m applying a filter to vmstat to get desired output... (4 Replies)