Menu

GIXSQL HOW TO USE RESERVED WORDS IN TABLE FIELDS

J McNamara
2024-12-19
2024-12-20
  • J McNamara

    J McNamara - 2024-12-19

    HI SIMON-

    I'M WRACKING MY BRAINS.

    CAN YOU USE A RESERVED WORD IN A PARAMERTIZED QUERY?

    LIKE FOR INSTANCE TRANS TYPE TYPE IS RESERVED

    SOME OF THESE WILL INSERT INTO REGULAR PSQL BUT NOT WITH GIX
    BECAUSE I DON'T KNOW THE TRICK.
    THANKS,
    JIM

    EXEC SQL
    INSERT INTO "my_table"
    ("id", "amount", "trans_type", "trans_date", "gl_acct",
    "class_value", "seq_num")
    VALUES (:"id", :"amount", :"trans_type",
    TO_DATE(:"trans_date", 'YYYY-MM-DD'),
    :"gl_acct", :"class_value", :"seq_num")
    END-EXEC

    Sent with Proton Mail secure email.

     
    • J McNamara

      J McNamara - 2024-12-19

      $ gixpp -e -S -I. -i t001.cbl -o t001.cbsql "c:\Users\stealth_droid\Documents\Gix\Examples\test001\bin\debug\x64"
      ""C:/Users/stealth_droid/Documents/Gix/Examples/test001/bin/debug/x64/t001.cbl(344): error: Cannot find host variable:
      C:/Users/stealth_droid/Documents/Gix/Examples/test001/bin/debug/x64/t001.cbl(340): error: Error in ESQL statement

      thanks,
      jim

       
    • J McNamara

      J McNamara - 2024-12-19

      sorry simon,

      I must have some data type mismatch.

      i'm trying to track down the last one i hope.

      i changed it to look kind of like this...

      EXEC SQL
      INSERT INTO "my_table"
      ("id", "amount", "trans_type", "trans_date", "gl_acct",
      "class_value", "seq_num")
      VALUES (:WS-ID, ROUND($2, 2), TRIM(:WS-TRANS-TYPE),
      TO_DATE(:WS-TRANS-DATE, 'YYYY-MM-DD'),
      :WS-GL-ACCOUNT, :WS-CLASS-VALUE, :WS-SEQ-ID)
      END-EXEC

      Sent with Proton Mail secure email.

       
      • J McNamara

        J McNamara - 2024-12-20

        Hi Simon-

        I got some select and insert code working with my db..

        The places I went wrong were data types in sql mapping to postgresql data types

        it handled the reserve field names well. I did something spacey.

        Also remembering to use DEFAULT for inserts in postgres.

        i also used ROUND($1, 1) which helped with an insert coercing something.
        03 WS-AMOUNT PIC 9(4).

        type numeric(10,2)

        that kind of thing....

        thanks,
        jim

         
  • Simon Sobisch

    Simon Sobisch - 2024-12-20

    That's possibly a bit much to ask, but why not...

    Could you try to write up a document on "what worked" - so only the parts someone needs to know / would be able to follow to use EXEC SQL with (Gnu)COBOL?
    A list of tips / things to watch out like "reserved word handling", "data type mapping", ... would be useful as well.

    I picture kind of a document "in progress" (that is edited/updated from time to time).

    While this will take some time it will likely help the next people in a similar situation that you were in and also could be useful to reduce the time for community support when we can point to documents like these. ... and: if you ever get distracted and need to come back - you have all your important notes in one place :-)

    ... oh, this reminds me about the documentation at https://gitlab.cobolworx.com/gnucobol/sql (this uses esqlOC on GNU/Linux, but there's likely something to take from in any case, if nothing else then sample COBOL sources with EXEC SQL and SQL scripts for testing them).

     
    • J McNamara

      J McNamara - 2024-12-20

      Hi Simon-

      I will try to improve some kind of use case documentation but your documentation is actually quite good. It is just that i don't' learn things linear and I come from a very limited cobol and postgresql background compared to some of the developers.

      Take this one for instance that you can declare a cursor inside a begin and a commit but don't have to open it. that is specifically for postgresql and found buried in your docs. I struggled with that and said what the what when it balked at my behavior. I think i looked at a non postgresql example doc and then tried to mix in postgresql example doc and was trying to open that cursor after calling declare because of it.

      I will start doing some notes in cherry tree app and save them and back them up.

      thanks so much Simon.

      this Gixsql is really cool.

      I am just not good enough yet.

      thanks,
      jim

      Sent with Proton Mail secure email.

      On Friday, December 20th, 2024 at 3:57 AM, Simon Sobisch sf-mensch@users.sourceforge.net wrote:

      That's possibly a bit much to ask, but why not...

      Could you try to write up a document on "what worked" - so only the parts someone needs to know / would be able to follow to use EXEC SQL with (Gnu)COBOL?
      A list of tips / things to watch out like "reserved word handling", "data type mapping", ... would be useful as well.

      I picture kind of a document "in progress" (that is edited/updated from time to time).

      While this will take some time it will likely help the next people in a similar situation that you were in and also could be useful to reduce the time for community support when we can point to documents like these. ... and: if you ever get distracted and need to come back - you have all your important notes in one place :-)

      ... oh, this reminds me about the documentation at https://gitlab.cobolworx.com/gnucobol/sql (this uses esqlOC on GNU/Linux, but there's likely something to take from in any case, if nothing else then sample COBOL sources with EXEC SQL and SQL scripts for testing them).


      GIXSQL HOW TO USE RESERVED WORDS IN TABLE FIELDS


      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/gnucobol/discussion/help/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.