Using &variables in a SQL Script scheduled job within OEM
Hi...I've been searching through the forum looking for any examples of setting up a job within OEM, using the SQL Script job type, where I can basically use a WHERE clause that says 'where column_name = &variable_name' and somehow provide that at run time, as if I were in a SQL*Plus session and using a PROMPT and ACCEPT command. I thought there might be a way to emulate that situation by placing the value I'd like to qualify on within some placeholder in the Parameter section of the job. We have a few users who have limited access to OEM and need to run queries on GRANTS and ROLES for various users etc. I realize there are other ways to do this, however I'm wondering if OEM has a capability like this. Any info is appreciated! Tks!
Looks like you're missing the schema name and you'll want to use QUOTENAME to add delimiters to the objects
e.g.
DECLARE @DATABASE AS VARCHAR(50)
DECLARE @SchemaName as SYSNAME;
DECLARE @TABLE AS VARCHAR(50)
DECLARE @QUERY AS VARCHAR(MAX)
SELECT @DATABASE = '602'
SELECT @SchemaName = 'dbo' --change as appropriate
SELECT @TABLE = 'Items'
SET @QUERY = 'SELECT TOP 10 * FROM ' + QUOTENAME(@DATABASE)+'.' + QUOTENAME(@SchemaName) + '.'+QUOTENAME(@TABLE)
print @query
EXEC( @QUERY)
Similar Messages
-
Passing variables to a SQL script within GC
Does anyone know if it is possible to pass in a variable to a SQL script job within Grid Control? I don't see that I can but I wanted to ask a larger group before cloing the loop on this.
For example, I have a few different databases which contain schemas which contain date-range daily partitioned tables. I have a single code block which normally accepts the table_owner as a variable then loops through to analyze the current day partition. I'd love for OEM to be able to have the job submitted to different database targets whilst passing in a different schema name.
Thank you in advance!This can be done in two steps, but first create a table containing 1 field in all the target databases (something like table_owner) you want to analyze. Before running the analyze script change in all the to be analyzed databases the table_owner (as a job?). Then run the analyze script that contains a statement that first reads the table_owner and use this table_owner as the variable you want.
Even more simple would be to use a database link from the to be analyzed db's to a central db so you only have to change the table_owner in one table.
Eric -
How to define variables in toad sql script editor - newbie
I have just pull out the script of a Function and want to run it on toad SQL editor.
I am little bit confused how to define the VARIABLEs here in toad SQL editor to run my script.
SELECT
NVL(SUM(debit), 0) - NVL(SUM(credit), 0)
INTO l_accountBalance
FROM
GLP_VoucherMaster vm
INNER JOIN GLP_VoucherDetail vd ON vm.GLP_VoucherMaster_ID = vd.GLP_VoucherMaster_ID
INNER JOIN GLP_ChartOFAccounts coa ON vd.GLP_ChartOfAccounts_ID = coa.GLP_ChartOfAccounts_ID
WHERE
vm.isActive = 'Y' AND vd.isActive = 'Y'
-- *** how to define variables in toad sql script editor ***
AND vm.voucherDate < p_cDate
AND coa.AccountCode LIKE p_accountCode || '%';
Thanks
w\Just prefix with a colon (:)
SELECT NVL (SUM (Debit), 0) - NVL (SUM (Credit), 0)
INTO L_accountbalance
FROM Glp_vouchermaster Vm
INNER JOIN
Glp_voucherdetail Vd
ON Vm.Glp_vouchermaster_id = Vd.Glp_vouchermaster_id
INNER JOIN
Glp_chartofaccounts Coa
ON Vd.Glp_chartofaccounts_id = Coa.Glp_chartofaccounts_id
WHERE Vm.Isactive = 'Y'
AND Vd.Isactive = 'Y'
AND Vm.Voucherdate < :P_cdate
AND Coa.Accountcode LIKE :P_accountcode || '%';
/:p -
[DW 8.02 + PHP] how to use variables in advanced SQL queries
Hi all,
I can't find a way to use variables in an SQL query after
updating
dreamweaver 8.02.
I always get error messages that says: 'missing variable
type:myvariablename', undefined#myvariablename... and so on.
What is the correct way to use variables?
I usually set a variable in a PHP statement (example: <?
$today=date('Y-m-d'); ?>)
and then I compare this variable in the SQL query.
What is the correct syntax for variable in DW 8.02 in
advanced SQL
queries?
TIA
tonysweetman wrote:
> I'm editing a website created with DW 8.01 and MX
Kollection.
>
> I updated DW to 8.02 and now I can't edit an existing
SQL query.
> I always get an error message 'Missing variable type'
and I can't go
> on.
InterAKT released a new version of Kollection to cope with
the 8.0.2
changes. AFAIK, you should be able to download the updated
version from
your InterAKT account area.
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/ -
Which are the required roles/privs for viewing all scheduler jobs in OEM?
Platform: Oracle 11.1.0.6 Enterprise Edition (64) Windows 2008 R2 Server
- I've created a new Admin user in "OEM>Setup>Adminstrators>Create"
- I checked the user in "OEM>Server>Users":
CREATE USER "SA_ADMIN"
PROFILE "DEFAULT"
INDENTIFIED BY "saadminsa"
DEFAULT TABLESPACE "SYSAUX"
TEMPORARY TABLESPACE "TEMP"
ACCOUNT UNLOCK;
GRANT SELECT ANY DICTIONARY TO "SA_ADMIN";
GRANT "MGMT_USER" TO "SA_ADMIN"
- "SA_ADMIN" was granted only the permissions above.
- I can log in OEM as "SA_ADMIN"
- I can see OEM backup jobs and the history
- But I cannot see any "scheduler" jobs in "OEM>Server>Jobs"
- I get a lists of the jobs in "OEM>Scheduler Central" but I cannot display any more information of "scheduler jobs"
- I logged off from OEM
- I granted SCHEDULER_ADMIN role to "SA_ADMIN"
GRANT SCHEDULER_ADMIN TO "SA_ADMIN";
- I logged back in OEM as "SA_ADMIN
- I can now see some scheduler jobs, but not all of the jobs, I still cannot see any of the new jobs I created logged in OEM as SYS.
Which are the required roles/privs for viewing all scheduler jobs in OEM?if you grant "SYSDBA" to the new Admin user then you can see the "scheduler" jobs.
GRANT SYSDBA TO "SA_ADMIN";
I wanted to grant "read" access in OEM for the new user.
This behaviour is strange.
Without the "SYSDBA" role the new user can see the OEM backup jobs that were create in as SYS, but it cannot see the "scheduler" jobs. -
Required roles/privs for viewing all scheduler jobs in OEM 10g
Hello,
I would like to know wchich role/priv schould have user to view all scheduler jobs
in OEM console 10g. My user can see only few jobs in Scheduler jobs part of OEM 10g. User sys see all scheduler jobs.
Thank you for replyHi,
If this is a highly privileged user you can consider the CREATE ANY JOB privilege. But this privilege allows a user to run code as any other user so it should only be granted very carefully.
A user can also view any job he is granted ALTER privileges on directly.
Hope this helps,
Ravi. -
Hi everyone,
i made a PL/SQL block and scheduled as a job of "SQL script" type.
Inside my code i trigger an exception (raise_application_error)
when i run the job i can see this error in the execution details, but the job is marked as Succeded.
Instead I wish to be warn when such a case happen. This check was supposed to raise a critical state and follow the notification flow.
Anyone knows I to do that?
ThanksHi,
It sounds like you are using the Grid Control Scheduler not the Oracle Database Scheduler dbms_scheduler.
If your job does not show up in dba_scheduler_jobs then you are using the Grid Control scheduler and you should post this on the Grid Control Forum.
If your job does show up in dba_scheduler jobs then you should post the code being used to create the job (by clicking show sql) and the relevant rows from dba_scheduler_jobs and dba_scheduler_job_run_details.
Hope this helps,
Ravi. -
ORA-27369 Exit-Code: 255 when executing sql script as job
Dear all
I'd like to find and compile all invalid objects in an instance. This should be done every day as a scheduled job with the use of DBMS_SCHEDULER.
For this, I set up the following sql-script:
---------start script--------------
set heading off;
set feedback off;
set echo off;
Set lines 999;
Spool /tmp/run_invalid.sql
select
'ALTER ' || OBJECT_TYPE || ' ' ||
OWNER || '.' || OBJECT_NAME || ' COMPILE;'
from
dba_objects
where
status = 'INVALID'
spool off;
set heading on;
set feedback on;
set echo on;
@/tmp/run_invalid.sql
exit
------ end script ----
The script ist working well when executed manualy via sqlplus. As you can see, it spools the commands to a second file (run_invalid.sql) which is the beeing executed to compile the invalid objects found.
I now want to schedule this script via DBMS_SCHEDULER (running the job every day at 7AM). Creation of the job:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'compile_invalid_objects',
job_type => 'EXECUTABLE',
job_action => '/home/oracle/scripts/sql/compile_invalid_objects.sql',
start_date => trunc(sysdate)+1+7/24,
repeat_interval => 'trunc(sysdate)+1+7/24',
enabled => TRUE,
comments => 'SQL-Script, und invalid objects zu finden und zu kompilieren'
END;
Manualy execute and error message:
BEGIN
DBMS_SCHEDULER.RUN_JOB (job_name => 'compile_invalid_objects',
use_current_session => true);
END;
FEHLER in Zeile 1:
ORA-27369: Job vom Typ EXECUTABLE nicht erfolgreich mit Exit-Code: 255
ORA-06512: in "SYS.DBMS_ISCHED", Zeile 150
ORA-06512: in "SYS.DBMS_SCHEDULER", Zeile 441
ORA-06512: in Zeile 2
--> Sorry for this, I'm using german localized oracle.
Unfortunately, it seems that only Shell-Scripts can be scheduled when using job_type='EXECUTABLE'. Can you confirm this?
BTW: The script is chmoded to 777, therefore it can't be a permission problem.
Is there maybe another solution with one single script using dbms_output functionality and run the script in a loop?
To complete my post, here are the commands used to create and test the job:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'compile_invalid_objects',
job_type => 'EXECUTABLE',
job_action => '/tmp/compile_invalid_objects.sql',
start_date => trunc(sysdate)+1+7/24,
repeat_interval => 'trunc(sysdate)+1+7/24',
enabled => TRUE,
comments => 'SQL-Script, und invalid objects zu finden und kompilieren'
END;
Thanks for your help
CasiYou could more simply use $ORACLE_HOME/dbms/admin/utlrp.sql
-
How to use parameters in oracle SQL script????
Right now I am writing a SQL script to create a schema and build the objects of this schema....
I use a .net winform program to run sqlplus to parse this sql script ...
The problem is that the schema name and the tablespace's location and the sys password must be input by the user, so my SQL script should use these runtime input parameters instead of const parameters....
So, how to use parameter in SQL script ...........
Are there some example scripts in oracle home directory for me to refer to????Hi,
UNISTD wrote:
thanks .....
what's the difference between variable , define, accept in sqlplus ???VARIABLE declares (but does not assign a value to) a bind variable. Unlike substitution variables, bind variables are passed to the back end to be compiled, and they can only be values in certain data types. You can not use a bind vaiable in place of an identifier, so to do something like
CREATE USER &1 ...a bind variable won't work.
"DEFINE x = y" sets the substitution variable &x to have the value y. There is no user interaction (unless x or y happen to contain undefined substtiution variables).
"DEFINE x" shiows the value of the substitution variable &x, or, if it is undefined, raises a SQL*Plus error. I use this feature below.
ACCEPT sets a substitution variable with user interaction.
And if the user miss some parameters in “sqlplus /nolog ssss.sql par1 par2 par5 par6”, how to use default value of the miss parameters??Don't you need a @ befiore the script name, e.g.
sqlplus /nolog @ssss.sql par1 par2 par5 par6Sorry, I don't know of any good way to use default values.
The foloowing works, but, as you can see, it's ugly.
"DEFINE 1" display a message like
DEFINE 1 = "par1" (CHAR)if &1 is defined; otherwise,it will display a SQL*Plus error message like
SP2-035: symbol 1 is UNDEFINEDNotice that the former contains an '=' sign, but the latter does not.
The best way I know to use default values is to run the DEFINE command, save the output to a filee, read the file, and see if it's an error message or not.
So you can use a script like this:
-- This is DEFINE_DEFAULT.SQL
SPOOL got_define_txt.sql
DEFINE &dd_old
SPOOL OFF
COLUMN dd_new_col NEW_VALUE &dd_new
WITH got_define_txt AS
SELECT q'[
@got_define_txt
]' AS define_txt
FROM dual
SELECT CASE
WHEN define_txt LIKE '%=%'
THEN REGEXP_REPLACE ( define_txt
, '.+"
([^"]*)
, '\1'
ELSE '&dd_default'
END AS dd_new_col
FROM got_define_txt
{code}
and start your real script, ssss.sql, something like this:
{code}
DEFINE dd_new = sv1
DEFINE dd_old = 1
DEFINE dd_default = FOO
@DEFINE_DEFAULT
DEFINE dd_new = sv2
DEFINE dd_old = 2
DEFINE dd_default = "Testing spaces in value"
@DEFINE_DEFAULT
{code}
when this finishes running, the substitution variable &sv1 will either have the value you passed in &1 or, if you didn't pass anything, the default value you specified, that is FOO.
Likewise, &sw2 will have the value you passed, or, if you didn't pass anything, the 23-character string 'Testing spaces in value'.
Here's how it works:
Define_default.sql puts the output of the "DEFINE x" command into a column, define_txt, in a query. That query displays either the existing value of the substitution variable indicated by &dd_old or, if it is undefined, the default value you want to use, which is stored in the substitution variable &dd_default. The substitution variable named in &dd_new is always set to something, but that something may be its existing value.
Notice that the paramerters to define_default.sql must be passed as global varibales.
Why didn't I just use arguments, so that we could simply say:
{code}
@DEFINE_DEFAULT sv1 1 FOO
{code}
? Because that would set the substitution variables &1, &2 and &3, which are miost likely the very ones in which you're interested.
I repeat: there must be a better way, but I'm sorry, I don't know what it is.
I usually don't do the method above. Instead, I always pass the required number of parameters, but I pass dummy or plce-holder values.
For example, if I wanted to call ssss.sql, but use defulat vlaues for &1 and &3, then I would say something like:
{code}
@ssss ? par2 ?
{code}
and, inside ssss.sql, test to see if the values are the place holder '?', and, if so, replace them with some real default value. The use has to remember what the special place holder-value is, but does not need to know anything more, and only ssss.sql itself needs to change if the default values change. -
Hi Team,
I am running a sql server job which is loading data to a sharepoint document library.File is an excel format and is getting loaded
when executed through SSDT solution .But when i am using an SQL Agent job to pick up the file it doesnt get the path and agent job fails with the error "Failed to acquire connection".I have deployed the SSIS Package through SQL Server 2012 deployment
methodologies.
I am not able to trace the error of loading data from a sharepoint library.library. Sql agent jobs works fine when i give local path.The
account which is running the sql agent job is the same who has access to document library.I also tried to run the job through proxy account. I am using a xml configuraion to store my credentials.I am able to palce the same file to a network drive in the same
server through sql server agent job. The only problem is when I am trying to load the file to a sharepoint folder.
Thanks,
Arsa..Is that the WebDAV method that you are suggesting here to map the n/w drive?
Its kind of webdav but you will be using windows nw drive to store data
yes, I am able to create the file to D: , but didn't check with the C:.
Try with c:, as c: require special permisssions
If this helped you resolve your issue, please mark it Answered -
Does anyone use OEM to monitor the success or failure of Scheduled Jobs?
Can somebody point me in the right direction, either documentation or how you do this at your place of work.
Documentation out there seems to be a little scarce with regards to this.
Thanks!I should make myself a little clearer. I would like a job failure to automatically notify me - whether by email or any other means.
The small bit of documentation that I find is in the OEM Advanced Configuratin Guide (B16242-01) section: 12.4 Passing Job Execution Status Information
Thanks. -
Using variables defined in another script
hallo
i have two separate scripts trigered by two unique shortcuts:
lets say first SCRIPT_1 takes a color (or any other property) of currentlly selected object and saves it in a variable "objCOLOR"
than i work on something else for a while or select different objects and eventually run SCRIPT_2 where id like to use value "objCOLOR" which i defined a while ago using SCRIPT_1
is it possible to define variables in one script and after a while use them in another script ? some kind of SUPER GLOBAL variables stored in memory of InDesign ? available to be used by various scripts ?I'm not JS man - but you can do this other way - use InsertLabel and ExtractLabel
description from VB:
Sub InsertLabel(Key As String, Value As String)
Member of InDesign.Document
Sets the label to the value associated with the specified key. / Key: The key. / Value: The value.
Function ExtractLabel(Key As String) As String
Member of InDesign.Document
Gets the label value associated with the specified key. / Return value: The label. / Key: The key.
example in VB:
first script:
myDoc.InsertLabel("objCOLOR","0,120,24,0")
second script:
myColor = myDoc.ExtractLabel("objCOLOR")
I don't know if you can save color value directly ...
I'm not sure - but you can use .InsertLabel and .ExtractLabel with all objects in InDesign
robin
www.adobescripts.com -
Using Variables in a SQL Statement
I know, I know, this is written in VB..I'm doing a VB Project right now for my Instructor (While in an Intermediate Java Class)
But VB (I feel) doesnt have very good support Forums.
Anyway, this is the problem:
I want to use String Variables to hold the place of field names in
a SQL Statement and the change the ORDER according to intCount's Loop:
The key word(s) here is "ORDER BY"
Private Sub DataGrid1_Click()
Dim intCount As Integer
Dim strColHead(11) As String
strColHead(0) = "RES__PUR_DT"
strColHead(1) = "VENDOR"
strColHead(2) = "VEN_LOC"
strColHead(3) = "RES_TYPE"
strColHead(4) = "RES_FROM_DT"
strColHead(5) = "RES_TO_DT"
strColHead(6) = "MISC_ADJ"
strColHead(7) = "STATE_TAX"
strColHead(8) = "LOC_CHARGE"
strColHead(9) = "RES_ID"
strColHead(10) = "RES_OP"
For intCount = 0 To 10
If DataGrid1.SelStartCol = intCount Then
Adodc1.RecordSource = "Select * from tblReservation order by 'strColHead(intCount)'"
End If
Adodc1.Refresh
Next intCount
End SubI'm just wondering if anyone knows a work around so that I might be able to store a Table's FIELD name in a variable or an array[] so that I can do a query based on the decision of a loop without having to code 10 IF/ELSE statements.For instance, although the above code will not work, this code, although quite lengthy, does:
If DataGrid1.SelStartCol = 0 Then
Adodc1.RecordSource = "Select * from tblReservation order by RES__PUR_DT"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 1 Then
Adodc1.RecordSource = "Select * from tblReservation order by VENDOR"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 2 Then
Adodc1.RecordSource = "Select * from tblReservation order by VEN_LOC"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 3 Then
Adodc1.RecordSource = "Select * from tblReservation order by RES_TYPE"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 4 Then
Adodc1.RecordSource = "Select * from tblReservation order by RES_FROM_DT"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 5 Then
Adodc1.RecordSource = "Select * from tblReservation order by RES_TO_DT"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 6 Then
Adodc1.RecordSource = "Select * from tblReservation order by MISC_ADJ"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 7 Then
Adodc1.RecordSource = "Select * from tblReservation order by STATE_TAX"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 8 Then
Adodc1.RecordSource = "Select * from tblReservation order by LOC_CHARGE"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 9 Then
Adodc1.RecordSource = "Select * from tblReservation order by RES_ID"
Adodc1.Refresh
ElseIf DataGrid1.SelStartCol = 10 Then
Adodc1.RecordSource = "Select * from tblReservation order by RES_OP"
Adodc1.Refresh
End If
Do you see where i'm going with this?
I simple want to use a variable in the "select * from <Table> Order by <Field>" -
How to use variables in an sql select statement.
Hi, I have seen examples using the update, but nothing using a select statement.
I have four variables I am getting from drop down menus in my JSP I set the user selected items to strings.
How would I create the select statement like this:
.String XName = request.getParameter("UserInputX");
rsInResult = stmtInResult.executeQuery("SELECT ColumxX FROM TableZ WHERE ColumnX = XName")Obviously it tries to read "XName" as a column and of course can't find it, how would I set it up to have it see the Value of XName and not the literal XName.read this:
rsInResult = stmtInResult.executeQuery("SELECT ColumxX FROM TableZ WHERE ColumnX = '"+XName+"')
{code}
better way is PreparedStatement:
{code}
// example code to change password to an user in the USERS table
String newPWD = "my password";
String user = "luxjava";
PreparedStatement prepStat;
String updatePWD = "UPDATE LOGISTIC.USERS "+
"SET logistic.users.password = ? "+
"WHERE logistic.users.username = ?";
prepStat = ql.conDb.prepareStatement(updatePWD);
prepStat.setString(1, newPwd);
prepStat.setString(2, user);
int zeroNotFound = prepStat.executeUpdate();
if (zeroNotFound==0)
ql.conDb.rollback();
prepStat.close();
else
ql.conDb.commit();
prepStat.close();
{code}
... use the SQLException to capture errors -
Using variables in the SQL Results in Dashboard Prompt
I use the ff query to limit my results on my dashboard prompt. The variable value is given by a dashboard prompt within the same page.
SELECT Owner.Name saw_0 FROM "iSupport Service Request" WHERE "- Service Request Attributes".Platform =
'@{promptedPlatform}' ORDER BY saw_0
It works fine with this query, only when selecting a particular selection in the prompt that feeds the variable data. Is there anyway to have this particular prompt by default(when the page first loads, load all the values possible prior to filtering by the variable?Hi Harley ,
The frame labels are 1,2,3 etc
sym.setVariable("subselect" , 0); // in the stage composition ready
Then in the menu you can set the "subselect" variable to 1,2,3 and then call sym.play(sym.getVariable("subselect"));
Thanks and Regards,
Sudeshna Sarkar
Maybe you are looking for
-
Switch between transient and persistent objects?
Hi Folks, I'm Re: transient object to persistent to ask this type of question, but couldn't find an answer. Using persistent classes, does anyone know an elegant way to convert a transient object to a persistent one and vice versa? There is no standa
-
In 10g ( 10.1.4.3)OID, what are the base tables
Hi ,I need to clean the users and groups from the OID manually ( i have deleted them using bulkload but oid tree is inconsistent stage) so now i have to clean them from the base tables, anyone faced this situation before, appreciate your help.
-
Dynamic calc member formula problem
Hello Gurús! We are using a member called "Full Year" that is a Dynamic calc with a member formula that calls another dynamic calc. For any reason, it is not working when we try to retrieve it from Excel Add-in. Any ideas? Any problem for put a Dynam
-
Java 2 SDK on Red Hat 8.0
I downloaded and installed Java 2 SDK 1.4.0 on my RH box. when I try to run java or javac I get the following message: libjava.so not found Cannot Find JRE How can I correct this?
-
Time Capsule vs NAS attached to AEn
This may be a hard one to answer without having the product but can anyone weigh in on whether using the Time Capsule drive would have faster access times than say a Lacie network drive attached to Airport Extreme N? Reason is that keeping our photo