Call a script from a function sql file.
HelloI need to call a script file sql from a user-defined function. Currently I am doing this in Oracle SQL Developer. I tried to call with
@ {filename}, EXECUTION IMMEDIATE etc, but nothing worked. I get the compile error.
Basically, my need is to call catldap.sql file so that DBMS_LDAP package gets loaded and then I can call this API functions.
Please let me know if this is possible to do in a PL/SQL function.
Thank you
NGO
user784520 wrote:
I need to call a script file sql from a user-defined function.
Not possible... and it seems that you do not fully understand the client-server in the context of Oracle.
All SQL and PL/SQL are parsed and executed by an Oracle server process. Engines SQL and PL/SQL is expecting a single command at a time block. Any of these can accept a series of commands in a single call and then runs them in turn. The SQL engine expects a single SQL statement at a time. PL engine provides an anonymous PL/SQL block for both.
This server process can not also enter the local file system to access the script files. Nor can he hack it on the network to access the script on the client files.
So that the server process to access local files, a Directory object must be created and the current Oracle schema must read or a write access to this directory object. Sound security principles apply.
There is no PL/SQL command to run a script. Do not confuse SQL * more (this customer has a very limited vocabulary) orders with PL/SQL commands. SQL * Plus runs its own orders... and send SQL and PL/SQL commands (a statement block a time) either repaired and running Oracle server process.
It's also a very bad idea to run the external script content from within an Oracle server process - as this script resides outside and so outside the Oracle security mechanisms. This means that it is fairly easy for a person to access this script, compromise and then you inject and execute the contents of this script in the database.
It is not good security.
Latest issue - it's even worse to have the PL/SQL application dynamically create (or try to create) parts of the Oracle data dictionary and calling PL/SQL interface.
The database must be installed correctly - and that includes loading and execution of the required rdbms/admin scripts during installation. It makes no sense at all for the application code to try to run these scripts. It raises many questions, including getting to allow the full application and full SYS code access to the instance database. A very serious breach of security.
I agree at all with the approach to use.
Tags: Database
Similar Questions
-
Call Shell Script from within PL/SQL - using DBMS_PIPE
Hi all
I'm trying to run a shell script inside my PL/SQL using DBMS_PIPE block (not sure if this is the right way or not)
Pl Sql script
==========
Set serveroutput size 100000
declare
cursor c1 is select * from mag_images
where nom_image like '% comp2.
v_path varchar2 (100): = ' / home/maguzzi/DOCUMENTS_DIR / ";
v_result number: = 0;
v_in_filename varchar2 (100): = v_path | ' test_file.jpg';
v_out_filename varchar2 (100): = v_path | ' test_file_out.jpg';
v_script varchar2 (100): = "tst_convert.sh";
v_command varchar2 (200): = 'sh'. v_path | v_script | » '|| v_in_filename | » '|| v_out_filename;
Start
A1 to c1 loop
dbms_output.put_line ('v_command: ' | v_command);
write_to_file ('test_file.jpg', 'DOCUMENTS_DIR', a1. Content);
dbms_output.put_line (' file write result: ' | v_result);
v_result: = exec_host_command (v_command);
dbms_output.put_line (' resize result :'|| file v_result);
end loop;
end;
Result DBMS_OUTPUT
====================
v_command: /home/maguzzi/DOCUMENTS_DIR/tst_convert.sh test_file.jpg test_file_out.jpg
Result of the entry of the file: 0
Result of resizing the file: 0
PL/SQL procedure successfully completed.
Function exec_host_command
=======================
FUNCTION to CREATE or REPLACE exec_host_command (lc_cmd IN VARCHAR2)
RETURN INTEGER IS
ln_status NUMBER;
lc_errormsg VARCHAR2 (80);
lc_pipe_name VARCHAR2 (30);
BEGIN
lc_pipe_name: = 'Maguzzi_PIPE ';
DBMS_PIPE. PACK_MESSAGE (lc_cmd);
ln_status: = dbms_pipe.send_message (lc_pipe_name);
RETURN ln_status;
END;
/
The Image of the BLOB is written to the correct location on the server "test_file.jpg", and although the exec_host_command function returns a value of 0, the shell script (tst_convert.sh) is not executed (i.e. no output file is created - outfile.txt and the image is not copied/converted to a new file name "" test_file_out.jpg" )
Shell script
========
tst_convert.sh
echo 'Here' > outfile.txt
Echo $1 > > outfile.txt
Echo $2 > > outfile.txt
resizing to convert $1 - $200 2
Could this be problems with permissions on files?
test_file1.jpg has permission - rw-rw-r-
test_convert.sh a permission rwxrwxrwx
When I run the script manually and pass in 2 parameters ($1 = infilename and $2 = outfilename), it works...
I'd appreciate if someone can point out my mistake or suggest another method that works.
Thanks in advance
How long does it take to create the converted file? Remember that the external Scheduler is running asynchronously, so it is possible that the converted file does not exist yet when the PL/SQL block subsequently tries to open it.
Try to add some delay seconds to the routine to ensure that the external task is completed:
begin dbms_scheduler.create_job( job_name => 'MAG_IMAGE_CONVERT2' , job_type => 'EXECUTABLE' , job_action => '/home/oracle/DOCUMENTS_DIR/tst_convert2.sh' );-- '/home/oracle/DOCUMENTS_DIR/tst_convert.sh'); dbms_scheduler.enable('MAG_IMAGE_CONVERT2'); dbms_lock.sleep(3); end;
This probably isn't really a viable solution in the long term if it turns out that this is really the problem.
-
Hello
Is it possible to call a script existing since an Illustrator plugin?
Thank you
I close the topic because I think I used a bad word. In fact, I don't want to call a script but an action performed by a user.
-
ExtendToolscript opens when I call the script from photoshop
Hey,.
I asked this question on in general discussions by mistake if I though I would ask new here.
I have a Javascript that I wrote which generates an interface of buttons in groups organized according to the contents of some folders. Everything works fine, but when you call it from photoshop and extendtoolscript it is not always executed it opens. I wrote many scripts with interfaces and I've never had this problem. This isn't a huge problem for me, as I usually have this program open anyway, but I intend to have a team of people using this script, so if I could stop, somehow, it would be much better.
If anyone has experienced this before? Or maybe functions extendscript causes to open?
I don't see anything unusual in the script...
Any help would be appreciated!
Thank you
Mark
var strtRulerUnits = app.preferences.rulerUnits; var strtTypeUnits = app.preferences.typeUnits; app.preferences.rulerUnits = Units.PIXELS; app.preferences.typeUnits = TypeUnits.PIXELS; var templatepath = "~/Desktop/BANNERS/"; var bannerfile = "" var docRef = app.activeDocument; var fileArray = new Array(); var sourceFolder = Folder (templatepath + "MAIN/"); var extRE = /\.(?:png|gif|jpg|bmp|tif|psd)$/i; // get all files in source folder var docs = sourceFolder.getFiles(); var len = docs.length; for (var i = 0; i < len; i++) { var doc = docs[i]; // only match files (not folders) if (doc instanceof File) { // store all recognized files into an array var docName = doc.name; if (docName.match(extRE)) { fileArray.push(doc); } } } var w = new Window ("dialog", "Choose a Banner"); w.preferredSize = [400, 100]; w.orientation = 'row'; w.alignChildren = "left" w.alignChildren = [ "fill", "fill"]; w.btnPnl = w.add('panel', undefined, 'MAIN'); w.btnPnl.btn = w.add ("group"); w.btnPnl.btn.alignChildren = "left" var buttonarray = new Array (); var key = {}; for (var i = 0; i < fileArray.length ; i++) { var delimeter = '/'; var string = String (fileArray[i]); var splitted = string.split(delimeter); var thelength = ((splitted.length) - 1); var bannername = splitted[thelength]; var delimeter = '.'; var splitted = bannername.split(delimeter); var bannername = splitted[0]; var checkdelim = "%20"; var checkthat = bannername.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = '%20'; var splitted = bannername.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var bannername = (splitted[counter] + " "); } else if (counter == ((splitted.length) - 1)){ var bannername = (bannername + splitted[counter]); } else{ var bannername = (bannername + splitted[counter] + " "); } var counter = (counter + 1); } } if (fileArray.length > 6){ var divider = 2 } else{ var divider = 1 } var remainder = (i % divider); if (remainder == 0){ w.btnPnl.btn = w.btnPnl.add ("group"); w.btnPnl.btn.alignChildren = "left" } else { //x is not a multiple of y } key = (String (fileArray[i])); w[key] = w.btnPnl.btn.add("button", undefined ,bannername ); w[key].alignment = 'left'; buttonarray.push(w[key]); w.btnPnl.btn.addEventListener('click', button_pressed); function button_pressed (e) { if (e.target.type == "button") $.writeln (e.target.text + " from panel " + e.target.parent.text); w.close() //////////////////// var buttonname = e.target.text; var checkdelim = " "; var checkthat = buttonname.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = ' '; var splitted = buttonname.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var buttonname = (splitted[counter] + "%20"); } else if (counter == ((splitted.length) - 1)){ var buttonname = (buttonname + splitted[counter]); } else{ var buttonname = (buttonname + splitted[counter] + "%20"); } var counter = (counter + 1); } } /////////////////////// bannerfile = new File (templatepath + "MAIN/" + buttonname + '.png'); } } /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// var fileArrayneon = new Array(); var sourceFolder = Folder (templatepath + "NEON/"); var extRE = /\.(?:png|gif|jpg|bmp|tif|psd)$/i; // get all files in source folder var docs = sourceFolder.getFiles(); var len = docs.length; for (var i = 0; i < len; i++) { var doc = docs[i]; // only match files (not folders) if (doc instanceof File) { // store all recognized files into an array var docName = doc.name; if (docName.match(extRE)) { fileArrayneon.push(doc); } } } w.btnPnl = w.add('panel', undefined, 'NEON'); w.btnPnl.btn = w.add ("group"); var buttonarray = new Array (); var key = {}; for (var i = 0; i < fileArrayneon.length ; i++) { var delimeter = '/'; var string = String (fileArrayneon[i]); var splitted = string.split(delimeter); var thelength = ((splitted.length) - 1); var bannername = splitted[thelength]; var delimeter = '.'; var splitted = bannername.split(delimeter); var bannername = splitted[0]; var checkdelim = "%20"; var checkthat = bannername.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = '%20'; var splitted = bannername.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var bannername = (splitted[counter] + " "); } else if (counter == ((splitted.length) - 1)){ var bannername = (bannername + splitted[counter]); } else{ var bannername = (bannername + splitted[counter] + " "); } var counter = (counter + 1); } } if (fileArrayneon.length > 6){ var divider = 2 } else{ var divider = 1 } var remainder = (i % divider); if (remainder == 0){ w.btnPnl.btn = w.btnPnl.add ("group"); w.btnPnl.btn.alignChildren = "left" } else { //x is not a multiple of y } key = (String (fileArrayneon[i])); w[key] = w.btnPnl.btn.add("button", undefined ,bannername ); w[key].alignment = 'left'; buttonarray.push(w[key]); w.btnPnl.btn.addEventListener('click', button_pressed); function button_pressed (e) { if (e.target.type == "button") $.writeln (e.target.text + " from panel " + e.target.parent.text); w.close() //////////////////// var buttonname = e.target.text; var checkdelim = " "; var checkthat = buttonname.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = ' '; var splitted = buttonname.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var buttonname = (splitted[counter] + "%20"); } else if (counter == ((splitted.length) - 1)){ var buttonname = (buttonname + splitted[counter]); } else{ var buttonname = (buttonname + splitted[counter] + "%20"); } var counter = (counter + 1); } } /////////////////////// bannerfile = new File (templatepath + "NEON/" + buttonname + '.png'); } } /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// var fileArray180 = new Array(); var sourceFolder = Folder (templatepath + "180/"); var extRE = /\.(?:png|gif|jpg|bmp|tif|psd)$/i; // get all files in source folder var docs = sourceFolder.getFiles(); var len = docs.length; for (var i = 0; i < len; i++) { var doc = docs[i]; // only match files (not folders) if (doc instanceof File) { // store all recognized files into an array var docName = doc.name; if (docName.match(extRE)) { fileArray180.push(doc); } } } w.btnPnl = w.add('panel', undefined, '180'); w.btnPnl.btn = w.add ("group"); var buttonarray = new Array (); var key = {}; for (var i = 0; i < fileArray180.length ; i++) { var delimeter = '/'; var string = String (fileArray180[i]); var splitted = string.split(delimeter); var thelength = ((splitted.length) - 1); var bannername = splitted[thelength]; var delimeter = '.'; var splitted = bannername.split(delimeter); var bannername = splitted[0]; var checkdelim = "%20"; var checkthat = bannername.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = '%20'; var splitted = bannername.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var bannername = (splitted[counter] + " "); } else if (counter == ((splitted.length) - 1)){ var bannername = (bannername + splitted[counter]); } else{ var bannername = (bannername + splitted[counter] + " "); } var counter = (counter + 1); } } if (fileArray180.length > 6){ var divider = 2 } else{ var divider = 1 } var remainder = (i % divider); if (remainder == 0){ w.btnPnl.btn = w.btnPnl.add ("group"); w.btnPnl.btn.alignChildren = "left" } else { //x is not a multiple of y } key = (String (fileArray180[i])); w[key] = w.btnPnl.btn.add("button", undefined ,bannername ); w[key].alignment = 'left'; buttonarray.push(w[key]); w.btnPnl.btn.addEventListener('click', button_pressed); function button_pressed (e) { if (e.target.type == "button") $.writeln (e.target.text + " from panel " + e.target.parent.text); w.close() //////////////////// var buttonname = e.target.text; var checkdelim = " "; var checkthat = buttonname.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = ' '; var splitted = buttonname.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var buttonname = (splitted[counter] + "%20"); } else if (counter == ((splitted.length) - 1)){ var buttonname = (buttonname + splitted[counter]); } else{ var buttonname = (buttonname + splitted[counter] + "%20"); } var counter = (counter + 1); } } /////////////////////// bannerfile = new File (templatepath + "180/" + buttonname + '.png'); } } /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// var fileArraymisc = new Array(); var sourceFolder = Folder (templatepath + "MISC/"); var extRE = /\.(?:png|gif|jpg|bmp|tif|psd)$/i; // get all files in source folder var docs = sourceFolder.getFiles(); var len = docs.length; for (var i = 0; i < len; i++) { var doc = docs[i]; // only match files (not folders) if (doc instanceof File) { // store all recognized files into an array var docName = doc.name; if (docName.match(extRE)) { fileArraymisc.push(doc); } } } w.btnPnl = w.add('panel', undefined, 'MISC'); w.btnPnl.btn = w.add ("group"); var buttonarray = new Array (); var key = {}; for (var i = 0; i < fileArraymisc.length ; i++) { var delimeter = '/'; var string = String (fileArraymisc[i]); var splitted = string.split(delimeter); var thelength = ((splitted.length) - 1); var bannername = splitted[thelength]; var delimeter = '.'; var splitted = bannername.split(delimeter); var bannername = splitted[0]; var checkdelim = "%20"; var checkthat = bannername.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = '%20'; var splitted = bannername.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var bannername = (splitted[counter] + " "); } else if (counter == ((splitted.length) - 1)){ var bannername = (bannername + splitted[counter]); } else{ var bannername = (bannername + splitted[counter] + " "); } var counter = (counter + 1); } } if (fileArraymisc.length > 6){ var divider = 2 } else{ var divider = 1 } var remainder = (i % divider); if (remainder == 0){ w.btnPnl.btn = w.btnPnl.add ("group"); w.btnPnl.btn.alignChildren = "left" } else { //x is not a multiple of y } key = (String (fileArraymisc[i])); w[key] = w.btnPnl.btn.add("button", undefined ,bannername ); w[key].alignment = 'left'; buttonarray.push(w[key]); w.btnPnl.btn.addEventListener('click', button_pressed); function button_pressed (e) { if (e.target.type == "button") $.writeln (e.target.text + " from panel " + e.target.parent.text); w.close() //////////////////// var buttonname = e.target.text; var checkdelim = " "; var checkthat = buttonname.indexOf(checkdelim); if (checkthat == "-1") {} else { var delimeter = ' '; var splitted = buttonname.split(delimeter); var counter = 0; while (counter < splitted.length){ if (counter == 0){ var buttonname = (splitted[counter] + "%20"); } else if (counter == ((splitted.length) - 1)){ var buttonname = (buttonname + splitted[counter]); } else{ var buttonname = (buttonname + splitted[counter] + "%20"); } var counter = (counter + 1); } } /////////////////////// bannerfile = new File (templatepath + "MISC/" + buttonname + '.png'); } } w.show(); /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// if (bannerfile == ""){} else{ var targetDocumentName = docRef.name; var tempfile = app.open (bannerfile); var sourceDocumentName = app.activeDocument.name; var thewidth = tempfile.width; var theheight = tempfile.height; app.activeDocument = docRef; docRef.resizeImage (null, theheight, null, ResampleMethod.BICUBIC); if ((String(thewidth)) == (String(docRef.width))){ var thelayer = docRef.activeLayer; copyLayers(sourceDocumentName, targetDocumentName ); docRef.activeLayer = thelayer; } else { alert ("Document width Incorrect") docRef.activeLayer.name = "main"; var thelayer = docRef.activeLayer; docRef.resizeCanvas (thewidth, null, AnchorPosition.BOTTOMCENTER); copyLayers(sourceDocumentName, targetDocumentName ); docRef.activeLayer = thelayer; } imageView ("FtOn"); } /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// function copyLayers(sourceDocumentName, targetDocumentName) { var sourceDoc = app.documents[sourceDocumentName]; var targetDoc = app.documents[targetDocumentName]; var sourceLayer, targetLayer, sourceGroup; if (app.activeDocument != sourceDoc) { app.activeDocument = sourceDoc; } var thelayer = tempfile.layers[0]; var layersToCopy = thelayer.name; if ( typeof layersToCopy === 'string' ) { sourceGroup = tempfile.layers[0]; targetLayer = sourceGroup.duplicate( targetDoc, ElementPlacement.PLACEATBEGINNING ) } else if ( Object.prototype.toString.call( layersToCopy ) === '[object Array]' ) { for (var i = 0; i < layersToCopy.length; i++) { sourceLayer = sourceDoc.artLayers.getByName( layersToCopy[i] ); targetLayer = sourceLayer.duplicate( targetDoc, ElementPlacement.PLACEATBEGINNING ); } } tempfile.close(SaveOptions.DONOTSAVECHANGES); } function imageView (view) { desc= new ActionDescriptor(); ref = new ActionReference(); if (view.length < 5){ var viewID = charIDToTypeID( view ); }else{ var viewID = stringIDToTypeID( view ); } ref.putEnumerated( charIDToTypeID( "Mn " ), charIDToTypeID( "MnIt" ), viewID ); desc.putReference( charIDToTypeID( "null" ), ref ); executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO ); };
$.writeln (written) the text specified in the JavaScript Console to ExtendScript Toolkit.
You will probably need to 4 occurrences of the following line, apparently used for purposes of debugging in comment:
$.writeln (e.target.text + " from panel " + e.target.parent.text);
-
data transmitted from dequeue function measure file incorrect
Hello
I'm under Labview Base 2013 and have a vi that reads data from a RS232 port and a digital port OR-USB6002. I decided to split the loops in consumers/producers, using the functions of the queue, but ran in four snags with the loop of data recovery.
(1) the digital pulses are displayed correctly in the USB Signal loop, but the recovery loop data does not display data RS232,
(2) combined in the loop of data recovery in the file of measurement data to write, but are not properly separated in their columns, i.e. a column is displaying data or loops
(3) stop button is throwing error 1, incorrect path
(4) thumbs real control when it is plugged into the loop of data recovery and in signals combine to measure file causes the vi runs correctly. It runs but does not display the data in the tables on the part of the loops and no data is written to the file of measures.
I added an indicator in the loop of RS2323 and it appears the data correctly on the front panel, but does not appear in the graph.
I am able to run this vi without the functions of the queue and simply write data files of two separate measures, but these are forces me to synchronize the data set later. Not quite what I need.
Image attached vi.
Thoughts? Will be streaming to TDMS work better to keep separate data streams?
You think that you have two queues, but you don't actually have. You named your queues with the same name, so they are the same queue. So you have race conditions including dequeue will get the data. Just remove the string names for constants, and it should work perfectly.
-
How to load SQL scripts from a text file.
Hi, I tried several times to load a script file/SQL text with 10 different tables and the data, but 10g Express doesen't allows me to do that, can someone direct me or tell me what I do or what I need to adopt a special method to achieve this. I'm sure there must be something where you can download SQL scripts from a text file (in the SQL command editor!). Thank youHello
Yes, as Aust replied, you must use SQL Workshop/SQL Script, instead the command SQL Editor.
Sqlplus can also do so, I think, as well as SQL Developer, now it is 1.5.
sqlplus: (the window command line, black of sql)
SQL > @path /--(l'extension devrait être.sql) filename.sql.
Peter
-
How to create Maste Scrpt to call/execute another sql file
Hello
Can you please help me on below.
I have 10 different .sql file and wanted to run in a sequence of another .sql file. Need sample file I can send it back to create my file master sql to call anothere Stored proc or .sql to comiple.
as:
a.SQL
b.PRC
c.PKH
c.PKB
d.SQL
watnted to run these files from another .sql file, do I need to mention the path, if yes then how to define the path, the execution of another file. all sewage treatment.
forward, thanks in advance
Thank you
Rob
Hi, Rob.
885137 wrote:
Hello
Can you please help me on below.
I have 10 different .sql file and wanted to run in a sequence of another .sql file. Need sample file I can send it back to create my file master sql to call anothere Stored proc or .sql to comiple.
as:
a.SQL
b.PRC
c.PKH
c.PKB
d.SQL
watnted to run these files from another .sql file, do I need to mention the path, if yes then how to define the path, the execution of another file. all sewage treatment.
forward, thanks in advance
Thank you
Rob
To call SQL scripts from another SQL script, do the same thing you would do to call by typing on the command line. Put the @ symbol immediately before the name of the file:
@a
@b
@c
...
You don't need to say "@a.sql", ".sql" being the default value at the end of the file name. If you find that explicitly ".sql" in the script, it is clear, then, by all means, go ahead.
If you do not include a full path name, SQL * Plus assumes that they are in the default location.
If you use 2 @ signs, then SQL * Plus will assume the Sub-script is in the same folder (directory) as the main script running, so you can say
@@a
@@b
@@c
...
How to include a path depends on your operating system. In Windows, for example, you could say:
@d:\sql_scripts\sales\a
@d:\sql_scripts\research\b
...
Instead of the sign @, you can use the START command.
See the SQL * Plus manual to learn more:
https://docs.Oracle.com/database/121/SQPUG/ch_five.htm#sthref439
-
call a script sql with one parameter of another
I would like to call a sql script that takes a single parameter (& 1)... but it doesn't.
It looks like (first.sql):
but when I run it, I got an error:begin for cv in (select table_name from all_tables where owner='IBIS') loop @my_script.sql cv.table_name; end loop; end;
What is missing?@first.sql; old 9: spool &1..cob replace new 9: spool cv.table_name.cob replace old 10: select ' 05 DBUFF-' || '&1' || '-1.' from dual; new 10: select ' 05 DBUFF-' || 'cv.table_name' || '-1.' from dual; old 12: from all_tab_cols where table_name='&1' and substr(column_name,1,3)<>'SYS'; new 12: from all_tab_cols where table_name='cv.table_name' and substr(column_name,1,3)<>'SYS'; old 13: select ' 05 ' || '&1' || '-ROWID PIC X(18).' from dual; new 13: select ' 05 ' || 'cv.table_name' || '-ROWID PIC X(18).' from dual;
Kind regards...Hello
The trick is to generate a sql script with all your calls to internal scripts and their parameters.
For example, my script is internal countTableIndex.sql :
select 'Table &1 has got '||count(*)||' indexes.' from user_indexes where table_name='&1';
And here's my script outside coutnIndex.sql :
set serverout on pages 0 lines 100 feed off time off verify off define on tab off trimspool on trimout on termout on termout off spool cmd.sql begin for cur in (select table_name tab from user_tables) loop dbms_output.put_line('@countTableIndexes.sql '||cur.tab); null; end loop; end; / spool off set termout on @cmd.sql exit;
As you can see, it generates a file cmd.sql containing internal script calls and ultimately calls the script cmd.sql.
In my example schema scott after the execution, the cmd.sql file contains:@countTableIndexes.sql DEPT @countTableIndexes.sql EMP @countTableIndexes.sql BONUS @countTableIndexes.sql SALGRADE @countTableIndexes.sql TOTO
Here is the result of my machine:
[oracle@Nicosa-oel test19_parameterizedSqlScripts]$ sqlplus -s scott/tiger@my11g @countIndex.sql Table DEPT has got 1 indexes. Table EMP has got 1 indexes. Table BONUS has got 0 indexes. Table SALGRADE has got 0 indexes. Table TOTO has got 0 indexes.
-
Run the PLSQL Script from Batch file
I am trying to run a PL/SQL script in a batch file in sp1 Windows 7 Prof
N ° 1) I wrote a simple PL/SQL script:
--
-The scope of variables
--
DECLARE
v_sal number (7.2): = 50000;
v_comm number (7.2): = v_sal *. 20;
v_message varchar2 (100): = 'eligible for the commission;
BEGIN
declare
v_sal number (7.2): = 50000;
v_comm number (7.2): = 0;
v_total_comp number (7.2): = v_sal + v_comm;
Start
v_message: = "not committed not" | v_message;
dbms_output.put_line (' message of sub-block is ' | v_message);
dbms_output.put_line (' subblock v_comm is ' | v_comm);
end;
v_message: = 'seller '. v_message;
-dbms_output.put_line ('Main block v_total_comp' | v_total_comp); -Error: not visible in the main block
dbms_output.put_line ('Main block v_comm' | v_comm);
dbms_output.put_line (' main block message is ' | v_message);
END;
/
Step 2) then I wrote a simple batch TstBatch.bat file
sqlplus scott/tiger@orcl < PLSqlVarInputTst1.sql > > TstBatch.log
Step 3) in the BACK of cmd, I tried to run TstBatch.bat
C: > TstBatch.bat
The log file tells me that I have connected to Oracle Database 11 g Enterprise Edition Release...
Then a lot of SQL > SQL > SQL >... 26 times
Procedue of PL/SQL completed successfully.
Disconnected from Oracle database
I also tried running the PLSQL script in SQLPlus:
SQL: > @PLSqlVarInputTst1.sql
Tell me the procedure completed successfully.
QUESTION: So, where is the output of the PL/SQL script?
Hello
You must activate the output: Add the following line at the beginning of your PL/SQL script:
SET SERVEROUT ON
...
-
Is it possible to call a script of a speech file?
Hi all
TL; Dr. to access the tops of path with the expression does not seem possible, but can script, so is it possible to do it by calling a script inside the expression file?
My goal is the number of vertices in path objects and use this value in an expression. The expression is the engine of offset property with a filling of the trajectory and the expression use a relative naming so that I can copy the path trim to 500 other groups of shape layers and have a different effect (speed of the offset) for each group according to the number of vertices of each path.
I looked for a solution to this problem for some time now, and my conclusion is that you simply cannot access the tops of path with the expression, that the path is in a mask or a shape layer.
Is this correct?
With a mask on a solid layer and effects scripts guide after I should be able to:
thisComp.layer("Black_Solid_1").mask ("mask 1") .maskPath .value
or
thisComp.layer("Black_Solid_1").mask ('mask 1'). maskPath.value .vertices
or
thisComp.layer("Black_Solid_1").mask ('mask 1'). maskPath.value.vertices .length
I also tried:
thisComp.layer("Black_Solid_1").mask ('mask 1'). maskPath.vertices .length
and so on...
But when you debug it with the source text of a text layer, I only get "undefined" for the value and errors for other expressions (' named 'summits' in class 'Property' property is missing or does not exist ").
I am sure that these are the correct methods because many scripts use those, including:
http://Omino.com/pixelblog/2008/12/25/AE-mask-vertices-from-Extendscript/
http://www.crGreen.com/aescripts/actual_scripts/Connect_Point_to_Mask_Vertex.jsx
http://aescripts.com/maskvertexexpression/
So if it is not possible to directly access the berries of way by the expression, I thought the appellant, in every expression, an external script which would then return the number of vertices, there are in each table. It would look something like this (pseudo code):
arrayLength =.content("Path_1").value.vertices.length content (.name thisProperty.propertyGroup (2))
return arrayLength
And then use the value I get the script to adjust speeds in my expressions:
Time * arrayLength * thisComp.Layer ("Controller"). Effect ("Speed") ("Slider")
Therefore, it is possible to call a script inside an expression file? How?
If this isn't the case, you have any other suggestions?
Thank you.
Reference: After Effects Scripting Guide, page 172 CS6.
You can use $. evalFile() to run an external file, but it will be executed by the expression engine, not script, so I don't think that helps you. I don't think that there is an automatic solution. I think you're stuck with manually executed a script once you modify the project for updating a cursor somewhere with the number of vertices.
Dan
-
I want to move virtual machines to a folder called Linux name, but we have several file of the same name in our Datacenter, please give me PowerCLI Script to move exactly.
I tried to use for the function FolderByPath below, but don't know how to use it and have worked. Please help me in this.
Function Get-FolderByPath {}
< #.
. Records of recovery SYNOPSIS by giving a path
. DESCRIPTION the function will retrieve a record by its
path. The path can contain any type of leave (folder or)
Data Center).
. Author NOTES: Luc relaxing
. Path PARAMETER
The path to the folder.
This is a required parameter.
. Path PARAMETER
The path to the folder.
This is a required parameter.
. PARAMETER separator
The character used to separate the leaves in the
path. The default value is ' / '.
. EXAMPLE OF
PS > Get-FolderByPath-path ' Datacenter/Folder1/Folder2 ".
. EXAMPLE OF
PS > Get-FolderByPath-path "Folder1 > Folder2"-separator ' > '
# >
(param
[CmdletBinding()]
[parameter (Mandatory = $true)]
[System.String []] ${Path}.
[tank] ${delimiter} = ' / '.
)
{in process
If (((Get-PowerCLIConfiguration).)) DefaultVIServerMode - eq "Multiple") {}
$vcs = $defaultVIServers
}
else {}
$vcs = $defaultVIServers [0]
}
{foreach ($vc to $vcs)
{foreach ($strPath in $Path)
$root = get-file-name of the server data $vc centers
$strPath.Split ($Separator) | %{
$root = get-inventory-name $_-location $root - server $vc - NoRecursion
If ((Get-stocks-localisation $root-NoRecursion |)) Select--ExpandProperty name)-contains "vm") {}
$root = get-inventory-name "vm" - location $root - server $vc - NoRecursion
}
}
$root | where {$_-is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.FolderImpl]}|% {}}
Get-file-name $_. Name - location $root. Parent - Server $vc
}
}
}
}
}
You can try to retrieve the object file by steps as well.
Something like this for example
$folder = get-data center-name 'LTX01-G8 | Get-file-name "LTX-servers | Get-file-name "LTX servers 0000 - 0299. Get-file-name Linux
I guess the first qualification in your path was the data center.
-
Run SQL scripts from a unix directory
DB version: 11.2
Version of the operating system: Solaris 5.10
We have a set of scripts that are used by administrators to display the info of Tablespace free space, file size information... etc.
Currently these .sql files (say free_Space.sql) are stored in the directory/U02/dba_scripts /. To run these scripts a dba can navigate to this directory, and then connect to sql * plus and from there run it as
I recently came across an environment where you can connect to SQL * more than any directory and you can run scripts as above any directory. How is that possible? Should what settings I set for this?SQL > @free_Space.sql
Herbaceous says:
DB version: 11.2
Version of the operating system: Solaris 5.10We have a set of scripts that are used by administrators to display the info of Tablespace free space, file size information... etc.
Currently these .sql files (say free_Space.sql) are stored in the directory/U02/dba_scripts /. To run these scripts a dba can navigate to this directory, and then connect to sql * plus and from there run it as
SQL > @free_Space.sql
I recently came across an environment where you can connect to SQL * more than any directory and you can run scripts as above any directory. How is that possible? Should what settings I set for this?
SQLPATH environment variable
-
Calling batch file. SQL file with parameters
Hi all:
I may / may not have correct code, because I can't find a Google result for answering the question and cannot test this solution until it goes live, so I want to make sure I have it correct.
I have a batch (file1.bat) file that implements some variables. Inside this file, I call a .sql like this procedure:
sqlplus username/password@environment @c:\sql\export.sql cID %%d sID % % exportFilename %
How do I use these settings within the export.sql so they are passed to the oracle procedure?
I am currently using the following code:
BEGIN
sinterface. Export (1, 2 & 3);
EXCEPTION
WHILE OTHERS
THEN NULL;
END;
This code will work? I know that if I call another code file1.bat .bat file, I can get the settings such as:
SET of cID = %1
SET sID = %2
SET exportFileName = %3
OR
SET CompID = compID %
SET SiteID = siteID %
SET exportFileName = % exportFilename %
But I have no idea if / how this translates an oracle .sql file to call a stored procedure. I got a result of Google to show using the & 1 & 2 & 3 to set the parameters of this batch file, but as I can't test it, I have no idea if it would work.
Anyone would be able to confirm the correct method?
Thank you
AndyAndy,
Welcome to the Oracle Forums. Please take a few minutes to review the following:
This forum is for general issues Oracle Forms. Please post your question in the forum SQL and PL/SQL . If you have a general question of forms, by all means, ask it here! ;-)
That said, you asked...
How do I use these settings within the export.sql so they are passed to the oracle procedure?
I am currently using the following code:
BEGIN
sinterface.export(&1, &2, &3);
EXCEPTION
WHEN OTHERS
THEN NULL;
END;
Since you simply call a Script SQL of your batch file file is not really necessary to use an anonymous block to call your stored procedure. In addition, as you use the OTHER generic exception - you never know if there was a mistake. Really, you shouldn't use SO that OTHERS value NULL. This isn't a very good programming practice. As for your variables, I would recommend that you set the substitution variables in your script and set your settings to access these variables. For example:
DEFINE c_id = &1 (CHAR)
DEFINE s_id = &2 (CHAR)
DEFINE f_name = &3 (CHAR)
Execute sinterface.export(c_id, s_id, f_name);
I would not include an exception handler at this level that any exception must propagate to the calling program.
Craig...
Calling shell script program SQL and passing parameters
Hi guys,.Greetings from Toronto. Is it possible to move one or more strings as parameters to a sql from shell script program?
Shell script
# Accept system input parameters
p_user_id=$1
p_job_id=$2
sqlplus.exe -s $p_user_id @$RD_PATH/rd_test.sql $p_user_id $p_job_id
SQL program (rd_test.sql)-- Accept system input parameters
define p_user_id = &1
define p_job_id = &2
-- Wondering if its possible to pass these 3 parameters from a shell script program.
-- (1) rd_test-$p_job_id-3-1.lis
-- (2) RD_PRINTER(rd_test,3)
-- (3) t_data
select
t_data=''rd_test-'||'''$p_job_id'''||'-1-1.txt''
t_data_dir=''.''
ksh $RD_PATH/another_shell_prog.sh $p_user_id $p_job_id '||a.rd_value||' '
||b.rd_value||' rd_test-$p_job_id-3-1.lis $RD_PRINTER(rd_test,3) '||
'$t_data $t_data_dir'||'
exit_status=$?
check_command'
from rd_job_parameter b, rd_job_parameter a
where a.job_id = &2
and a.jp_module_id = 'RDTEST'
and b.job_id = a.job_id
and b.module_id = a.module_id
/
As always, this is not something I have to solve that minute. Any help would be appreciatedand I will think of the problem.
Thank you
REDA
Published by: Raj404261 on June 25, 2009 11:40
Published by: Raj404261 on June 25, 2009 17:29
OK, just a few pointers possible if you need to go the way of shell script.
I suggest that you have a separate SQL script for each of your options, which retains the fairly well-defined lines and keeps the maintenance as simple as possible. Therefore, in your shell script, you can have something like:
#!/bin/ksh
# Accept system input parameters
p_user_id=$1
p_job_id=$2
# Deduce which script you'll call here
# using if statements, or even a case:
if [[ p_job_id -eq 1 ]]
then
SQL_SCRIPT=sql_script1.sql
else
SQL_SCRIPT=sql_script2.sql
fi
# Or using case
case $2
in
1) SQL_SCRIPT=sql_script1.sql;
2) SQL_SCRIPT=sql_script2.sql;
3) SQL_SCRIPT=sql_script3.sql;
*) SQL_SCRIPT=sql_script4.sql;
esac
export ${SQL_SCRIPT}
#If you need to query the database at all to deduce which script to cal
#Then something like this:
SCRIPT_VAR=`sqlplus -s username/password << EOF
set heading off
set feedback off
set verify off
SELECT * FROM DUAL;
EOF`
export {SCRIPT_VAR}
SQL_SCRIPT=sql_script${SCRIPT_VAR}.sql
# Then just call your script:
sqlplus. -s $p_user_id/password @${SQL_SCRIPT}
Hello
I was wondering if you could help me.
I'm trying to find out how to export a .sql file, I created from Oracle Application Express of SQL Server Management 2012? I'm not very technical, but it seems that the Oracle code does not work with SQL Management Studio when I drag the file inside.
I need the database Oracle express and its data to enter in SQL Management Studio, so any help would be much appreciated!
Thank you.
Hello
Your question is beyond the scope of this community.
Please repost your question in the SQL Server TechNet Forums.
https://social.technet.Microsoft.com/forums/SQLServer/en-us/home?category=SQLServer
See you soon.
Maybe you are looking for
-
Installation of the incorrect firmware on 48L1453DN
I update the firmware on my TV with the wrong file (to other model 48l1443dn) and the TV now have the led flashes green and red lights... Its dead...You need the right firmware? How can I unbrick TV? THX
-
I can't seem to be abl to connect to messengr
I can't seem to be abl to connect to messengr... when I try it says I have virefy and I can not find where you don't have that I need help
-
HP Deskjet F4283 does not not on new MacBook Pro
Hello I have a HP Deskjet F4283, I have used successfully and without any problems on my previous MacBook. I have recently replaced the computer with a new MacBook Pro, installed the software of the printer, but for some reason any that it does not w
-
Change windows rename numbering scheme
In most versions of Windows, you can select multiple files in Explorer, right-click, and select Rename. It is a very useful utility; However, I need to change the numbering scheme. The default schema adds (1), etc. until the end of each file name.
-
Replace the comma with a period in a text layer expression
Hello!I need to make a simple counter to 0 billion, so I found this expression that works perfectly:Start codestartTime = 0; secondsendTime = 5; secondsbeginCount = 0;endCount = 9700698977;hasCommas = true;function addCommas (s) {}If (s.length < = 3)