• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Any SAPs out there?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    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
    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; 11 July 2017, 20:52.
    merely at clientco for the entertainment

    Comment


      #3
      Cheers - I'll try the set thing.

      Comment


        #4
        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.
        Down with racism. Long live miscegenation!

        Comment


          #5
          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

          Comment


            #6
            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

            Comment


              #7
              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.
              …Maybe we ain’t that young anymore

              Comment


                #8
                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

                Comment


                  #9
                  Have you tried DROPTABLE ?
                  …Maybe we ain’t that young anymore

                  Comment


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

                    https://help.sap.com/viewer/de2486ee...1ac6541b8.html
                    The Chunt of Chunts.

                    Comment

                    Working...
                    X