Table for HANA XSJOBS - hana

I am looking for a table in HANA where I can find the XSJOB details such as when was it last run, its status etc. TBTCO is used generally in SAP, but not sure if that's the right table in HANA too.

The XSJOB service uses tables in the _SYS_XS schema:
select * from _SYS_XS.JOBS;
/*
NAME DESCRIPTION ACTION USER LOCALE STATUS START_TIME END_TIME SESSION_TIMEOUT SIGNATURE_VERSION ACTIVATED_BY ACTIVATED_AT CONFIGURED_BY CONFIGURED_AT SCHEMA_NAME
Scheduled_Backup::DataBackup Create data backup of database S20 BACKUP_SCHEDULER_BACKUP_DATA_DEV ? ? INACTIVE ? ? 0 0 ? ? SYSTEM 23/10/2018 1:09:58.915 AM ?
Scheduled_Backup_Retention::DeleteBackups Delete backups of database S20 BACKUP_RETENTION_DELETE_BACKUPS_DEV ? ? INACTIVE ? ? 0 0 ? ? SYSTEM 23/10/2018 1:09:58.95 AM ?
sap.hana.xs.admin.webdispatcher.server.jobs::httpTracing Enable HTTP Tracing sap.hana.xs.admin.webdispatcher.server.jobs:callTracingProcedure.xsjs::callTracingProcedure ? ? INACTIVE ? ? 0 0 ? ? ? ? ?
sap.hana.xs.admin.jobs.server.common::cleanJobLog Sweep old entries from _SYS_XS.JOB_LOG sap.hana.xs.admin.jobs.server.common:cleanJobLog.xsjs::clean ? ? INACTIVE ? ? 0 0 ? ? ? ? ?
*/
select * from _SYS_XS.JOB_SCHEDULES;
/*
ID JOB_NAME XSCRON DESCRIPTION PARAMETER ORIGIN STATUS CHANGED_BY CHANGED_AT
7 sap.hana.xs.admin.webdispatcher.server.jobs::httpTracing * * * * 23 59 * SAP Web Dispatcher HTTP Tracing Job ? DESIGNTIME ACTIVE ? ?
8 sap.hana.xs.admin.jobs.server.common::cleanJobLog * * * * 0 0 0 Clean up schedule for sap.hana.xs.admin.jobs.server.common::cleanJobLog {"day":1,"jobName":"sap.hana.xs.admin.jobs.server.common::cleanJobLog"} DESIGNTIME ACTIVE ? ?
*/
select * from _SYS_XS.JOB_LOG;
/* no example for this - check your own system*/

Related

Is there a way to return the currently logged on ID from Netezza in a view's SQL, current_sid

