Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional CREATE VIEW/ DROP VIEW

Status
Not open for further replies.

commgraf

Technical User
Jul 17, 2006
2
PL
Hi All!

I would like to make in the Stored Procedure conditional
Create View (If not Exist), but it appears that in my Pervasive SQL (9.1) PCC IF statement doesn't work with DROP VIEW and CREATE VIEW commands.
I can't find this kind of information in Pervasive SQL Reference Manual.
May be someone more experienced in Pervasive SQL can help?

Best regards,
Jurek
 
Following is my syntax:

CREATE PROCEDURE create_vw_XT_if_not_exist()
AS
BEGIN
IF( EXISTS (SELECT X$View.Xv$Name
FROM X$View
WHERE X$View.Xv$Name = 'VW_XT') ) THEN
DROP VIEW VW_XT;
END IF;

CREATE VIEW VW_XT(id,kod) AS SELECT XT.id, XT.kod FROM XT;
END;

My problem is , that regardless of IF condition result ( true or false) the line after THEN ( if that is DROP VIEW or CREATE VIEW) is always executed.
If I changed the line and used (for example) SIGNAL Statement all working OK.
I can't understand while?

Thanks in advance
Jurek
 
Well, I changed your statement a little and confirmed that the "True" value of the IF is running because the condition seems to always evaluate as true.
I would suggest contacting Pervasive.

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top