Is possible to use TEMPORARY MACRO into CREATE VIEW? I need to use a kind of precompiler to expand macros and save the code as a permanent VIEW. Example:
CREATE TEMPORARY MACRO to_isodate(d string)
CONCAT_WS('-',substr(d,1,4),substr(d,5,2),substr(d,7));
CREATE VIEW vw1 AS SELECT id, to_isodate(d1) d1, to_isodate(d2) d2 FROM t;
... after session logout use the VIEW vw1.
Related
I am working with API keys and I need to be able to access the same unique API from two different screens. Basically, I need the dataKey variable in both screens, and I get the dataKey variable from the getKey() function, which has a get method that fetches the key. Right now the getKey() function is in one of the files (todolist.dart), but I don't know how to access it from my other file (add_new_item.dart).
Create a class, define the function getKey() inside the class. Then import the file where the Class is created. Then Use ClassName.getKey() syntax.
Trying to understand the question. I think if you need to access the API key in the second screen or which ever screen.
You can use the “import” statement to import the file where the API keys are, (that’s if it’s not in a widget class).
Then access it normally where you’ll need it.
Like.
getData(
final key = getKey():
// then the key stored key variable
// then use key in api call
)
I have a class who's main purpose revolves around a temp table. I want to make a constructor that takes an identical temp table as input.
So far the compiler chokes on any attempt to pass a temp table as a input parameter. If I use a table handle instead, it works. But I'd rather not copy from a dynamic table to a static one.
Progress wants the tables to match up at compile time, but I know they'll be the same - the're defined in a .i file.
Is there an easy way to line up the tables, or am I stuck parsing it out one field at a time?
Works like a charm to me.
CLASS Test.TTOO.TempTableWrapper:
{Test/TTOO/ttCustomer.i}
CONSTRUCTOR PUBLIC TempTableWrapper (TABLE ttCustomer):
FOR EACH ttCustomer:
DISPLAY ttCustomer.CustNum ttCustomer.Name .
END.
END CONSTRUCTOR.
END CLASS.
and the caller:
ROUTINE-LEVEL ON ERROR UNDO, THROW.
USING Test.TTOO.* FROM PROPATH.
DEFINE VARIABLE oWrapper AS TempTableWrapper NO-UNDO .
{Test/TTOO/ttCustomer.i}
/* *************************** Main Block *************************** */
CREATE ttCustomer.
ASSIGN ttCustomer.CustNum = 42
ttCustomer.Name = "It works" .
oWrapper = NEW TempTableWrapper(TABLE ttCustomer ) .
You can also pass the temp-table by-ref:
oWrapper = NEW TempTableWrapper(TABLE ttCustomer BY-REFERENCE) .
However, then the temp-table data is only availalbe during the constructor as BY-REFERENCE calls "overlap" the temp-table within the callee only for the duration of that call.
For permanent "BY-REFERENCE", use the BIND keyword on the call and the paramter - in which case the callee must define the temp-table as REFERENCE-ONLY.
Note, it's not required (although recommended at least by me) to define the temp-tables in include files. At runtime and compile time, the schemas just need to match.
When the compiler does not like your call, delete the classes r-code and recompile.
new to Cache so please forgive me,
I'm trying to call a class/table method in WinSQL. Basically trying to go select table_methodname() but it says it's not finding the stored function.
In Cache SQL there seems to be either a result set stored procedure which acts like a normal T-SQL stored proc or a class/table method (stored function) that acts like a function.. those are the ones I'm having trouble calling in WinSQL..
thanks!
In order to call a ClassMethod from SQL, you must mark the ClassMethod with the [SqlProc] modifier.
ClassMethod MyMethod() As %Integer [SqlProc]
{
...
}
Then, you can call it with
SELECT MySchema.MyClass_MyMethod()
Documentation is here:
http://docs.intersystems.com/ens20141/csp/docbook/DocBook.UI.Page.cls?KEY=ROBJ_method_sqlproc
I need a way to select objects given the name:string of the object and ObjectContext, but dont know how to do this.
I will use this to create a generic lookup dropdown editor template in ASP.MVC
So when view contains #Html.EditorFor (student=>student.School), it will show dropDown containing list of schools.
I get the target entity name from relation.ToMember, but don't know how to query data records with this input.
Currently I have added a custom method which gets string and returns innumerable and inside that I have a big switch case "School": return this.SchooleSet;
Is there a right way to do this.
I also want to add a generic method which allows me to query using syntax like ctx.Select<Teacher>().Where(...)
again here I have implemented with switch but there should be a better way to do this.
Try the CreateObjectSet method.
var q = ctx.CreateObjectSet<Teacher>().Where(...);
I have a controller named class TestController which extends some Zend_Controller_Action. Now I would like to use create an instance of TestController in TestForms (a Zend_Form). I want to populate a Zend_Form_Element_Select dynamically.
Please suggest how I can do this. Thanx in advance.
Where are you instantiating the form - is it in the controller? Instead of having the form call an action on the controller to dynamically get the values, you should look at setting the values on the form after it has been instantiated.
A quick and dirty way of doing that would be to grab the values in the controller and assign it to the element via:
$values = $db->query('query');
$element = $form->getElement('dynamicSelect');
$element->setValue($values);
Of course having DB queries to a table in your controller isn't exactly best practice... Per philistyne's suggestion, I use a a form builder class to build forms dynamically from my models. I have mappers for each model, and I pass in the mapper to the form builder class so it can dynamically populate my select elements.
A couple of things to try (passing a controller into a form or instantiating from within one is not recommended):
Use a model to access the dynamic values you want to put into your Zend_Form_Element_Select.
If the form is complex, create a form builder class to take care of, and separate out, the heavy lifting of the form construction.
Create customised form elements by extending from Zend_Form_Element_(Radio, Select, etc etc) if you feel you need very fine control over the form element's construction/behaviour/appearance, but wish to be able to reuse that element elsewhere.