I have a SQL statement on Netezza that uses the following SQL to acquire the currently logged on user ID:
SELECT SESSION_USERNAME FROM _V_SESSION_DETAIL WHERE SESSION_ID=current_sid
This works great when I'm executing the SQL in a database client. However, when I implement the above SQL in a view (along with other SQL) the current_sid is replaced with the session ID I happened to have when I created the view. That SQL will then look something like:
SELECT DEFINITION_SCHEMA."_V_SESSION_DETAIL".SESSION_USERNAME FROM DEFINITION_SCHEMA."_V_SESSION_DETAIL" WHERE (DEFINITION_SCHEMA."_V_SESSION_DETAIL".SESSION_ID = 2434740
Is there a way to define a view that will get the currently logged on user's ID, not the ID that was assigned when the view was created?
Seems like Netezza Metadata functions(ex. current_sid) are not supported in with clause and would advice to remove them from with and to include them in the base query .
CREATE
OR REPLACE VIEW ADMIN.VW_PI_HRCHY_EPH AS
WITH CHAR_MASK(CHAR_MASK_CHAR) AS (
SELECT 'xxx'
FROM _V_SESSION_DETAIL LIMIT 1
)
,NUM_MASK(NUM_MASK_NUM) AS (
SELECT - 1
FROM _V_SESSION_DETAIL LIMIT 1
)
,TS_MASK(TS_MASK_TS) AS (
SELECT '1000-01-01 00:00:00'
FROM _V_SESSION_DETAIL LIMIT 1
)
SELECT CASE
WHEN SECURITY_GRP_CNT.COUNT > 0
THEN PI_HRCHY.HRCHY_LINE_ID
ELSE NUM_MASK.NUM_MASK_NUM
END AS HRCHY_LINE_ID
,CASE
WHEN SECURITY_GRP_CNT.COUNT > 0
THEN PI_HRCHY.LOCALE_CD
ELSE CHAR_MASK.CHAR_MASK_CHAR
END AS LOCALE_CD
,CASE
WHEN SECURITY_GRP_CNT.COUNT > 0
THEN PI_HRCHY.MODIFY_TS
ELSE TS_MASK.TS_MASK_TS
END AS MODIFY_TS
FROM (
SELECT COUNT(*) AS count
FROM _V_USERGROUPS
WHERE USERNAME IN (
SELECT SESSION_USERNAME
FROM _V_SESSION_DETAIL
WHERE SESSION_ID = current_sid
)
AND GROUPNAME = 'GROUP_AUTH2READ'
) SECURITY_GRP_CNT
,ADMIN.PI_HRCHY
,CHAR_MASK
,NUM_MASK
,TS_MASK
WHERE (
(PI_HRCHY.HRCHY_TYP_ID = 11)
AND (PI_HRCHY.ACTV_IND = 'Y'::"NCHAR")
);
The solution NzGuy provided solved my problem. As he stated, apparently placing the current_sid contact in the WITH clause of the SQL causes the constant to be evaluated differently than if it were placed outside the WITH. The common table expression defined outside the WITH clause resolved my problem.

Why do I keep getting NULL results?

For some reason I keep getting NULL results included in my data. It has been narrowed down to a section of the script:
Goods_In
LOAD
WEL_ORIG &'/' & WEL_EINGANG AS GI_Number,
WEL_RECHNUNG AS SI_Fut_Invoice_No;
SQL
SELECT *
FROM CONFUTHO.dbo.V_WE_LINK
WHERE WEL_RECHNUNG > 133695 and WEL_RECHNUNG is NOT NULL;
And a small section of the results are as follows;
SI_Fut_Invoice_No GI_Number
67715
67716
67717
67718
67719
67720
67721
144608 1/247336
144605 1/247337
144606 1/247338
144604 1/247339
144607 1/247340
145611 1/247341
149074 1/247341
144816 1/247342
As you can see I am still getting GI_Numbers with NULL WEL_ORIG and WEL_RECHNUNG. I am relatively new to Qlikview, do they have an alternative for NOT NULL?
A possible solution could be :
LET inacceptable_value = -1 ;
Goods_In :
NoConcatenate
LOAD
*
WHERE GI_Number <> '$(inacceptable_value)' ;
LOAD
alt( WEL_ORIG &'/' & WEL_EINGANG , '$(inacceptable_value)' )
AS GI_Number ,
WEL_RECHNUNG AS SI_Fut_Invoice_No
;

SSIS expression similar to case statement

I need to write an expression for derived column. My column name is 'status'. what is the equivalent expression in SSIS for the below condition?
Case when Status Like '%Open%' then 0
when Status like '%Won%' then 1
when status like "%Lost%' then 2 Else 3
Thanks in advance
Give this a shot:
FINDSTRING(Status,"Open",1) > 0 ? 0 : (FINDSTRING(Status,"Won",1) > 0 ? 1 : (FINDSTRING(Status,"Lost",1) > 0 ? 2 : 3))

SQL statement to list all of the current database properties

I have tried a few different ways to list the db properties and have come up short.
SQL> SHOW DATABASE VERBOSE emp;
SP2-0158: unknown SHOW option "DATABASE"
SP2-0158: unknown SHOW option "VERBOSE"
SP2-0158: unknown SHOW option "emp"
Heres another that I dont understand why its not working
SQL> show database;
SP2-0158: unknown SHOW option "database"
SQL> DGMGRL
SP2-0042: unknown command "DGMGRL" - rest of line ignored.
Does anyone have ideas as to what I am missing.
There's a table called database_properties - you should query that
select property_name, property_value, description from database_properties
If this isn't what you're looking for, you should be more specific
If you wan the full version information for your DB then:
SELECT *
FROM v$version;
If you want your DB parameters then:
SELECT *
FROM v$parameter;
If you want more information about your DB instance then:
SELECT *
FROM v$database;
If you want the database properties then:
SELECT *
FROM database_properties;
If you want the "size" of your database then this will give you a close enough calculation:
SELECT SUM(bytes / (1024*1024)) "DB Size in MB"
FROM dba_data_files;
You will need DBA level permissions to see these views or you could request the data from your DBA and he will (probably) oblige.
Hope it helps...
SHOW DATABASE is not a valid SQL*Plus command.
The correct syntax is SHOW option where option is one of:
system_variable ALL BTI[TLE]ERR[ORS] [ { FUNCTION | PROCEDURE | PACKAGE |
PACKAGE BODY | TRIGGER | VIEW | TYPE | TYPE BODY | DIMENSION | JAVA CLASS }
[schema.]name] LNO PARAMETERS [parameter_name] PNO RECYC[LEBIN] [original_name]
REL[EASE] REPF[OOTER] REPH[EADER] SGA SPOO[L] SPPARAMETERS [parameter_name
SQLCODE TTI[TLE] USER XQUERY

Can you optimize this SQL query for me?

I'm running this query in 2 mysql_query calls. I would like to do the most performant thing and run it in one query. Can anyone optimize this for me:
if(mysql_num_rows(eq("select *
from player_data
where uid = $uid")) == 0 )
eq("update player_data
set uid = $uid,
`stat`= REPLACE(`stat`, '$temp_uid', '$uid')
where uid = $temp_uid");
Note: eq is just a wrapper function for mysql_query
You could try:
eq("update player_data
set uid = $uid,
`stat`=REPLACE(`stat`, '$temp_uid', '$uid')
where uid=$temp_uid
and not exists (select *
from player_data
where uid = $uid)");
if(mysql_num_rows(eq("select 1 from player_data where uid=$uid")) == 0 )
eq("update player_data set uid=$uid, `stat`=REPLACE(`stat`, '$temp_uid', '$uid') where uid=$temp_uid");
Avoid select * if you just want to get the count of rows in the table.
Will A's answer is very good, and if you do need to select a field specify it. Selecting everything is terrible for performance.