SQL Example Using Clarion

:smile:

Post some code and I will see if I can spot anything!

viewTabela                  view(RESPOSTA)
                        project(RES:COLUNA1)
                        project(RES:COLUNA2)
                        project(RES:COLUNA3)
                        project(RES:COLUNA4)
                        project(RES:COLUNA5)
                        project(RES:COLUNA6)
                        project(RES:COLUNA7)
                        project(RES:COLUNA8)
                        project(RES:COLUNA9)
end

open(viewTabela)
L:SQL = 'select * from cl_clire where cd_repre = ' & REP:Cd_Repre & ';'
RESPOSTA{PROP:SQL} = L:SQL !Dummy table
if error()
    message(errorcode() & ' ' & error() & ' ' & fileerrorcode() & ' ' & fileerror())
else
    loop
        next(viewTabela)
        if errorcode()        
            do InsertRoutine
        else
            do UpdateRoutine
        end
        break
    end
end
close(viewTabela)

The first part it’s the declaration of the View. The second part it’s the code that it’s not working.

You should do a check for errors after opening the view.

open(viewTabela)
if error()
  ! do something about it
end

and here, I think you need to explicitly list the columns you want rather than use *. Also, I am pretty sure the ; is unnecessary and may even cause a problem.

L:SQL = 'select * from cl_clire where cd_repre = ' & REP:Cd_Repre & ';'

What data type is this one?

REP:Cd_Repre

Sorry for not answering you guys. I was on vacation and started to work back today. My mistake was that I wasn’t using the view to execute the SQL statement, now everything is working. Thanks for all your help, @brahn and @rockyp.

1 Like

Hi hugs from Costa Rica.

Please help me, I’m trying to run a PROP : SQL in my application with the following command C6.3 , but there is no way to run . What am I doing wrong?

mytable{prop: sql} = 'truncate table dbo.mae06f_buscador'

If Errorcode() = 90
           Message ( Errorfile ())
           Message ( Fileerrorcode ())
end

“mytable” its a table SQL and defined in the Clarion Dictionary.

Always returns error S0002 in the table mae06f_buscador

Thank you !!!

I have never used ErrorFile(), had to look that one up!

Whilst it might be handy probably what you actually want there is Message(FileError()) instead.
See if that tells you anything helpful.

Thank you,
This just helped me find my fault after 3 days of searching in around 5 minutes.

1 Like