[SOLVED] I need a variable that contains SQL Statement

Is there any scriptcase internal variable that contains the sql statement?

I assume that you want to manipulate the statement? If that is the case then look into that SC macros. Afaik there is not an easy way to get the full sql.

I want to create a view with the sql statement and make it dynamically to get all the field names of the application.

I see. I’m afraid I don’t have the answer.

OK, you want to get the SQL-statement of a grid.

You’ll have to read it out of session variables.

If you have a grid using mySQL, you can get it during onFooter event with:
echo $this->Db->_driver->_queryID->queryString;

Make sure, that the footer is switched on!
You will not have to display any content in the footer but the event has to be executed.

My example grid has an sql statement even including a stored procedure:

SELECT 
    id,
    anrede,
    vorname,
    nachname,
    land,
    plz,
    ort,
    bemerkung, 
    asdw_translation_get_content_varchar('[gbl_language]','','sample_adresse','bemerkung_loc',id) AS bemerkung_loc 
FROM 
    sample_adresse
WHERE asdw_set_is_deleted_yn = 0 

The echo statement shows:


You might want to get rid of the LIMIT at the end :wink:

I do hope, this will help you!

Best

Gunter Eibl
Scriptcase Coaching in Germany

1 Like

Thank you, this is what i needed