I have a Classic Report with a schedule for each day. There are no, one or multiple entries per day. It looks like this:
select
week_no,
apex_item.DISPLAY_AND_SAVE(p_idx => 8, p_value => plan_id) as ID,
apex_item.select_list(p_idx => 1, p_list_values => 'S1;1,S2;2,S3;3', p_attributes => 'size="3" multiple="multiple"', p_show_null => 'NO', p_show_extra => 'NO', p_item_id => plan_id || '_1', p_value => monday) as monday,
apex_item.select_list(p_idx => 2, p_list_values => 'S1;1,S2;2,S3;3', p_attributes => 'size="3" multiple="multiple"', p_show_null => 'NO', p_show_extra => 'NO', p_item_id => plan_id || '_2', p_value => tuesday) as tuesday,
apex_item.select_list(p_idx => 3, p_list_values => 'S1;1,S2;2,S3;3', p_attributes => 'size="3" multiple="multiple"', p_show_null => 'NO', p_show_extra => 'NO', p_item_id => plan_id || '_3', p_value => wednesday) as wednesday
from plan;
I can select multiple values and can save them to my table. It gets save like this "1,2". But I can't load the data rows with multiple selected values.
I can select multiple options with jQuery like this
$('#1000_1').val(["1","2"]);
but I don't know how to select the stored values from table with PL/SQL and then set the options selected with javascript.
I tried to load the data in an apex_item.text (id="1000_11" for monday etc.) and transfer the values in "After Refresh" DA to select list like that:
var sel_opt = $('#1000_11').val();
if (sel_opt == "1,2")
{
$('#1000_1').val(["1","2"]);
}
else if (sel_opt == "1,3")
{
$('#1000_1').val(["1","3"]);
}
else if (sel_opt == "2,3")
{
$('#1000_1').val(["2","3"]);
}
else if (sel_opt == "1,2,3")
{
$('#1000_1').val(["1","2","3"]);
}
It works, but maybe there's a smarter solution?
I create a sample Workspace on https://apex.oracle.com/pls/apex/f?p=4550:1:0:::::
Workspace: multi_select
Username: dev
Password: newYears3problems
I would create SELECT LIST page items for each selection menu and set their multi selection option to Yes.
then I'm guessing I'd need something like this somewhere at my page-process section
declare
array apex_application_global.vc_arr2;
begin
array := apex_util.string_to_table (:P30_SELECT_LIST_1);
apex_collection.create_or_truncate_collection ('P30_SELECT_LIST_1');
apex_collection.add_members ('P30_SELECT_LIST_1', array);
end;
to store more than one menu item at once.
then I'd add something like that to my query
and ITEM_1 in (
select c001
from apex_collections
where collection_name = 'P30_SELECT_LIST_1'
)
I probably didn't understand your question, but according to part that I get, it's straightforward sql query. no need for js.
I am trying to debug a core file that was generated on a test system. It was generated due to an assert() that was tripped.
The bt shows multiple frames with ?? followed by the actual functions. Not sure why that is so.
(gdb) bt
#0 0x00007f6c2d1eb035 in ?? ()
#1 0x00007f6c2d1ee79b in ?? ()
#2 0x00007f64fc3b0240 in ?? ()
#3 0x00007f6c2fdeb092 in ?? ()
#4 0x00007f6c2d1bbc58 in ?? ()
#5 0x00007f6c3205d9c0 in ?? ()
#6 0x0000000002a06a00 in ?? ()
#7 0x00007f64fc3b0150 in ?? ()
#8 0x00007f64fc3b0170 in ?? ()
#9 0x00000000018fb2cb in operator,<AssertCollectorBase> (this=<optimized out>, t=...) at ./shared/Assert.h:116
#10 X (platformContext=<optimized out>, severity=<optimized out>, msg=0x7f64fc3b0740 "Enabling poll on wrong connection.") at ss/*.cpp:497
#11 0x00000000025c2fd7 in Y (severity=1 '\001', msg=...) at *.cc:1065
#12 0x00000000025d0875 in Z (this=0x7f6bcbbbe440) at *.cc:870
#13 0x00007f6c2ebe0e9a in ?? ()
#14 0x0000000000000000 in ?? ()
I went to the frame containing the assert and tried printing out some local
and member variables. Some of the variables keep saying 'Cannot access memory 0x< some-memory-addr >'
I tried to print an STL map - but the pointers returned are always invalid.
(gdb) pmap connmap_ int SmaConnection*
elem[0].left: $1 = 219
elem[0].right: $2 = (SmaConnection *) 0x9c63d4e000007f6b
elem[1].left: $3 = 463
elem[1].right: $4 = (SmaConnection *) 0x9c63bd4000007f6b
elem[2].left: $5 = 469
elem[2].right: $6 = (SmaConnection *) 0x9c63e82000007f6b
elem[3].left: $7 = 471
(gdb) p *$2
Cannot access memory at address 0x9c63d4e000007f6b
(gdb)
The pointer values in the map always seem to be reported incorrectly by gdb, even when nothing goes wrong with the program.
Is there something wrong with the way I store the pointers in the map?
Is there something wrong I am doing with examining the map?
Is there something else I can do to access the memory correctly?
I had a similar problem because my code was in Release mode.
For example, did you add the flag -DCMAKE_BUILD_TYPE=Debug when you run cmake?
Or gcc -g option flag? (http://www.rapidtables.com/code/linux/gcc/gcc-g.htm)
The bt shows multiple frames with ?? followed by the actual functions. Not sure why that is so.
Most likely because of system library mismatch between the test and development systems. See this answer on how to fix it.
The pointer values in the map always seem to be reported incorrectly by gdb
If you do have a mismatch (which I am 99.9% certain you do), then you can ignore the rest of the stack -- it's guaranteed to be bogus.
I stumbled upon the auto-display functionality of gdb, which is pretty powerful and convenient. After calling
(gdb) display/i $pc
(gdb) display $rax
the watched values are displayed automatically after every step:
(gdb) si
0x0804805e in print_loop_start ()
2: $rax = 0
1: x/i $pc
=> 0x804805e <print_loop_start+6>: mov 0x4(%ebp,%eax,4),%ecx
But how can I "unwatch" the value in $rax, if it is no longer of interest?
Gdb help for display says:
"Use undisplay to cancel display requests previously made."
So if you do display a, then display b, and display c gdb will give numbers to this requests (which you can see by issuing replay with no arguments). Then you can use this numbers with undisplay.
Example:
(gdb) display a
1: a = 32767
(gdb) display b
2: b = 0
(gdb) display c
3: c = 0
(gdb) undisplay 2
(gdb) step
6 b = 2;
1: a = 1
3: c = 0
Details in gdb documentation.
Note that you can also temporarily hide a disp output using:
disable display dnums…
And re-enable with:
enable display dnums…
I've got this error: Teradata execute: Numeric overflow occurred during computation.
I have read the similar questions on this forum but still can't understand what should I do to resolve the problem.
I supposed that the reason is that I have computation on step when i devide NATIONAL_AMOUNT on DEBT_EXPENSE.
After using CAST there was no resolving still.
Has anyone thoughts? Please help me.
I think that the problem is here:
EXECUTE (create multiset volatile table Debt_&mon. AS
(SELECT
t1.TABLE_BUSINESS_MONTH,
t1.REGION,
t1.SEGMENT,
t1.ACC_METH,
COUNT(t1.ACC_N) as Count_ACC_N,
SUM(t1.NATIONAL_UNPAID) AS NATIONAL_UNPAID,
SUM(t1.DEBT_EXPENSE) as DEBT_EXPENSE,
SUM(t2.NATIONAL_AMOUNT) as NATIONAL_AMOUNT,
(case when SUM(t2.NATIONAL_AMOUNT)=0 then 0 else (cast(SUM(t1.DEBT_EXPENSE) as Decimal(20,6))/cast(SUM(t2.NATIONAL_AMOUNT) as Decimal(20,6)) end) as 'РСДЗ/Д'n,
(case when SUM(t1.DEBT_EXPENSE)=0 then 0 else cast(SUM(t2.NATIONAL_AMOUNT) as Decimal(20,6))/cast(SUM(t1.DEBT_EXPENSE) as Decimal(20,6)) end) as 'Д/ДЗ'n
FROM Prev_Debt_&mon. t1
LEFT JOIN CLC_&mon. t2 on
t1.REGION=t2.REGION and
t1.SEGMENT=t2.SEGMENT and
t1.ACC_METH=t2.ACC_METH
GROUP BY t1.TABLE_BUSINESS_MONTH, t1.REGION, t1.SEGMENT, t1.ACC_METH)
WITH DATA NO PRIMARY INDEX ON COMMIT PRESERVE ROWS;)
by teradata;
======================The full code below====================================
EXECUTE (create multiset volatile table CLC_&mon. AS
(SELECT
t1.TABLE_BUSINESS_MONTH,
t1.REGION,
Case when t2.SEGMENT is Null then 'NEW' else t2.SEGMENT end as "SEGMENT",
t1.ACC_METH,
COUNT(t1.ACC_N) as Count_ACC_N,
SUM(t1.NATIONAL_AMOUNT) AS NATIONAL_AMOUNT,
SUM(t1.NATIONAL_AMOUNT)/COUNT(t1.ACC_N) as 'ARPaU'n
FROM UAT_V_BASE.RA_FCLC_ACC t1
LEFT JOIN prd_sbx_general.&login._LIST_MK_2 t2 ON (t1.MARKET_CATEGORY=t2.MARKET_CATEGORY)
GROUP BY t1.TABLE_BUSINESS_MONTH, t1.REGION, "SEGMENT", t1.ACC_METH
WHERE SEGMENT in ('B2C','B2B','VIP','OTHER')
AND t1.ACC_METH in (1, 2)
AND TABLE_BUSINESS_MONTH between &firstmonth. and &lastmonth.
AND MRGN_ID=&MR.)
WITH DATA NO PRIMARY INDEX ON COMMIT PRESERVE ROWS;)
by teradata;
create table CLC_&mon. as select
TABLE_BUSINESS_MONTH FORMAT=Date9.,
REGION FORMAT=FSRGC.,
SEGMENT FORMAT=$9.,
ACC_METH FORMAT=F78C.,
Count_ACC_N,
NATIONAL_AMOUNT FORMAT=NUMX16.2 LABEL="(Сумма начислений с учетом налогов), RUB)",
'ARPaU'n
from connection to teradata
(select distinct
TABLE_BUSINESS_MONTH,
REGION,
SEGMENT,
ACC_METH,
Count_ACC_N,
NATIONAL_AMOUNT,
'ARPaU'n
GROUP BY TABLE_BUSINESS_MONTH, REGION, SEGMENT, ACC_METH, Count_ACC_N, NATIONAL_AMOUNT,'ARPaU'n
ORDER BY TABLE_BUSINESS_MONTH, REGION, SEGMENT, ACC_METH
from CLC_&mon.);
EXECUTE (create multiset volatile table Prev_Debt_&mon. AS
(SELECT
t1.TABLE_BUSINESS_MONTH,
t1.REGION,
Case when t2.SEGMENT is Null then 'NEW' else t2.SEGMENT end as "SEGMENT",
t1.ACC_METH,
t1.BASE_AGE,
Case when t1.BASE_AGE=-1 then 'ОДЗ'
when t1.BASE_AGE=3 then 'CДЗ'
else 'Другая ДЗ'
end as "Tип ДЗ",
Case when t1.NATIONAL_UNPAID between 0 and 200000 then '0...200'
when t1.NATIONAL_UNPAID between 200000 and 500000 then '200...500'
else '> 500' end as 'Amount_of_Debt'n,
t1.ACC_N,
SUM(t1.NATIONAL_UNPAID) AS NATIONAL_UNPAID,
Case when t1.EXCEPTED_FROM_BUH eq 0 then (t1.NT_BUH_DELTA + t1.NT_WRITE_OFF)
else t1.NT_WRITE_OFF_COLLFIN
end AS DEBT_EXPENSE
FROM UAT_V_BASE.RA_FDEB_ACC t1
LEFT JOIN prd_sbx_general.&login._LIST_MK_2 t2 ON (t1.MARKET_CATEGORY=t2.MARKET_CATEGORY)
WHERE SEGMENT in ('B2C','B2B','VIP','OTHER')
AND t1.ACC_METH in (1, 2)
AND TABLE_BUSINESS_MONTH between &firstmonth. and &lastmonth.
AND MRGN_ID=&MR.
GROUP BY t1.TABLE_BUSINESS_MONTH, t1.REGION, "SEGMENT", t1.ACC_METH, t1.BASE_AGE,'Tип ДЗ'n, t1.ACC_N, 'Amount_of_Debt'n, "DEBT_EXPENSE")
WITH DATA PRIMARY INDEX (ACC_N) ON COMMIT PRESERVE ROWS;)
by teradata;
EXECUTE (create multiset volatile table Debt_&mon. AS
(SELECT
t1.TABLE_BUSINESS_MONTH,
t1.REGION,
t1.SEGMENT,
t1.ACC_METH,
COUNT(t1.ACC_N) as Count_ACC_N,
SUM(t1.NATIONAL_UNPAID) AS NATIONAL_UNPAID,
SUM(t1.DEBT_EXPENSE) as DEBT_EXPENSE,
SUM(t2.NATIONAL_AMOUNT) as NATIONAL_AMOUNT,
(case when SUM(t2.NATIONAL_AMOUNT)=0 then 0 else (cast(SUM(t1.DEBT_EXPENSE) as Decimal(20,6))/cast(SUM(t2.NATIONAL_AMOUNT) as Decimal(20,6)) end) as 'РСДЗ/Д'n,
(case when SUM(t1.DEBT_EXPENSE)=0 then 0 else cast(SUM(t2.NATIONAL_AMOUNT) as Decimal(20,6))/cast(SUM(t1.DEBT_EXPENSE) as Decimal(20,6)) end) as 'Д/ДЗ'n
FROM Prev_Debt_&mon. t1
LEFT JOIN CLC_&mon. t2 on
t1.REGION=t2.REGION and
t1.SEGMENT=t2.SEGMENT and
t1.ACC_METH=t2.ACC_METH
GROUP BY t1.TABLE_BUSINESS_MONTH, t1.REGION, t1.SEGMENT, t1.ACC_METH)
WITH DATA NO PRIMARY INDEX ON COMMIT PRESERVE ROWS;)
by teradata;
Create table RSDZ_&mon. as select
TABLE_BUSINESS_MONTH FORMAT=Date9.,
REGION FORMAT=FSRGC.,
SEGMENT FORMAT=$9.,
ACC_METH FORMAT=F78C.,
Count_ACC_N,
NATIONAL_UNPAID FORMAT=NUMX16.2 ,
DEBT_EXPENSE FORMAT=NUMX16.2,
NATIONAL_AMOUNT FORMAT=NUMX16.2,
'РСДЗ/Д'n FORMAT=NUMX16.10,
'Д/ДЗ'n FORMAT=NUMX16.10
from connection to teradata
(select distinct
TABLE_BUSINESS_MONTH,
REGION,
SEGMENT,
ACC_METH,
Count_ACC_N,
NATIONAL_UNPAID,
DEBT_EXPENSE,
NATIONAL_AMOUNT,
'РСДЗ/Д'n,
'Д/ДЗ'n
GROUP BY TABLE_BUSINESS_MONTH, REGION, SEGMENT, ACC_METH, Count_ACC_N, NATIONAL_UNPAID, DEBT_EXPENSE, NATIONAL_AMOUNT, 'РСДЗ/Д'n, 'Д/ДЗ'n
ORDER BY TABLE_BUSINESS_MONTH, REGION, SEGMENT, ACC_METH
from Debt_&mon.);
Use Bigint instead of INTEGER?DECIMAL while casting your numeric columns
Actualy, I found how to solve my problem. I took my code where I had trouble apart from full code.
The log got the error "Numeric overflow occurred during computation." but sighned that the trouble is with column NATIONAL_AMOUNT.
Then I changed my SUM(t2.NATIONAL_AMOUNT) as NATIONAL_AMOUNT, on t2.NATIONAL_AMOUNT.
After that code had worked.
I agregated my t2.NATIONAL_AMOUNT on previous step and I should'n agregete it twice.
My environment is Ruby 1.8.7-p358 with Rails 2.3.11. I am trying to query for all accounts that have a first_name containing only numbers (they are all 3 digit integers, i.e. 001, 143, 815, etc.). I have been trying to use this query:
Account.find(:all, :conditions => ["first_name LIKE ?", "[^0-9][^0-9][^0-9]"])
All I get in return is => [].
If I use the same query only with NOT LIKE I get all accounts, including the ones where first_name is an integer.
I've also tried using:
Account.find(:all, :conditions => ["first_name REGEXP ?", "[^0-9][^0-9][^0-9]"])
but that only gives me:
ActiveRecord::StatementInvalid: PGError: ERROR: syntax error at or near "REGEXP"
LINE 1: SELECT * FROM "accounts" WHERE (first_name REGEXP '[0-9][0-9...
^
: SELECT * FROM "accounts" WHERE (first_name REGEXP '[0-9][0-9][0-9]') ORDER BY first_name ASC
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract_adapter.rb:227:in `log'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/connection_adapters/postgresql_adapter.rb:520:in `execute'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/connection_adapters/postgresql_adapter.rb:1002:in `select_raw'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/connection_adapters/postgresql_adapter.rb:989:in `select'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/base.rb:665:in `find_by_sql'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/base.rb:1582:in `find_every'
from /Users/kyle/.rvm/gems/ruby-1.8.7-p358#popcorn_recruiter_portal/gems/activerecord-2.3.11/lib/active_record/base.rb:619:in `find'
from (irb):189
from :0
Are regular expressions not allowed? How am I able to find each account with a first_name that's equal to a three digit integer?
The like operator does not evaluate regular expressions. In instead you can use both similar to:
select '980' similar to '[0-9][0-9][0-9]';
?column?
----------
t
Or ~:
select '980' ~ '[0-9][0-9][0-9]';
?column?
----------
t
(1 row)