dailydevsblog.com Open in urlscan Pro
2606:4700:3033::6815:3b0b  Public Scan

URL: https://dailydevsblog.com/troubleshoot/resolved-invalid-identifier-when-binding-variables-in-snowflake-163173/
Submission Tags: falconsandbox
Submission: On July 27 via api from US — Scanned from DE

Form analysis 5 forms found in the DOM

GET https://dailydevsblog.com/

<form role="search" method="get" class="search-form" action="https://dailydevsblog.com/">
  <label>
    <span class="screen-reader-text">Search for:</span>
    <input type="search" class="search-field" placeholder="Search …" value="" name="s">
  </label>
  <input type="submit" class="search-submit" value="Search">
</form>

GET https://dailydevsblog.com/

<form role="search" method="get" class="search-form" action="https://dailydevsblog.com/">
  <label>
    <span class="screen-reader-text">Search for:</span>
    <input type="search" class="search-field" placeholder="Search …" value="" name="s">
  </label>
  <input type="submit" class="search-submit" value="Search">
</form>

GET https://dailydevsblog.com/

<form role="search" method="get" class="search-form" action="https://dailydevsblog.com/">
  <label>
    <span class="screen-reader-text">Search for:</span>
    <input type="search" class="search-field" placeholder="Search …" value="" name="s" autocomplete="off">
  </label>
  <input type="submit" class="search-submit" value="Search">
</form>

GET https://dailydevsblog.com/

<form role="search" method="get" class="search-form" action="https://dailydevsblog.com/">
  <label>
    <span class="screen-reader-text">Search for:</span>
    <input type="search" class="search-field" placeholder="Search …" value="" name="s" autocomplete="off">
  </label>
  <input type="submit" class="search-submit" value="Search">
</form>

POST https://dailydevsblog.com/wp-comments-post.php

<form action="https://dailydevsblog.com/wp-comments-post.php" method="post" id="commentform" class="comment-form" novalidate="">
  <p class="comment-notes"><span id="email-notes">Your email address will not be published.</span> <span class="required-field-message" aria-hidden="true">Required fields are marked <span class="required" aria-hidden="true">*</span></span></p>
  <div class="rb-form-rating">
    <span class="rating-alert is-hidden">Please select a rating</span>
    <label id="rating-163173">Your rating</label>
    <div class="rb-review-stars"> <span> <a class="star" data-rating="1" href="#"><i class="rbi rbi-star"></i></a> <a class="star" data-rating="2" href="#"><i class="rbi rbi-star"></i></a>
        <a class="star" data-rating="3" href="#"><i class="rbi rbi-star"></i></a> <a class="star" data-rating="4" href="#"><i class="rbi rbi-star"></i></a> <a class="star" data-rating="5" href="#"><i class="rbi rbi-star"></i></a> </span> </div>
    <select name="rbrating" id="rating-163173" class="rb-rating-selection" style="display: none;">
      <option value="">Rate…</option>
      <option value="5">Perfect</option>
      <option value="4">Good</option>
      <option value="3">Average</option>
      <option value="2">Not that bad</option>
      <option value="1">Very poor</option>
    </select>
  </div>
  <p class="comment-form-comment"><label for="comment">Your review&nbsp;<span class="required">*</span></label><textarea autocomplete="new-password" id="comment" name="be4319fc59" placeholder="Leave Your Review" cols="45" rows="8"
      required=""></textarea><textarea id="a21f8caf5e8afb382c89fa0d29552ab8" aria-label="hp-comment" aria-hidden="true" name="comment" autocomplete="new-password"
      style="padding:0 !important;clip:rect(1px, 1px, 1px, 1px) !important;position:absolute !important;white-space:nowrap !important;height:1px !important;width:1px !important;overflow:hidden !important;" tabindex="-1"></textarea>
    <script data-noptimize="">
      document.getElementById("comment").setAttribute("id", "a21f8caf5e8afb382c89fa0d29552ab8");
      document.getElementById("be4319fc59").setAttribute("id", "comment");
    </script>
  </p>
  <p class="comment-form-author"><label for="author">Name&nbsp;<span class="required">*</span></label><input placeholder="Name" id="author" name="author" type="text" value="" size="30" required=""></p>
  <p class="comment-form-email"><label for="email">Email&nbsp;<span class="required">*</span></label><input placeholder="Email" id="email" name="email" type="email" value="" size="30" required=""></p>
  <p class="comment-form-url"><label for="url">Website</label><input placeholder="Website" id="url" name="url" type="email" value="" size="30"></p>
  <p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"> <label for="wp-comment-cookies-consent">Save my name, email, and website in this browser for the next time
      I comment.</label></p>
  <p class="form-submit"><input name="submit" type="submit" id="submit" class="submit" value="Post Review"> <input type="hidden" name="comment_post_ID" value="163173" id="comment_post_ID">
    <input type="hidden" name="comment_parent" id="comment_parent" value="0">
  </p>
</form>

Text Content

0
 * Oracle/SQL
 * Programing Language
   
   * Javascript
   * C Language
   * Javascript
   * Python
   * PHP
   * Redis
   * Selenium
 * Cloud
 * Troubleshoot
 * About me


LOGIN

 * Log in
 * Entries feed
 * Comments feed
 * WordPress.org

 * Oracle/SQL
 * Programing Language
   * Javascript
   * C Language
   * Javascript
   * Python
   * PHP
   * Redis
   * Selenium
 * Cloud
 * Troubleshoot
 * About me


