var step0=`select INGESTION_SUCCESSFUL,ingestion_uuid from FILE_INGESTION_HISTORY where ingestion_uuid=( select ingestion_uuid from registration where registry_subject_uuid=:1 qualify row_number() over( order by dnb_latest_received_dt desc)=1)`; var statement0=snowflake.createStatement( {sqlText: step0,binds: [PARAM_REG_SUB_UUID]} ); variable1= statement0.execute(); variable1.next(); ingsindc=variable1.getColumnValue(1);ingsuuid=variable1.getColumnValue(2);
cuando trato de usar el ingsuuid anterior en sql, donde la cláusula arroja un error
var step1 = create or replace temporary table FN_IGSN_REG_LBV1 as select * from registration where ingestion_uuid=**ingsuuid** and (DELETE_INDC=0) qualify row_number() over (partition by REGISTRATION_HASH_KEY order by dnb_latest_received_dt desc, row_created_tmst desc, registration_uuid desc) = 1 ;
var statement1=snowflake.createStatement( {sqlText: step1} ); statement1.execute();Vincular una variable a una instrucción SQL le permite utilizar el valor de la variable en la instrucción.
Puede enlazar valores NULL así como valores no NULL.
El tipo de datos de la variable debe ser apropiado para el uso del valor en la instrucción SQL. Actualmente, solo se pueden enlazar variables de JavaScript de tipo número, cadena y SfDate. (Para obtener detalles sobre la asignación entre los tipos de datos de SQL y los tipos de datos de JavaScript, consulte Asignación de tipos de datos de SQL y JavaScript).
Aquí hay un breve ejemplo de enlace:
var stmt = snowflake.createStatement( { sqlText: "INSERT INTO table2 (col1, col2) VALUES (?, ?);", binds:["LiteralValue1", variable2] } );Más detalles : https://docs.snowflake.com/en/sql-reference/stored-procedures-usage.html#binding-variables