+ Reply to Thread
Page 1 of 2 1 2 LastLast
Posts 1 to 10 of 12
  1. #1

    TPAFKAk2p2

    mudskipper's Avatar
    Join Date
    Sep 2009
    Posts
    24,663
    Thanks (Given)
    791
    Thanks (Received)
    1332
    Likes (Given)
    6172
    Likes (Received)
    4790

    Default Any SAPs out there?

    I've got a .net application that runs a sql script to populate a staging table. It's written to be generic - ODBC connection to the feed system(s), and the sql is read from a text file that is configured for each customer (using OdbcCommand - so the SQL is just a string). A bunch of parameters are passed in to cater for all scenarios.

    So far, the only systems we've interfaced with have been sql server. An ODBC connection doesn't support named parameters, so the (sql server) sql script looks something like

    DECLARE @period varchar(4) = ?;
    DECLARE @actuality varchar(2) = ?;

    SELECT sum(myamount) as amount from mytable where myperiod=@period and myactuality = @actuality;

    All works hunky dory

    I need to be able to do the same with a HANA database, but can't work out the variable syntax

    With the help of google, I've got -

    declare period varchar(4) := ?;
    declare actuality varchar(2) := ?;

    SELECT sum(MYAMOUNT) as amount from MYTABLE where MYPERIOD=eriod and MYACTUALITY=:actuality;

    But I get a syntax error on declare

    To add to the difficulty, I only have access to configure the system via a webex screenshare, where every mouse click or keystroke comes with a 2 second timelag, so it's not easy just to edit and try stuff.#

    How do I declare variables in HANA?

    Any clues?

  2. #2
    eek
    eek is online now

    bored now

    eek's Avatar
    Join Date
    Jun 2010
    Location
    😂
    Posts
    21,948
    Thanks (Given)
    228
    Thanks (Received)
    1123
    Likes (Given)
    1004
    Likes (Received)
    3388

    Default

    I believe from limited experience probably 10+ years ago and a very quick google search tells me you need something like...

    SET 'period' = '?';
    SET 'actuality' = '?';

    SELECT MYAMOUNT from MYTABLE where MYPERIOD=(select SESSION_CONTEXT('period') from DUMMY) and MYACTUALITY=(select SESSION_CONTEXT('actuality') from DUMMY);


    UNSET 'period';
    UNSET 'actuality';

    Good luck I expect you'll need it but its variation of the above...
    Last edited by eek; 11th July 2017 at 20:52.
    merely at clientco for the entertainment

  3. #3

    TPAFKAk2p2

    mudskipper's Avatar
    Join Date
    Sep 2009
    Posts
    24,663
    Thanks (Given)
    791
    Thanks (Received)
    1332
    Likes (Given)
    6172
    Likes (Received)
    4790

    Default

    Cheers - I'll try the set thing.

  4. #4

    Respect my authoritah!

    NotAllThere's Avatar
    Join Date
    Aug 2007
    Location
    Far away from HMRC
    Posts
    17,192
    Thanks (Given)
    187
    Thanks (Received)
    712
    Likes (Given)
    1196
    Likes (Received)
    2548

    Default

    HANA SQLScript reference is here, in case you missed it.

    I don't know odbc, so I don't know what you mean by the ?, but your declares look correct. What is the exact syntax error? Are you able to post the exact script?

    SAP have a VM of HANA Express you could download to directly create your own SQL Scripts. Might speed things up.
    You won. Get over it.

    --drunk on abuse of power--

  5. #5

    TPAFKAk2p2

    mudskipper's Avatar
    Join Date
    Sep 2009
    Posts
    24,663
    Thanks (Given)
    791
    Thanks (Received)
    1332
    Likes (Given)
    6172
    Likes (Received)
    4790

    Default

    Quote Originally Posted by NotAllThere View Post
    HANA SQLScript reference is here, in case you missed it.

    I don't know odbc, so I don't know what you mean by the ?, but your declares look correct. What is the exact syntax error? Are you able to post the exact script?

    SAP have a VM of HANA Express you could download to directly create your own SQL Scripts. Might speed things up.
    Ta muchly - that's probably what I need.

    Haven't got access at the moment, but IIRC the message was something along the lines of Syntax error on declare

  6. #6

    Faqqed Off

    TheFaQQer's Avatar
    Join Date
    Oct 2006
    Posts
    35,838
    Thanks (Given)
    369
    Thanks (Received)
    1233
    Likes (Given)
    3564
    Likes (Received)
    3088

    Default

    I'm disappointed.

    This thread seems to have a clearly defined problem, with enough information to seek accurate responses, with no need to pull teeth to get to the bottom of the problem. And the people who have replied seem to have some knowledge and how to solve the problem, without the OP resorting to laughing at them for not understanding and berating them for not having more than two years experience.

    This place really has gone down hill.
    Best Forum Advisor, 2014
    Work in the public sector? You can read my FAQ here
    Click here to get 15% off your first year's IPSE membership

  7. #7

    キツネの帽子をかぶる

    WTFH's Avatar
    Join Date
    Nov 2012
    Posts
    8,951
    Thanks (Given)
    8
    Thanks (Received)
    1041
    Likes (Given)
    919
    Likes (Received)
    3126

    Default

    I'm surprised that the answer to an SAP question could be condensed into a few lines and not the usual 500 pages of documentation that is normally required for their software.
    Strong and Stable Moderation

  8. #8

    TPAFKAk2p2

    mudskipper's Avatar
    Join Date
    Sep 2009
    Posts
    24,663
    Thanks (Given)
    791
    Thanks (Received)
    1332
    Likes (Given)
    6172
    Likes (Received)
    4790

    Default

    Quote Originally Posted by WTFH View Post
    I'm surprised that the answer to an SAP question could be condensed into a few lines and not the usual 500 pages of documentation that is normally required for their software.
    It may not be answered yet

  9. #9

    キツネの帽子をかぶる

    WTFH's Avatar
    Join Date
    Nov 2012
    Posts
    8,951
    Thanks (Given)
    8
    Thanks (Received)
    1041
    Likes (Given)
    919
    Likes (Received)
    3126

    Default

    Have you tried DROPTABLE ?
    Strong and Stable Moderation

  10. #10

    Double Godlike!


    Join Date
    Dec 2012
    Posts
    10,384
    Thanks (Given)
    755
    Thanks (Received)
    742
    Likes (Given)
    4942
    Likes (Received)
    2860

    Default

    Couldn't you use a similar method as the example here?

    https://help.sap.com/viewer/de2486ee...1ac6541b8.html

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Content Relevant URLs by vBSEO 3.6.0 ©2011, Crawlability, Inc.