How to create thousands of sql scripts easily?
Hello,
I would like to create thousand of scripts as following:
insert into table tb_test('aaa'); update table tb_class( set nm = 'aaa');
insert into table tb_test('basd'); update table tb_class( set nm = 'basd');
insert into table tb_test('asdfa');update table tb_class( set nm = 'asdfs');
insert into table tb_test('xxxyy');update table tb_class( set nm = 'xxxyy');
Is there any simple way to generated those scripts automatically? I am thinking of :
define var_str = ('aaa', 'bbb', 'asdfd',...'xxxyy');
select 'insert into table tb_test(' || var_str || '); update table tb_class( set nm =' || var_str || ');'
from dual;
Then how do I generate those scripts from the var_str?
Thanks,
942572 wrote:
I have more than 5000 parameters in a text file as followings, which can be opened by notepad or excel:
'aaa',
'basd',
'asdfs',
'xxxyy'
Ok, so assuming this is a 1-off event, use Excel.
Setup a quick formula to turn each into a proc call:
[edit] if the values are in column "A", then in column "B", you could do: =concatenate("p_proc('", a1, "');")
then copy that formula down.
[/edit]
p_proc('aaa');
p_proc('basd');
etc.
Then setup a little p_proc as Frank described. (and please, use a WHERE clause on that update ... or you're going to destroy some data )
Then copy past those commands into a routine that ends up looking like:
declare
procedure p_proc ( in_value )
is
begin
-- Frank's code goes here
end;
begin
-- proc list goes here
p_proc('aaa');
..... etc.
end;
That's 1 very primitive way to do it.
If you need to reproduce this in future, you may want to consider loading that list of parameter values into a table, then you can do some more funky things. *shrug*
Similar Messages
-
How can I run a SQL script file...
How can I run a SQL script file from a location on my computer without providing the whole path?
Is there some way I can set a "Working folder" in SQL Plus??
Thanks!
TomYou can create an environment variable called "SQLPATH" which is a list of directories that SQL*Plus will search for your .SQL
scripts.
I would like to use another directory than the oracle/bin...
How can I do this ??
Hello,
U can do this by this way:
Save odm_script.sql file to the default Oracle
directory i.e. Oracle-Home/bin and Run following command
through SQL Plus.
SQL>@Script_Name
I hope this will resolve ur problem.
Regards,
Omer Saeed Khan. -
How to create .log for sqlplus script
Hi All,
I created a sqlplus script and run it through a window form. My user want to me create a .log file for this script so they can know the job is completed or not. Does any one know how to do it?
Thanks
OFI created a "Login.sql" script that I use for all my sql*plus sessions.
It creates a spool file in my common directory and everything i do is logged unless i set spool off.
Take a look and it gives you an example of using spool files and how to set a directory and unique filename for each spoolfile.
The contents of this file:
-- any uppercase commands are my specific changes.
-- this file must go in the oracle bin path or where sqlplus exe is located
SET HEADING OFF
PROMPT Who What Why Where When, This is SQL*Plus!
Select 'You are connected to ' || GLOBAL_NAME || ' as ' || USER FROM GLOBAL_NAME;
set appinfo ON
set appinfo "SQL*Plus"
set arraysize 15
set autocommit OFF
set autoprint OFF
set autorecovery OFF
set autotrace off
set blockterminator "."
set cmdsep OFF
set colsep " "
set compatibility NATIVE
set concat "."
set copycommit 0
set copytypecheck ON
set define "&"
set describe DEPTH 1 LINENUM OFF INDENT ON
set markup HTML OFF SPOOL OFF ENTMAP ON PRE OFF
set echo OFF
set editfile "afiedt.buf"
set embedded OFF
set endbuftoken ""
set escape OFF
set feedback 6
set flagger OFF
set flush ON
SET HEADING ON
set headsep "|"
SET LINESIZE 250
set logsource ""
set long 80
set longchunksize 80
set newpage 1
set null ""
set numformat ""
set numwidth 10
SET PAGESIZE 24
set pause OFF
set recsep WRAP
set recsepchar " "
SET SERVEROUTPUT ON size 1000000 format WORD_WRAPPED
set shiftinout invisible
set showmode OFF
set sqlblanklines OFF
set sqlcase MIXED
set sqlcontinue "> "
set sqlnumber ON
set sqlprefix "#"
set sqlprompt "SQL> "
set sqlterminator ";"
set suffix "sql"
set tab ON
set termout ON
SET TIME ON
SET TIMING ON
SET TRIMOUT ON
set trimspool OFF
set underline "-"
set verify ON
set wrap ON
COL SPOOLFILE NEW_VALUE SPOOL;
COL SYSTIMESTAMP FORMAT a38
SELECT 'C:\oracle\spoolfiles\'||NAME||'_'||TO_CHAR(SYSDATE,'DD_MON_YYYY_HH24MISS')||'.lst' spoolfile FROM V$DATABASE;
spool &spool
PROMPT -----------------------------------------------
SELECT SYSTIMESTAMP FROM DUAL;
PROMPT ----------------------------------------------- -
How to create a barcode in scripts and smartforms
hi
how to create a barcode in scripts and smartformsHi,
For Script:
A barcode solution consists of the following:
- a barcode printer
- a barcode reader
- a mobile data collection application/program
A barcode label is a special symbology to represent human readable information such as a material number or batch number
in machine readable format.
There are different symbologies for different applications and different industries. Luckily, you need not worry to much about that as the logistics supply chain has mostly standardized on 3 of 9 and 128 barcode symbologies - which all barcode readers support and which SAP support natively in it's printing protocols.
You can print barcodes from SAP by modifying an existing output form.
Behind every output form is a print program that collects all the data and then pass it to the form. The form contains the layout as well as the font, line and paragraph formats. These forms are designed using SAPScript (a very easy but frustratingly simplistic form format language) or SmartForms that is more of a graphical form design tool.
Barcodes are nothing more than a font definition and is part of the style sheet associated with a particular SAPScript form. The most important aspect is to place a parameter in the line of the form that points to the data element that you want to represent as barcode on the form, i.e. material number. Next you need to set the font for that parameter value to one of the supported barcode symbologies.
The next part of the equation can be a bit tricky as you will need to get a printer to print that barcode font. Regular laser printers does not normally print barcode fonts, only specialized industrial printers that is specifically designed to support that protocol and that uses specialized label media and heat transfer (resin) ribbon to create the sharp image required for barcodes.
Not to fear though, there are two ways to get around this:
- You can have your IT department do some research -
most laser printers can accept a font cartridge/dimm chip (similar to computer memory), called a BarDIMM that will allow a laser printer to support the printing of barcodes.
- Secondly, you can buy software that you can upload in your SAP print Server that will convert the barcode symbology as an image that will print on a regular laser printer. I found that this option results in less sharper barcodes. This option is really if you need to convert a large quantity of printers (>10) to support barcodes.
- Thirdly, you can buy a third party software like Barcode.dll and install on your frontend PC connected to the laser printer.
Now you have a barcode printed - what next?
Well there are two options, depending on your business requirements:
- You can use an existing SAP transaction on a regular workstation and get a barcode wedge reader to hook up between the keyboard and the PC. These wedge readers comes in a wand or scanner format. There are even wireless wedge scanners available that allows you to roam a few yards from the workstation to scan a label. This approach is mostly used where you want to prevent human errors in typing in long material, batch or serial numbers in receiving or issuing of material. The problem is that it's just replacing the keyboard input and you are basically locked down in one location and have to bring all the material to that location to process.
- Another solution is to use SAPConsole transactions
or write your own ABAP Dialog programs that will fit onto a barcode enabled wireless handheld terminal and that will follow the business logic as executed on the shop floor.
These programs are highly complex exercises in industrial engineering and ergonomics because of the limited screen sizes and limited ability to accept keyboard input. The user is instructed step-by-step and only scan and push F-keys to interact with the SAP system. Scan, scan, beep, beep, enter - highly automated.
For SmartForm:
http://www.sap-img.com/abap/questions-about-bar-code-printing-in-sap.htm
Regards,
Bhaskar -
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 to use views in sql script report?
All all
Can any one tell how to use views in sql script report?Most of the views are based on tables (or other views which are based on tables).
The view typically shows one org at a time based on the context that is set.
If you need records for all orgs, you need to use the underlying tables. Oracle typically names the tables with a _all suffix.
e.g. PO_HEADERS will show records for one org at a time. PO_HEADERS_ALL will show records for all orgs.
Hope this answers your question,
Sandeep Gandhi -
How to create ArrayColletion in mx:Script from <mx:Model
id="results" source="/data/data.xml" />
Please see my code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute">
<mx:Model id="results" source="/data/data.xml" />
<mx:Script>
import mx.collections.ArrayCollection;
import mx.utils.ArrayUtil;
import mx.controls.Alert;
</mx:Script>
<mx:ArrayCollection id ="dt1"
source="{ArrayUtil.toArray(results.result)}"/>
<mx:Script><![CDATA[
[Bindable]
public var expenses:ArrayCollection = dt1;
[Bindable]
public var expenses2:ArrayCollection = dt1;
[Bindable]
public var dp:ArrayCollection=expenses;
public function changeDataProvider():void{
Alert.show(expenses.toString());
if (dp==expenses){
dp=expenses2;
}else{
dp=expenses;
]]></mx:Script>
<mx:Panel x="10" y="10" width="100%" height="378"
layout="absolute">
<mx:ColumnChart dataProvider="{dt1}" x="10" y="10"
id="myChart" height="318" width="100%">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="month"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries displayName="apple" yField="apple"/>
<mx:ColumnSeries displayName="orange"
yField="orange"/>
<mx:ColumnSeries displayName="banana"
yField="banana"/>
</mx:series>
</mx:ColumnChart>
<mx:Legend dataProvider="{myChart}" x="481" y="10"/>
</mx:Panel>
<mx:Button x="284" y="416" label="Change Data" id="bt"
click="changeDataProvider()" />
</mx:Application>Tracy,
Thanks. That worked. However I have another related question:
I convert the xml feed to a XMLListCollection by doing:
<mx:XMLListCollection id="mission"
source="{xmlFeed.lastResult.day}"/>
and
<mx:XMLListCollection id="mission1"
source="{xmlFeed.lastResult.day.tBlock}"/>
On the chart I have
<mx:ColumnChart id="missionReadiness" height="150%"
width="100%"
paddingLeft="2" paddingRight="2"
showDataTips="true" dataProvider="{mission1}">
<mx:series>
<mx:ColumnSeries xField="" yField="@today"
displayName="Today"/>
<mx:ColumnSeries xField="" yField="@tomorrow"
displayName="Tomorrow"/>
<mx:ColumnSeries xField="" yField="@afterT"
displayName="After Tomorrow"/>
</mx:series>
</mx:ColumnChart>
the yField works, but for the xField I want to have the @date
but refers to the parent node, so I am clueless on how to refer to
it.
Also, I would like to display on the chart only the values to
a specific date (like @date="05/17/2007").
Any suggestions on how to do that?
Gilbert -
How to double dereference in sql scripts
hi all,
I wanted to call a sql file(sql2) from within an another sql file(sql1). The call to sql2 from sql1 contains some parameters( in form of integer and some variables). It is possible to access integer values in sql2 but i am unable to access the value stored in the variables in file2.
How to access the parameter's(which is itself is a variable) value in the called sql script.
Thanks,
ShyamDepending on your environment and if these are administrative (DBA) scritps or production batch then here are some ideas:
For DBA
Run the scripts via cron in a DBA privileged account
sqlplus /nolog <<EOF
connect / as sysdba
start script
exit
EOF
The above requires no password,
For production batch assuming that all production runs under one OS ID that access to is restricted then potentially you can use OS authentication so the Oracle username has no password: create user bob identified externally.
sqlplus / @script
will then do the job
HTH -- Mark D Powell -- -
How to hide passwords in sql scripts?
Hi!
I have got a few sql scripts for some actions. In the scripts the connection information is plain text - even the SYS password in one script.
Are there ways to solve this behaviour? Perhaps encrypt it or... What does the practice say - how do you solve this???
Thanks
MarkusDepending on your environment and if these are administrative (DBA) scritps or production batch then here are some ideas:
For DBA
Run the scripts via cron in a DBA privileged account
sqlplus /nolog <<EOF
connect / as sysdba
start script
exit
EOF
The above requires no password,
For production batch assuming that all production runs under one OS ID that access to is restricted then potentially you can use OS authentication so the Oracle username has no password: create user bob identified externally.
sqlplus / @script
will then do the job
HTH -- Mark D Powell -- -
This is a noob question, though I do use SQL Server databases all the time with Entity Framework when I code in C# using Visual Studio 2013. The development environment is found below at [A]. I am trying to make a clone of a SQL Server 2008 R2
database (.mdf) that exists online. I can read, connect and work with this database in Visual Studio 2013, but I wish to make a local copy of the database, as an .MDF file. Somewhere in my notes I have a way of creating a local copy from
an online database when using Visual Studio but I forgot how (it seems, reviewing my notes, that it deals with ADO.NET which is deprecated in Visual Studio 2013 these days, or so it seems). So I'm looking for another way. What I did was create
(or export) a "Data-Tier Application File" from the online SQL Server database, with data, and it seems to have worked in that this Data-Tier Application file exists on my hard drive and seems to have data in it ("SQL Server Replication Snapshot"
is the format it seems). It contains skeleton code to create a database, but when I tried to execute it with SQL Server 2014 Management Studio, I got a bunch of errors.
So my question is:
1) Can I somehow create a .MDF SQL Server Database from an Data-Tier Application file that has data? What tool do I use? I saw this link, http://social.technet.microsoft.com/wiki/contents/articles/2639.how-to-use-data-tier-application-import-and-export-with-a-windows-azure-sql-database.aspx
and it relates to Azure, but is there a tool for C#Visual Studio 2013, standalone?
2) If there's an easy way to create a .mdf SQL Server Database file from an online file, within SQL Server Management Studio? I don't think so, since it would require Administrator permissions on the online server, which I don't have. I have permission
to read, update, delete the online database file, but strangely not to download it (the service I use has a tool for backup, but not for download).
3) same question as 2), but for Visual Studio 2013? I don't think so, since I notice none of the templates even mentions ADO.NET anymore, but instead they go with Entity Framework. Using EF I can of course do anything I want with the online database
(CRUD), but it remains online. Maybe there's a switch to make a local copy? I guess I could write a short program to suck all the data out of the online database and put it into a new, duplicate database having the same tables, that I create on
my localhost, but my question here is if there's an easier way than this, maybe a tool or command I can run from inside Visual Studio?
Any advice on any of the above questions is appreciated.
Thank you,
Paul
[A] Microsoft Visual Studio Professional 2013
Version 12.0.21005.1 REL
Microsoft .NET Framework
Version 4.5.51641
Microsoft Web Developer Tools 2013 2.0.40926.0
SQL Server Data Tools 12.0.30919.1
Microsoft SQL Server Data Tools
Windows Azure Mobile Services Tools 1.0
Windows Azure Mobile Services ToolsThanks but these links are too general to help.
"2. what do you mean by online file?" - I mean the SQL Server database file is on a remote web server that I rent from, but I am not the administrator of. I can access my database using SQL Server Authentication, but nothing more.
Paul
What do you mean by too general? It explains on how you can use data tier application to create and deploy databases
May be this will help you to understand better
http://www.databasejournal.com/features/mssql/article.php/3911041/Creating-Data-Tier-Applications--in-SQL-Server-2008-R2.htm
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Problem while executing script in Toad - How to use '&' in the sql script ?
I have to execute sql script in toad. Sql script has one insert query in which one insert-value is 'USA & CAN'. When I executed the script in toad by pressing F5, I got a prompt window asking for the value if 'CAN' as it is after the &.
I tried using[b] {escape '\' } .... but could not resolve the problem.
Is there any solution or workaround to overcome this problem. I have thousands of records with such values and I have to use sql script only.There is an option in TOAD to change this behaviour.
Look in VIEW/OPTIONS/SQL Editor/
Uncheck the box for "Scan statements for bound variables before execution".
In SQL*PLUS it would be SET SCAN OFF
(desupported version is SET DEFINE OFF)
Message was edited by:
Sven Weller -
How to create database using shell script
hai
how to create database using shell scriptThe documentation details the steps to create a database manually. Another option is to use DBCA to create the scripts. DBCA will give you a complete set of scripts that will create a database.
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/create.htm#sthref220 -
How to create a table in script
hi gurus
can any one suggest me
how to create a table format in script output
i want the output be in table format
thank you
regards
kals.Hi Kalyan,
There is option for creation of table in Scripts .
We can make the output to b displayed in table format by using BOX command .
see this
Setting default parameters for a box:
You can use the POSITION and SIZE commands to set default parmeters for a box.
Instead of:
/: BOX XPOS '11.21' MM YPOS '5.31' MM HEIGHT '10' MM WIDTH '20' MM INTENSITY 10 FRAME 0 TW
You can write:
/: POSITION XORIGIN '11.21' YORIGIN '5.31' MM
/: SIZE HEIGHT '2' MM WIDTH '76' MM
/: BOX FRAME 10 TW INTENSITY 10
This can be usefull if you gave several boxes that share the same parameters.
If you want to set the position realtively to the window use POSITION WINDOW
to set the position to the top/left start of the window. Then use POSITION
to set the current position relatively to the start of the Window.
Note that you uses "+" or "-" in the ORIGIN position to the set the position relatively.
/: POSITION WINDOW
/: POSITION XORIGIN '5' MM YORIGIN '10' MM
the position is now 5 MM from the left and 10 MM from the top of the window
NOTE: After using the position command you can move the current position
realtively to the last used position
/: POSITION XORIGIN '10' MM YORIGIN '20' MM
Now the position will be X = 15 and Y = 30
Drawing a line. You can draw a line by setting the Height or Weidth to 0
and add a frane. E.g. a horizontal line:
/: SIZE HEIGHT '0' MM WIDTH '200' MM
/: BOX FRAME 10 TW XPOS '11.21' MM YPOS '14.81' MM INTENSITY 100
thnx
Sravani
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Apr 21, 2008 5:59 PM -
How to create table control in script
hi expects,
how can i create table control in script?Hi,
It is not possible to create Table Control in Sap-Scripts n u can create it by using se51 that is screen painter only...
if useful reward with points,
regards,
Madhuri. -
How to create channel mixer by script
How I can create channel mixer by JavaScript?
If you create a channel Mixer script you will most likely be using Action Manager Coder you modify from Adobe Scriptlitener Plug-in. There is a Photoshop scripting forum and scripting documentation you can download. Adobe DOM does not cover all Photoshop function. Adobe Photoshop Scripting | Adobe Developer Connection and Photoshop Scripting
Maybe you are looking for
-
For the first time Firefox made me choose between my two gmail accounts: lbalisle @gmail.com and [email protected] I was in Vovision so i checked that and now I can't get into my [email protected] account. This is taking a lot of time to deal with wh
-
I have a strange problem connecting my iPod shuffle. If I plug it into the keyboard USB hub, iTunes recognizes it and I am able to load it with music, but if I plug it into the USB ports on the rear of the G4 it is not seen at all on the Bus (System
-
ITunes doesn't start, crash
My iTunes crash on start. Last operation was to import some song. I rebooted the pc but it still not working.
-
Why does my screen resolution always change when I plug in my iphone 4? How can I stop it?
-
Tmg 2010 Block Any https web site
TMG 2010 block any https site And HTTPS Inspection Disabled when i make a Rule and i make TO Exception URL sets.