Set named parameter for Oracle dbms_scheduler job stored procedure - stored-procedures

Is it possible to passed named arguments to for dbms_scheduler job with a type 'stored_procedure' ? I've tried this way:
-- 1) example dummy procdure
CREATE OR REPLACE PROCEDURE my_test_proc (
param1 IN NVARCHAR2,
param2 IN NUMBER,
param3 IN NUMBER
) IS
BEGIN
-- ...
END;
-- 2)Example dummy job:
BEGIN
dbms_scheduler.create_job(
job_name => 'my_test_job'
,job_type => 'STORED_PROCEDURE'
,job_action => 'my_test_proc'
,start_date => sysdate
,number_of_arguments => 3
,enabled => FALSE
,auto_drop =>FALSE
);
END;
-- 3)Set named param value:
BEGIN
dbms_scheduler.set_job_argument_value(
job_name => 'my_test_job'
,argument_name => 'param1'
,argument_value => 'some value'
);
END;
I get following error:
ORA
-27484: Argument names are not supported for jobs without a program. ORA-06512: at "SYS.DBMS_ISCHED", line 207 ORA-06512: at
"SYS.DBMS_SCHEDULER", line 602 ORA-06512: at line 2
I successfully set parameter values with set_job_argument_value by using argument_position setting. But there can be cases when I will need to run stored procedures to whom I will need to set only certain parameters and this could not work. Is there a way to pass named argument to stored procedure runed by scheduler job?

as the error states, create a program first, then the job on that.
dbms_scheduler.create_program(program_name => 'YOUR_PROGRAM',
program_type => 'STORED_PROCEDURE',
program_action => 'my_test_proc',
number_of_arguments => 2,
enabled => false,
comments => 'Comments you want');
dbms_scheduler.define_program_argument(program_name => 'YOUR_PROGRAM',
argument_name => 'param1',
argument_position => 1,
argument_type => 'VARCHAR2',
default_value => '');
..etc, do for all 3.
dbms_scheduler.enable (name => 'YOUR_PROGRAM');
dbms_scheduler.create_job(job_name => 'my_test_job',
program_name => 'YOUR_PROGRAM',
start_date => systimestamp,
end_date => null,
...
dbms_scheduler.set_job_argument_value(job_name => 'my_test_job',
argument_position => 1,
argument_value => 'value');
...

I have a basic example for procedure
1.- CREATE MY PROCEDURE
CREATE OR REPLACE PROCEDURE MY_TEST_PROCEDURE (P_VAR1 VARCHAR2, P_VAR_NUMBER NUMBER)
AS
V_RESULT_MSG VARCHAR2(300);
BEGIN
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE,'DD/MM/YYYY HH24:MI'));
V_RESULT_MSG := P_VAR1;
V_RESULT_MSG := V_RESULT_MSG||' '||P_VAR_NUMBER;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(SYSDATE,'DD/MM/YYYY HH24:MI'));
DBMS_OUTPUT.PUT_LINE(V_RESULT_MSG);
END MY_TEST_PROCEDURE;
2.- CREATE PROGRAM
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM(
PROGRAM_NAME => 'MY_TEST_PROGRAM'
,PROGRAM_TYPE => 'STORED_PROCEDURE'
,PROGRAM_ACTION => 'MY_TEST_PROCEDURE'
,NUMBER_OF_ARGUMENTS => 2
,ENABLED => FALSE
,COMMENTS => 'my test program'
);
DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
PROGRAM_NAME => 'MY_TEST_PROGRAM',
argument_name => 'P_VAR1',
argument_position => 1,
argument_type => 'VARCHAR2',
default_value => ''
);
DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT(
PROGRAM_NAME => 'MY_TEST_PROGRAM',
argument_name => 'P_VAR_NUMBER',
argument_position => 2,
argument_type => 'NUMBER',
default_value => ''
);
dbms_scheduler.enable (name => 'MY_TEST_PROGRAM');
END;
3.- CREATE JOB
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => '"XXFLM"."MY_TEST_JOB"',
PROGRAM_NAME => 'MY_TEST_PROGRAM'
);
END;
4.- PL/SQL CODE TEST
DECLARE
V_VAR1 VARCHAR2(50) := 'HOLA';
V_VAR2 NUMBER := 2010;
BEGIN
dbms_scheduler.set_job_argument_value(
job_name => 'MY_TEST_JOB',
argument_position => 1,
argument_value => V_VAR1);
dbms_scheduler.set_job_argument_value(
job_name => 'MY_TEST_JOB',
argument_position => 2,
argument_value => V_VAR2);
DBMS_SCHEDULER.RUN_JOB(
JOB_NAME => '"XXFLM"."MY_TEST_JOB"',
USE_CURRENT_SESSION => FALSE);
END;
5.- RESULT
SELECT * FROM ALL_SCHEDULER_JOB_RUN_DETAILS ORDER BY 1 DESC;

Related

Search list result null prevPageToken

