VS:DBObjSQLGetRead: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 39: Line 39:


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<sample></sample>
<sample>
==== VectorScript ====
<code lang="pas">
PROCEDURE Test;
VAR
recordName, query : DYNARRAY [] OF CHAR;
hCurrentLayer, hCurrentObject, hRecord : HANDLE;
i, cnt : LONGINT;
res : BOOLEAN;
 
BEGIN
hRecord := NIL;
{Select only objects with record attached}
recordName := 'TestRecord';
DSelectAll;
SelectObj(INSYMBOL & INVIEWPORT & (R IN [recordName ]));
 
{Get quesries of selected object}
hCurrentLayer := FLayer; { first layer }
while (hCurrentLayer <> NIL) do { loop through all the layers }
begin
hCurrentObject := FSObject(hCurrentLayer); { first selected object in layer }
while hCurrentObject <> NIL do { loop through all the objects }
begin
{find the record}
cnt := NumRecords(hCurrentObject );
for i := 1 to cnt do
begin
hRecord := GetRecord(hCurrentObject , i);
if hRecord <> NIL then begin
if GetName(hRecord) = recordName then begin
res := DBObjSQLGetRead(hRecord, query);
AlrtDialog(query);
end;
end;
end;
hCurrentObject := NextSObj(hCurrentObject); { next selected object }
end;
hCurrentLayer := NextLayer(hCurrentLayer); { next layer }
end;
END;
RUN(Test);
</code>
</sample>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------

Revision as of 17:22, 30 September 2014

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Get an object's SQL sentence for ODBC read.

FUNCTION DBObjSQLGetRead(
hRecord :HANDLE;
VAR SQLSentence :DYNARRAY[] of CHAR) : BOOLEAN;
def vs.DBObjSQLGetRead(hRecord):
    return (BOOLEAN, SQLSentence)

Parameters

hRecord HANDLE
SQLSentence DYNARRAY[] of CHAR

Example

VectorScript

PROCEDURE Test;
VAR
	recordName, query : DYNARRAY [] OF CHAR;
	hCurrentLayer, hCurrentObject, hRecord : HANDLE;
	i, cnt : LONGINT;
	res : BOOLEAN;

BEGIN
	hRecord := NIL;
	{Select only objects with record attached}
	recordName := 'TestRecord';
	DSelectAll;
	SelectObj(INSYMBOL & INVIEWPORT & (R IN [recordName ]));

	{Get quesries of selected object}
	hCurrentLayer := FLayer; { first layer }
	while (hCurrentLayer <> NIL) do { loop through all the layers }
	begin
		hCurrentObject := FSObject(hCurrentLayer); { first selected object in layer }
		while hCurrentObject <> NIL do { loop through all the objects }
		begin
			{find the record}
			cnt := NumRecords(hCurrentObject );
			for i := 1 to cnt do 
			begin
				hRecord := GetRecord(hCurrentObject , i);
				if hRecord <> NIL then begin
					if GetName(hRecord) = recordName then begin
						res := DBObjSQLGetRead(hRecord, query); 
						AlrtDialog(query);
					end;
				end;
			end;
			hCurrentObject := NextSObj(hCurrentObject); { next selected object }
		end;
		hCurrentLayer := NextLayer(hCurrentLayer); { next layer }
	end;
	
END;
RUN(Test);

Version

Availability: from Vectorworks 2011