I have stored many employee objects in session. how to populate the select box with the name of the all employees.i am very new to cakephp so explain me the syntax.
Assuming that your employee objects in your session are in the following format
array('Employee.id' => 'Employee.name') you can populate the selectbox with the following statement in your views: $this->Form->select('employees', $employees) (where $employees is an array formatted as above).
See also http://book.cakephp.org/view/1430/select for more info on the syntax of the select box.
Related
I would like to filter the output of show tables.
The documentation has one example on how to do this using result_scan(last_query_id()), but for me the example does not work:
show tables;
select "schema_name", "name" as "table_name", "rows"
from table(result_scan(last_query_id()))
where "rows" = 0;
-- SQL compilation error: error line 1 at position 8 invalid identifier 'SCHEMA_NAME'
The column SCHEMA_NAME is actually in the output of show tables,
so I do not understand what is wrong.
Best,
Davide
Run the following on your account and see what it is set to:
show parameters like 'QUOTED_IDENTIFIERS_IGNORE_CASE';
If this is set to TRUE, then it is ignoring the quotes in your query, which will then uppercase the column names, which won't match to the lowercase names of the SHOW output.
To resolve for your own session, you can run the following:
ALTER SESSION SET QUOTED_IDENTIFIERS_IGNORE_CASE = False;
You can also change this at a user or account level, if you wish. Setting this value to TRUE isn't recommended for the reason that you are running into.
You can reference the filter column using $<col_n> syntax (#8 for rows).
Example:
show tables;
select *
from table(result_scan())
where $8 > 5
That being said, your query worked for me.
HANA Version: SP12
All,
I've successfully created Calc Views with INPUT_PARAMETERS as described by Lars in many blogs and forums. While these views work without issue when querying directly for single and multi inputs, I'm encountering an issue with performing joins on the Calc View itself within a stored proc or table function.
Example:
"BASE_SCHEMA"."BASE_TABLE_EXAMPLE" - record count(*) ~ 2million records
Keys: Material (20k distinct), Plant (200 distinct)
"_SYS_BIC"."CA_EXAMPLE_PRODUCTIVITY"
Input Parameters: IP_MATNR (nvarchar (5000)), IP_PLANT (nvarchar(5000))
Issue #1: The maximum value for nvarchar is 5000. Unable to utilize multiple inputs within the parameter if the count of distinct characters are 5000+.
Issue #2: How to use PLACEHOLDER logic in the same method of performing an INNER_JOIN in SQL.
base_data =
select
PLANT
,MATERIAL
from "BASE_SCHEMA"."BASE_TABLE_EXAMPLE"
group by PLANT,MATERIAL;
I would think to perform the below but the output would cause issues when concatenating multiple strings for use within input parameter of nvarchar(5000).
select
string_agg(PLANT,''',''') as PLANT
,string_agg(MATERIAL,''',''') as MATERIAL
into var_PLANT, var_MATERIAL
from
(
select
PLANT
,MATERIAL
from :base_data
);
While I'm successful up to this point, once adding the variables into the PLACEHOLDER of the Calc View, it fails stating that I'm passing too many characters to the IP. Any suggestions??? Thanks in advance.
base_calc =
select
PLANT
,MATERIAL
,MATERIAL_BU
,etc....
from "_SYS_BIC"."CA_EXAMPLE_PRODUCTIVITY"
(PLACEHOLDER."IP_MATNR"=> :var_MATERIAL, --<---Fails here. :(
PLACEHOLDER."IP_PLANT"=> :var_PLANT);
Question raised on SAP SCN. Located here!
Did you tried to use WHERE clause instead of PLACEHOLDER?
base_calc =
select
PLANT,
MATERIAL,
MATERIAL_BU,
etc....
from "_SYS_BIC"."CA_EXAMPLE_PRODUCTIVITY"
WHERE MATERIAL = var_MATERIAL AND PLANT = var_PLANT;
A class has a property which holds link of rid's.ie testcaseLink:[#20:0,#20:1].I have a problem in selecting only certain rids from the testcaseLink using select statement.
Looking for something like select testcaseLink.get(#20:0) from tableName.Is there is any method to filter the contents of collections in orientdb
select testCaseLink[#rid=#20:6 OR #rid=#20:8] from tableName where ColumnName='Value' Solved the problem
I have large amount of data in a table 'Users'. The 'username' field contains string values but users has input symbols in it e.g. im-a-user, you_are_user, etc.
How can I clean that columns data using SQL query ?
Users:
I want to clean the values in Username column so that they should look like, imauser, imanotheruser and andmoreuser, etc.
Use regexp_replace()
select id,
regexp_replace(lower(username), '[^a-z]', '', 'gi') as clean_user_name
from users;
I have two tables in database namely QbQuestion(Qid,Question,StatusId) and Qbstatus(StatusId,Status),,,,,where Status stores status as new,acive,inactive etc.
i want to fetch StatusOptions on view form of QbQuestion in form of dropdownBox. i got succeded to fetch StatusOptions on QbQuestion view form but that selected entry is not getting inserted in QbQuestion table. In _form.php,to fetch StatusOptions, i have inserted code as follows:
labelEx(Qbstatus::model(),'Status'); ?>
findAll();
$list = CHtml::listData($records,'QuestionStatusId', 'Status');
echo CHtml::dropDownList('Qbstatus', null, $list, array('empty' => 'Select a Status'));
?>
error(QbStatus::model(),'Status'); ?>
So what i should do in order to make entries in QbQuestion table
Your question is not very clear, but from what I understand you are unable to make the drop down list display the correct options/values, which then prevents your QbQuestion table from storing the correct id for the QuestionStatusId?
Here is how your drop down list should look (untested obviously):
echo CHtml::dropDownList($model,'StatusId',CHtml::listData(Qbstatus::model()->findAll(),'QuestionStatusId','Status'),array('empty'=>'Select a Status'));
If you view the source you should see a normal HTML structure with Display Value
In your controller/action that receives the form, you should be able to echo out the model value for the StatusId and see there if it is getting passed