I'm trying to get videos from my channel using search function. Response include only nextPageToken, but no prevPageToken. prevPageToken is null always, even if I'm listing other pages using nextPageToken. I use an access_token param from Google Oauth.
My request:
$searchResponse = $youtube->search->listSearch('snippet', array(
'forMine' => 'true',
'order' => 'date',
'pageToken' => $pageToken,
'type'=>'video',
'maxResults' => '10',
'q' => $searchQuery,
));
Result:
Google_Service_YouTube_SearchListResponse Object
(
[collection_key:protected] => items
[etag] => "XXX"
[eventId] =>
[itemsType:protected] => Google_Service_YouTube_SearchResult
[itemsDataType:protected] => array
[kind] => youtube#searchListResponse
[nextPageToken] => Cib3-ZrgSf____9uWHdEYVNIVnlOVQD_Af_-blh3RGFTSFZ5TlUAARAPIbmtEhE6-iWlOQAAAAC2H2UGSAFQAFoLCdIYcGeU2-YsEAJgyOjNygE=
[pageInfoType:protected] => Google_Service_YouTube_PageInfo
[pageInfoDataType:protected] =>
[prevPageToken] =>
[regionCode] =>
[tokenPaginationType:protected] => Google_Service_YouTube_TokenPagination
[tokenPaginationDataType:protected] =>
[visitorId] =>
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
[pageInfo] => Google_Service_YouTube_PageInfo Object
(
[resultsPerPage] => 5
[totalResults] => 55
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)
Thank you for your ideas!
Petr
UPDATE
This problem is only if is set param forMine. But I need show only my videos...

Yii2 join 6 tables + dropdown filter in grid

I have the following tables/models: A, B, C, BC, D, BCD
(A:B 1:N) Connecting table D to BCD would be no problem. However I would like to filter key attributes as dropdown from A, B, C and D to find results in BCD (because in the end I need BCDid). In BCD next to BCid and Did I can store of course Aid, Bid and Cid, and it would seem to me quite an easy workaround, however I know it's totally against db normalisation. Is there another, better way (with eager loading of course)?
I've now this in BCD:
public function getB() {
return $this->hasOne(\app\models\B::className(), ['id' => 'Bid'])
->via('BC');
}
and it seems to work, but it's not eager loading.
And how do I get to model A? can I define it like this in BCD?:
public function getA() {
return $this->hasOne(\app\models\A::className(), ['id' => 'Aid'])
->via('BC')
->via(B);
}
It doesn't really work yet.
This way it works (BCSearch):
public function search($params) {
$query = BC::find()->joinWith('A', true)->joinWith('C', true);
Relation A in BC defined with "via". Dropdown filter also works.
But I still don't know how to achieve one more level deep into db structure.
This way it seems to work fully:
models/BCDSearch.php
public function search($params) {
$query = BCD::find()
->select([
'BCD.id',
'BCD.amount',
'A.id AS A_Id',
'A.name AS A_name',
'B.name AS B_name',
'B.name2 AS B_name2',
'C.name AS C_name',
'D.name AS D_name',
])
->leftJoin('BC', 'BC.id = BC_Id')
->leftJoin('B', 'B.id = B_Id')
->leftJoin('A', 'A.id = A_Id')
->leftJoin('C', 'C.id = C_Id')
->leftJoin('D', 'D.id = D_Id');
$query->andFilterWhere([
...
'A.id' => $this->A_Id,
'B.name' => $this->B_name,
'B.name2' => $this->B_name2,
'C.name' => $this->C_name,
'D.name' => $this->D_name,
]);
public function rules() {
return [
...
[[... 'A_Id', 'B_name', 'B_name2', 'C_name', 'D_name'], 'safe'],
];
}
models/base/BCD.php:
class BCD extends Whatever {
public $A_Id;
public $A_name;
public $B_name;
public $B_name2;
public $C_name;
public $D_name;
views/BCD/index.php:
GridView::widget([
'layout' => '{summary}{pager}{items}{pager}',
'dataProvider' => $dataProvider,
'pager' => [
'class' => yii\widgets\LinkPager::className(),
'firstPageLabel' => Yii::t('app', 'First'),
'lastPageLabel' => Yii::t('app', 'Last')],
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'A_Id',
'value' => 'A_name',
'filter' => yii\helpers\ArrayHelper::map(app\models\A::find()->all(), 'id', 'name')
],
[
'attribute' => 'B_name',
'value' => 'B_name',
'filter' => yii\helpers\ArrayHelper::map([['id' => 'name1', 'name' => 'name1'], ['id' => 'name2', 'name' => 'name2']], 'id', 'name')
],
[
'attribute' => 'B_name2',
'value' => 'B_name2',
'filter' => yii\helpers\ArrayHelper::map([['id' => 'name2_1', 'name' => 'name2_1'], ['id' => 'name2_2', 'name' => 'name2_2']], 'id', 'name')
],
[
'attribute' => 'C_name',
'value' => 'C_name',
'filter' => yii\helpers\ArrayHelper::map(app\models\C::find()->all(), 'C_name', 'C_name')
],
[
'attribute' => 'D_name',
'value' => 'D_name',
'filter' => yii\helpers\ArrayHelper::map(app\models\D::find()->all(), 'D_name', 'D_name')
],
'amount',
...
hope this helps others. It was not easy to figure out (at least for me) this basically easy solution. I don't know why but so far I couldn't find any relevant info on the web like this.

Ruby inline begin and rescue not performing properly

I have the following code
'Performance' => {
'Date' => performance_values.date.strftime('%m/%d/%Y'),
'Ratio' => begin sprintf("%0.02f", performance_values.ratio) rescue nil end},
'Ratings' => {
'Overall' => performance_values.overall_rating,
'3-yr' => performance_values.3yr_rating}
With 'Ratio' it can sometimes be nil, so I'm trying to begin/rescue out of the sprintf function and just let it be nil.
When this runs and performance_values.ratio is nil, i get the following error message:
TypeError: can't convert nil into Float
Being inline, you don't need to specify begin & end. Rails knows that you are rescuing the whole line.
Try this:
'Performance' => {
'Date' => performance_values.date.strftime('%m/%d/%Y'),
'Ratio' => (sprintf("%0.02f", performance_values.ratio) rescue nil)},
'Ratings' => {
'Overall' => performance_values.overall_rating,
'3-yr' => performance_values.3yr_rating}

how to get value from wsdl returned data in PHP?

Below is the data I'm getting from wsdl response... I need to get the separate value for example how to get the firstname from this array...Please anyone help me...
GetReportResponse Object ( [GetReportResult] => MBPeopleSearchRs_Type Object ( [MsgRsHdr] => MsgRsHdr_Type Object ( [RqUID] => {4DB2AD23-228A-465F-938D-BE072CED61C4} [Status] => Status_Type Object ( [StatusCode] => 0 [ServerStatusCode] => [Severity] => Info [StatusDesc] => OK [AdditionalStatus] => ) ) [Subject] => Subject Object ( [RefNum] => [PersonInfo] => PersonInfo_Type Object ( [PersonName] => PersonName_Type Object ( [LastName] => JANARDHANAN [FirstName] => SENTHINBABU [FullName] => [MiddleName] => [TitlePrefix] => [NameSuffix] => [Nickname] => [LegalName] => [MaidenName] => [OfficialTitle] => [Source] => MB [EffDt] => 2013-05-24 ) [ContactInfo] => ContactInfo_Type Object ( [ContactPref] => [PhoneNum] => [ContactName] => [EmailAddr] => [URL] => [PostAddr] => PostAddr_Type Object ( [PreDirection] => [Addr2] => [PostDirection] => N [Addr3] => [StreetType] => AVE [Addr4] => [StreetName] => LEXINGTON [Apt] => APT 4203 [StreetNum] => 4150 [Addr1] => [City] => SAINT PAUL [StateProv] => MN [PostalCode] => 55126-6131 [County] => RAMSEY
I suggest using a framework for this. CXF is a good choice if you write Java.
http://cxf.apache.org/
edit: since you work with php, take a look here: PHP SOAP client Tutorial/Recommendation?

Column order in propel pager (symfony)

i have this code in executeIndex action:
$pager = new sfPropelPager('News',5);
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn(NewsPeer::ID);
$c->addSelectColumn(NewsPeer::TYTUL);
$c->addSelectColumn(NewsPeer::SLUG);
$c->addSelectColumn(NewsPeer::TEKST);
$c->addSelectColumn(NewsPeer::UTW);
$c->addSelectColumn(NewsPeer::WYSWIETLENIA);
$c->addDescendingOrderByColumn(NewsPeer::UTW);
$pager->setCriteria($c);
$pager->setPage($this->getRequestParameter("p", 1));
$pager->init();
$this->pager=$pager;
as you can see, im selecting 6 columns from 9column table.
When i want to print UTW column in indexSuccess it print nothing. when i do: print_r($news), im getting this:
[id:protected] => 64
[tytul:protected] => Limit
[slug:protected] => limit
[tekst:protected] => text.....
[pelnytekst:protected] => 2011-12-22 08:54:07
[stan:protected] => 42
[utw:protected] =>
[zmi:protected] =>
[wyswietlenia:protected] =>
and it should be:
[id:protected] => 64
[tytul:protected] => Limit
[slug:protected] => limit
[tekst:protected] => text.....
[pelnytekst:protected] =>
[stan:protected] =>
[utw:protected] => 2011-12-22 08:54:07
[zmi:protected] =>
[wyswietlenia:protected] => 42
So, its ok, when i select columns with same order as in table, but when i skip one, values get messed up. How to fix this?
You need to set the PeerMethod to 'doSelectStmt'.
$pager->setCriteria($c);
$pager->setPeerMethod('doSelectStmt'); // add this
$pager->setPage($this->getRequestParameter("p", 1));
$pager->init();
$this->pager=$pager;

Resources