Search for:
Search for:

Daily Developer Blog

Everything about dev technical

 * Oracle/SQL
 * Programing Language
   * Javascript
   * C Language
   * Javascript
   * Python
   * PHP
   * Redis
   * Selenium
 * Cloud
 * Troubleshoot
 * About me

0
Search for:



Daily Developer Blog

 * Oracle/SQL
 * Programing Language
   * Javascript
   * C Language
   * Javascript
   * Python
   * PHP
   * Redis
   * Selenium
 * Cloud
 * Troubleshoot
 * About me

0
Search for:



Daily Developer Blog > Troubleshoot > Resolved: Invalid identifier when binding
variables in snowflake
Troubleshoot


RESOLVED: INVALID IDENTIFIER WHEN BINDING VARIABLES IN SNOWFLAKE

Posted by By Isaac 2 months Ago 2 Min Read



QUESTION:

I have created a stored procedure which gets certain values from a table and
uses those values into another sql query I successfully got the values I needed
however I keep getting invalid identifier for the values I pass through binding
Below is a snippet of my code


    var v_role       = sqlRS1.getColumnValue(1);
    var v_database   = sqlRS1.getColumnValue(2);
    var v_schema     = sqlRS1.getColumnValue(3);
    var v_table      = sqlRS1.getColumnValue(4);
    var v_column     = sqlRS1.getColumnValue(5);
    
    var v_tableColumn = v_table + `_` + v_column;
        
    var v_sqlCode5 = `SELECT * 
                      FROM  db.sch.tbl  
                      WHERE DATABASE_NAME = identifier(?) 
                      AND   SCHEMA_NAME   = identifier(?)  
                      AND   POLICY_NAME IN (identifier(?))`;
                     
    var sqlStmt2 = snowflake.createStatement({sqlText:v_sqlCode5,binds:[v_database,v_schema,v_tableColumn]});
    var sqlRS2   = sqlStmt2.execute();


the error will say that there is invalid identifier for the value passed in
DATABASE_NAME I checked the query history and I see that the value passed is
correct So I am unsure of how to solve this, any help would be greatly
appreciated



ANSWER:

Identifiers are using to replace table names (which can been seen in this
example). Where what you have seems like it should be normal equality join:
Another way of saying this is your generated SQL:


SELECT * FROM DB.SCH.TBL 
WHERE DATABASE_NAME = identifier('AD') 
    AND SCHEMA_NAME = identifier('DB') 
    AND POLICY_NAME IN (identifier('M_E'));


does this run with no errors for you in the UI?
I suspect you need to change it to:


SELECT * FROM DB.SCH.TBL 
WHERE DATABASE_NAME = 'AD'
    AND SCHEMA_NAME = 'DB'
    AND POLICY_NAME IN ('M_E');


to get it to work.
What you are wanting is to make sure the passed in values are fully quoted. so
things don’t escape, which was my understand of what passing them as bound
variables does.
which implies you source should be:


    var v_sqlCode5 = `SELECT * 
                      FROM  db.sch.tbl  
                      WHERE DATABASE_NAME = ?
                      AND   SCHEMA_NAME   = ? 
                      AND   POLICY_NAME IN (?)`;


If you have better answer, please add a comment about this, thank you!


RELATED

Resolved: Snowflake – How to call a UDF within a ProcedureJune 29, 2022In
"Troubleshoot"

Resolved: SwiftUI: Binding on property of struct derived from environment
objectJune 19, 2022In "Troubleshoot"

Resolved: Swift array binding filtering – Conformance of Binding to SequenceJune
14, 2022In "Troubleshoot"





Tags: snowflake-cloud-data-platform
Share on
Share on Facebook Share on Twitter Share on Linkedin Share on Telegram
Isaac June 7, 2022
Previous Article Resolved: How to change the language for the Wear OS emulator
in Android Studio?
Next Article Resolved: I am very new to MySQL and don’t know why there are
dupliacte items being added to each row?



LEAVE A REVIEW


CANCEL REPLY

Your email address will not be published. Required fields are marked *

Please select a rating Your rating

Rate… Perfect Good Average Not that bad Very poor

Your review *

Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.






RECENT POSTS

 * Resolved: Why any postcss nesting plugins doesn’t work?
 * Resolved: I added a Like model but I don’t know how to increase the number of
   like
 * Resolved: How to center a showmodalbottomservice
 * Resolved: Overflow X with max two rows
 * Resolved: Plotly: How to adjust annotation text angle for rectangles using
   `add_vrect()`?




YOU MIGHT ALSO ENJOY


RESOLVED: WHY ANY POSTCSS NESTING PLUGINS DOESN’T WORK?

Posted by Isaac 1 min Ago


RESOLVED: I ADDED A LIKE MODEL BUT I DON’T KNOW HOW TO INCREASE THE NUMBER OF
LIKE

Posted by Isaac 6 mins Ago


RESOLVED: HOW TO CENTER A SHOWMODALBOTTOMSERVICE

Posted by Isaac 11 mins Ago


RESOLVED: OVERFLOW X WITH MAX TWO ROWS

Posted by Isaac 15 mins Ago

 * Privacy Policy

© Daily Developer Blog, 2021


Sponsored Page