Set a mydbr variable value from javascript?

(5 posts) (2 voices)

Tags:

No tags yet.

  1. SteveD, Member

    I can easily set a javascript variable with a mydbr variable's value, but what is the syntax for the reverse, especially in an if else statement. The below works fine to set a javascript variable, but I can't seem to work out the correct syntax to do the reverse

    <script type="text/javascript"> if (sessionStorage.length == 0) { sessionStorage.tmpdb = "' + @tableid + '"; } </script>

    Ideally I would like to add an else statement that populates @tableid with the value of sessionStorage.tmpdb if sessionStorage.tmpdb has already been set.

    I have a work around in place if it isn't possible (I can just pass @tableid as part of the sequence of stored procedure calls, so this is more for future reference than to solve an immediate problem.

    Thanks

  2. myDBR Team, Key Master

    What is the problem you are trying to solve by using the sessionStorage?

    --
    myDBR Team

  3. SteveD, Member

    Unfortunately my initial approach wont work.

    I need to share a collection of data between three different procedures. My initial thought was to use a global temporary table with a unique name that could be stored in sessionStorage (the name, not the data). This won't work however as even a global temporary table goes out of scope as soon as the initial creating procedure finishes and SQL Server purges it (plus sessionstorage was slightly OTT as I could just pass the table name as a parameter).

    A regular table won't work (if a user closes the webpage after the regular table has been created it wont purge), and as this is SQL Server 2005 I can't use table variables either.

    sessionStorage may still work (although it's less than ideal) as I could parse the collection of data (9 columns * n rows, typically only around 3 or 4) and store it in sessionstorage.

    I know that it isn't an ideal solution to use sessionstorage, but unfortunately the local DB side of HTML5 isn't as widely supported as sessionstorage is.

  4. myDBR Team, Key Master

    Using sessionStorage to store data that you share in your report procedures sound overly complicated. First thing is to evaluate if such data sharing is needed, if it is, the correct place to keep it would be in the database.

    --
    myDBR Team

  5. SteveD, Member

    In an ideal world it would indeed be easier to keep it in the database (oh so much easier), unfortunately due to the reasons mentioned above that doesn't look like it will be possible, hence myself looking at sessionStorage as a solution. The only other viable alternative is to pass the data as an XML datatype between the various procedures, which is kind of nasty by may be the only viable solution.


Reply

You must log in to post.