Jump to content

Query from text file


Recommended Posts

Good Morning!!!

I'm trying to access a query saved in a query.sql file for example.

This query has two variables. But when I call the contents of the file, I don't understand the query.

The variable is not replaced by its value so there is no record.

Can you help me?

thank you

LOCAL $sFilePath =  "C:\robotdesp\queryspmi.sql"
   ; Open the file for reading and store the handle to a variable.
    Local $hFileOpen = FileOpen($sFilePath, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "ERRO NA LEITURA DO ARQUIVO "&$sFilePath)
        Return False
    EndIf
    ; Read the contents of the file using the handle returned by FileOpen.
    Local $sFileRead = FileRead($hFileOpen)
;~     ; Close the handle returned by FileOpen.
;~     FileClose($hFileOpen)
;~     ; Display the contents of the file.

; the query in the file is  :  

"SELECT EAS.NOME_EMPRESA_PAI  EMPRESA ,EAS.NOME_EA  EA ,NOTAS.NOME_EQUIPE EQUIPE  ,NOTAS.NOTA_SERVICO  NOTA , NOTAS.SEQUENCIA SEQUENCIA FROM IGP.SPMI_EA_EQUIPE_NOTAS_DESP NOTAS LEFT JOIN  IGP.SYS_ESTRUTURA EAS ON EAS.COD_EA = NOTAS.ID_EA_CWSI WHERE DIA = TRUNC(SYSDATE)                 AND ETL_DESPACHAVEL = 1  AND EAS.NOME_EMPRESA_PAI = '"&$nomeemresapai&"' AND EQ_VINCULADA_DESPACHO_AUTOMATICO_CWSI = '"&$eqp_dedic_ou_multi&"' ORDER BY EAS.NOME_EMPRESA_PAI  ,EAS.NOME_EA ,NOTAS.NOME_EQUIPE ,NOTAS.SEQUENCIA"

.Source = $sFileRead  ;
.Open

Edited by Clayson
Changed ridiculously large font
Link to comment
Share on other sites

Try using something like this:

$sFileRead = StringReplace($sFileRead, "$nomeemresapai", $nomeemresapai)

AutoIt doesn't auto-expand variables like you're thinking.

(Also, please try to clear the formatting from your posts after copying out of Google Translate, it's a mess right now :))

Edit: And using the code tag "<>" is very helpful when you're posting code

Edited by seadoggie01

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

3 hours ago, seadoggie01 said:

Try using something like this:

$sFileRead = StringReplace($sFileRead, "$nomeemresapai", $nomeemresapai)

AutoIt doesn't auto-expand variables like you're thinking.

(Also, please try to clear the formatting from your posts after copying out of Google Translate, it's a mess right now :))

Edit: And using the code tag "<>" is very helpful when you're posting code

my dysgraphia kills me with shame lol ...

thanks for letting me know, I hadn't noticed.

I will try what you suggested.

Link to comment
Share on other sites

No problem! And don't be ashamed, some disabilities can help you in ways. I'm a bit dyslexic (why is that word so hard to spell?) and I have some ADD tendencies. The ADD helps me concentrate in huge bursts without noticing it sometimes and complete lots of small things quickly at other times. I haven't found things that dyslexia helps with (yet), but I'm sure it makes me think about things differently (I think part of the reason I started programming was so I wouldn't have to deal with all of the numbers, especially in accounting), which is just part of what makes me who I am :)

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

2 minutes ago, seadoggie01 said:

No problem! And don't be ashamed, some disabilities can help you in ways. I'm a bit dyslexic (why is that word so hard to spell?) and I have some ADD tendencies. The ADD helps me concentrate in huge bursts without noticing it sometimes and complete lots of small things quickly at other times. I haven't found things that dyslexia helps with (yet), but I'm sure it makes me think about things differently (I think part of the reason I started programming was so I wouldn't have to deal with all of the numbers, especially in accounting), which is just part of what makes me who I am :)

CERTAINLY, DYSLEXIA HELPS YOU TO ENCRYPT,

ONLY YOU CAN UNDERSTAND WHAT YOU WRITE ...

WE ARE SLOW TO UNDERSTAND SOME THINGS BUT WE UNDERSTAND OTHERS BEFORE EVERYONE,

AUTOMATION, AUTOIT BECOMES A GREAT ALLY IN THIS WAY, ALWAYS INTERESTED IN THIS WAY AUTOMATE TO REDUCE ERRORS !!!

 

THANK YOU FOR YOUR WORDS TOO!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...