我想在javascript过程本身中访问Snowflake中当前正在执行的过程的名称,并将其存储在变量中。
当我询问“ this”对象时,我可以在Variant返回中看到名称,但是就JSON而言,我相信它是名称而不是值,而且我不确定如何在JSON中检索名字对象。
我需要使用什么代码来获取过程名称?
procName = ???此对象在这里带什么代码???;
我们知道“ this”中的名字/值对始终是过程名称吗?
CREATE OR REPLACE PROCEDURE EDW_ADMIN.DAG_TEST()
RETURNS VARIANT
LANGUAGE JAVASCRIPT
AS
$$
var procName = "";
// procName = this.??? WHAT DO I PUT HERE ???
return this;
$$
;
“ this”的返回/内容为:
{
"DAG_TEST": {},
"ResultSet": {},
"SfTimestamp": {},
"Snowflake": {},
"Statement": {},
"Status": {
"EOF": "eof",
"ERROR": "error",
"INITIALIZED": "initialized",
"SUCCESS": "success"
},
"_c_snowflake": {
"createExecError": {},
"createStatement": {}
},
"createError": {},
"extractValue": {},
"getColSqlTypeFromIdx": {},
"nativeTypes": {
"values": {
"BOOLEAN": "boolean",
"BUFFER": "buffer",
"DATE": "date",
"INVALID": "invalid",
"JSON": "json",
"NUMBER": "number",
"STRING": "string"
}
},
"noSuchColumnIdxErrorMessage": "Given column name/index does not exist: ",
"snowflake": {
"createStatement": {},
"execute": {}
},
"sqlTypeFromLibSfDbTypeVal": {},
"sqlTypes": {
"isArray": {},
"isBinary": {},
"isBoolean": {},
"isDate": {},
"isNumber": {},
"isObject": {},
"isText": {},
"isTime": {},
"isTimestamp": {},
"isTimestampLtz": {},
"isTimestampNtz": {},
"isTimestampTz": {},
"isVariant": {},
"values": {
"ARRAY": {
"libSfDbType": 9,
"name": "ARRAY"
},
"BINARY": {
"libSfDbType": 10,
"name": "BINARY"
},
"BOOLEAN": {
"libSfDbType": 12,
"name": "BOOLEAN"
},
"DATE": {
"libSfDbType": 3,
"name": "DATE"
},
"FIXED": {
"libSfDbType": 0,
"name": "FIXED"
},
"INVALID_SQL_TYPE": {
"libSfDbType": -1,
"name": "INVALID_SQL_TYPE"
},
"OBJECT": {
"libSfDbType": 8,
"name": "OBJECT"
},
"REAL": {
"libSfDbType": 1,
"name": "REAL"
},
"TEXT": {
"libSfDbType": 2,
"name": "TEXT"
},
"TIME": {
"libSfDbType": 11,
"name": "TIME"
},
"TIMESTAMP_LTZ": {
"libSfDbType": 4,
"name": "TIMESTAMP_LTZ"
},
"TIMESTAMP_NTZ": {
"libSfDbType": 5,
"name": "TIMESTAMP_NTZ"
},
"TIMESTAMP_TZ": {
"libSfDbType": 6,
"name": "TIMESTAMP_TZ"
},
"VARIANT": {
"libSfDbType": 7,
"name": "VARIANT"
}
}
},
"testFunc": {},
"typeFromLibSfDbTypeVal": {},
"validateBinds": {},
"validateColumnExists": {}
}
答案 0 :(得分:1)
在您的proc中尝试一下:
const procName = Object.keys(this)[0];
假定procName始终是字典中的第一个键!尽可能使用const是一种好习惯。