Welcome! Log In Create A New Profile

Advanced

How to insert SQLViews into the database via code?

Posted by TCV 
Greetings!

I've been trying to add all of the SQLViews I have on my analysis to my database via code, but nothing has worked so far.

I tried doing this:

INTERNAL PROCEDURE storedviews()
	HRefreshView(MyConnection,"*")
	HRefreshQuery(MyConnection,"*")
END


But I got no results, then I tried this:

INTERNAL PROCEDURE storedviews()
	arrTexto is array of string
	sText is string
	
	sText = HListFile(hLstView)
	StringToArray(sText,arrTexto,CR)
	FOR EACH i OF arrTexto
		HRefreshView(MyConnection,i)
		HRefreshQuery(MyConnection,i)
	END
END


and it didn't work either, it only gave me the tables in my analysis, not the views.

I am working with WINDEV23. I would appreciate any help I can get! smiling smiley
Re: How to insert SQLViews into the database via code?
December 03, 2023 10:16AM
Hi TCV

Can you first tell us the type of database you are using?

Cheers

Peter
Greetings Peter!

I'm currently using an HFSQL C/S server.
Re: How to insert SQLViews into the database via code?
December 07, 2023 09:06PM
Hi TCV

Not sure... Moved away from HFSQL already a long time ago because of its constraints for my purposes.
So in other databases this works pretty easy using standard SQL, TSQL, PL/SQL...
CREATE VIEW MyViewName
(
SELECT...
...
)

Maybe HFSQL is not very SQL standard but you may give it a try if it supports those basic SQL statements.

Cheers

Peter
Hey Peter!

Thank you for answering! It isn't exactly what I was looking for but it's what I ended up using in the end anyways. I mainly wanted to know if there was a way to create the views directly from the analysis instead of having to create each one individually from scratch.

Something similar to
HCreationIfNotFound
or similar to what
HRefreshSet(MyConnection,"*",True)
accomplishes with stored procedures.

Again, I ended up doing what you suggested since I couldn't find a way to do it automatically. Anyways, thank you so much for your help!

Be seeing you around,

TCV
Re: How to insert SQLViews into the database via code?
December 09, 2023 12:10PM
Hi TCV

Guess this is what you are looking for:
hCreateView()
https://doc.windev.com/en-US/?3044159&name=hcreevue_fonction

Cheers

Peter
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: