The following small shell script will generate a SQL file which contains multiple insert statements.
The shell script will add unique numbers for each primary key object in the insert statements.
######################################################################Put the above lines of code in shell script and run it at the shell to generate mutiple insert statements according to ur need in the SQL file dummydata.sql
i=1270803816866
k=1
while [ $k -le 4 ]
do
echo "insert into CDSSCHEMA.PLAN_DESCRIPTION (PLAN_ID,PACKAGE_ID,LOCAL_IP,REMOTE_IP,STATUS,PLANCREATIONTIME,USERID) values ('$i','1270803791784','9.124.158.200','9.124.158.200',1,'2010-04-09 09:04:21.979898','CDS_Administrator')" >> dummydata.sql
let i="i+1"
let k="k+1"
done
####################################################################
Don't forget to add your better ideas to improve this script in form of comments.
1 comments to "Generate mutiple insert commands in sql file using shell script"
Post a Comment
Whoever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs, u can at least use Name/URL option which doesn’t even require any sign-in, The good thing is that it can accept your lovely nick name also and the URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")
Popular Posts
-
The best solution to know about these init levels is to understand the " man init " command output on Unix. There are basically 8...
-
How to Unlock BSNL 3G data card to use it with Airtel and Vodafone Model no : LW272 ? How to unlock BSNL 3G data card( Model no : LW272 )us...
-
How to transfer bike registration from one State to other (Karnataka to Andhra)?? Most of us having two wheelers purchased and registered in...
-
ఓం శ్రీ స్వామియే శరణం ఆయ్యప్ప!! Related posts : Trip to Sabarimala - Part 1 Trip to Sabarimala - Part 2 Ayappa Deeksha required things...
-
Following are some of interesting blogs I found till now ...please comment to add your blog here. Blogs in English : http://nitawriter.word...
Popular posts
- Airtel and vodafone GPRS settings for pocket PC phones
- Andhra 2 America
- Ayyappa Deeksha required things
- Blogs I watch !
- Captions for your bike
- DB2 FAQs
- Deepavali Vs The Goddes of sleep
- ETV - Dhee D2 D3
- Evolution of smoking in India Women
- How to make credit card payments?
- init 0, init 1, init 2 ..
- Java-J2EE interview preparation
- mCheck Application jar or jad download
- My SQL FAQs
- My Travelogues
- Old is blod - New is italic
- Online pay methids for credit cards
- Oracle FAQs
- Pilgrimages
- Smoking in Indian Women
- Technology Vs Humans
- Twitter feeds for all Telugu stars on single page.
- Unix best practices
- Unix FAQs
Buffs ...
Tags
Powered by WidgetsForFree
Archives
-
▼
2010
(35)
-
▼
April
(9)
- Sekhar Kammula - A Soothing director
- ETV Dhee 4 - D4 Ladies special - Keep dancing
- Best/top/Free pocket pc app(s)lications download
- Generate mutiple insert commands in sql file using...
- DB2 manual uninstallation and cleaning
- SQL1428N The application is already attached to "...
- Indian famous film stars on twitter tolly,kolly,bo...
- Review "Of course I love You....Till I Find Someon...
- Difference between Jython and python
-
▼
April
(9)
Kishore says:
hi babu
Good one...have a look of below code, it might be useful stuff & off course this is main part of our code...but runsql function below must to useful one..
Thanks
kishore
-----
#********************************************************************************
# Function Name : runSql
# Description : Run the given sql as the given user with given login/passwd.
# Parameters : $1=user $2=login/passwd/connectString $3=sql
# Returns : N/A but $rows set
# Notes : Can't just return rows as its only 8 bit.
#********************************************************************************
runSql ()
{
typeset user=${1%%/*}
typeset dir=/home/${1#*/}
typeset login=$2
typeset sql=${3%;}
typeset pattern=${4:-"^"}
4>&-
let rows=$(su $user -c "cd $dir; . ./.profile >/dev/null; \
echo \"${sql};\ncommit;\nexit;\" | sqlplus -s $login \
| grep \"${pattern}[0-9]\" 2>/dev/null \
| tail -1 | sed 's/[^[:digit:]]\{2,\}/ /g' \
| awk '{ print \$1 }' >&4" 4>&1 >/dev/null) 2>/dev/null
return
}
##main
# To create an index for USERLINK_IDX1 and NODEAGGREGATE_VIEWTYPE(msp120779 Patch_293)
if [[ $scriptType = "Postinstall" ]]
then
print "DISP: $scriptType for P$p create an index USERLINK_IDX1 and NODEAGGREGATE_VIEWTYPE."
sql="CREATE INDEX USERLINK_IDX1 ON USERLINK (MAPID,ACTION,SESSIONID,MAPREFID) TABLESPACE NP_INDEX_S1;
CREATE INDEX NODEAGGREGATE_VIEWTYPE ON NODEAGGREGATE(VIEWTYPE) TABLESPACE NP_INDEX_S1;"
runSql oms "osm/dbmanager@osm" "$sql"
print "DISP: $scriptType for P$p created an index EM_NOTIF_SVCRID."
elif [[ $scriptType = "Postremove" ]]
then
print "DISP: $scriptType for P$p droping an index USERLINK_IDX1 and NODEAGGREGATE_VIEWTYPE."
sql="DROP INDEX USERLINK_IDX1;
DROP INDEX NODEAGGREGATE_VIEWTYPE;"
runSql oms "osm/dbmanager@osm" "$sql"
print "DISP: $scriptType for P$p Droped an index USERLINK_IDX1 and NODEAGGREGATE_VIEWTYPE."
fi