Pessoal vlw pela ajuda até aqui… Consegui executar o código sem erro só que meu dataset ta vindo com umas coisas estranhas, acredito que sejam parâmetros do sistema, mas meus dados não vieram, novamente testei no SGBD e funciona balinha… Dei um echo
na dataset e peguei isso:
[code]ADORecordset_oci805 Object
(
[databaseType] => oci805
[bind] =>
[_fieldobjs] => Array
(
[0] => ADOFieldObject Object
(
[name] => ENCARGOS
[max_length] => 22
[type] => NUMBER
)
[1] => ADOFieldObject Object
(
[name] => VENDAINTERNAT
[max_length] => 22
[type] => NUMBER
)
[2] => ADOFieldObject Object
(
[name] => VENDAINTERNAR
[max_length] => 22
[type] => NUMBER
)
)
[dataProvider] => native
[fields] => Array
(
)
[blobSize] => 100
[canSeek] =>
[sql] => Select cr.ENCARGOS, pr.VENDAINTERNAT, pr.VENDAINTERNAR from
COMPLEMENTORAC cr, PRODUCAORAC pr
Where cr.EMPRESAS_IDEMPRESAS in(select EMPRESAS_IDEMPRESAS from COMPLEMENTORAC ) and
cr.ANO = ‘2007’ and
cr.MES = TO_CHAR(pr.PERIODO, ‘mm’) and
pr.PERIODO = TO_DATE(‘11’, ‘mm’) and
pr.EMPRESAS_IDEMPRESAS = cr.EMPRESAS_IDEMPRESAS
[EOF] => 1
[emptyTimeStamp] =>
[emptyDate] =>
[debug] =>
[timeCreated] => 0
[fetchMode] => 15
[connection] => ADODB_oci805 Object
(
[databaseType] => oci805
[connectSID] => 1
[dataProvider] => oci8
[replaceQuote] => ‘’
[concat_operator] => ||
[sysDate] => TRUNC(SYSDATE)
[sysTimeStamp] => SYSDATE
[metaDatabasesSQL] => SELECT USERNAME FROM ALL_USERS WHERE USERNAME NOT IN (‘SYS’,‘SYSTEM’,‘DBSNMP’,‘OUTLN’) ORDER BY 1
[_stmt] => Resource id #50
[_commit] => 32
[_initdate] => 1
[metaTablesSQL] => select table_name,table_type from cat where table_type in (‘TABLE’,‘VIEW’) and table_name not like ‘BIN$%’
[metaColumnsSQL] => select cname,coltype,width, SCALE, PRECISION, NULLS, DEFAULTVAL from col where tname=’%s’ order by colno
[_bindInputArray] => 1
[hasGenID] => 1
[_genIDSQL] => SELECT (%s.nextval) FROM DUAL
[_genSeqSQL] => CREATE SEQUENCE %s START WITH %s
[_dropSeqSQL] => DROP SEQUENCE %s
[hasAffectedRows] => 1
[random] => abs(mod(DBMS_RANDOM.RANDOM,10000001)/10000000)
[noNullStrings] =>
[_bind] =>
[_nestedSQL] => 1
[_hasOCIFetchStatement] => 1
[_getarray] =>
[leftOuter] =>
[session_sharing_force_blob] =>
[firstrows] => 1
[selectOffsetAlg1] => 100
[NLS_DATE_FORMAT] => RRRR-MM-DD HH24:MI:SS
[dateformat] => YYYY-MM-DD
[useDBDateFormatForTextInput] =>
[datetime] =>
[_refLOBs] => Array
(
)
[database] => 54.243.15.130/XE
[host] =>
[user] => ROOT
[password] => 90634JJY
[debug] => 1
[maxblobsize] => 262144
[substr] => substr
[length] => length
[upperCase] => upper
[fmtDate] => 'Y-m-d'
[fmtTimeStamp] => 'Y-m-d, h:i:s A'
[true] => 1
[false] => 0
[nameQuote] => "
[charSet] => WE8ISOICLUK
[uniqueOrderBy] =>
[emptyDate] =>
[emptyTimeStamp] =>
[lastInsID] =>
[hasInsertID] =>
[hasTop] =>
[hasLimit] =>
[readOnly] =>
[hasMoveFirst] =>
[hasTransactions] => 1
[genID] => 0
[raiseErrorFn] =>
[isoDates] =>
[cacheSecs] => 3600
[memCache] =>
[memCacheHost] =>
[memCachePort] => 11211
[memCacheCompress] =>
[arrayClass] => ADORecordSet_array
[numCacheHits] => 0
[numCacheMisses] => 0
[pageExecuteCountRows] => 1
[uniqueSort] =>
[rightOuter] =>
[ansiOuter] =>
[autoRollback] =>
[poorAffectedRows] =>
[fnExecute] =>
[fnCacheExecute] =>
[blobEncodeType] =>
[rsPrefix] => ADORecordSet_
[autoCommit] => 1
[transOff] => 0
[transCnt] => 0
[fetchMode] =>
[null2null] => null
[_oldRaiseFn] =>
[_transOK] =>
[_connectionID] => Resource id #35
[_errorMsg] =>
[_errorCode] =>
[_queryID] => Resource id #50
[_isPersistentConnection] =>
[_evalAll] =>
[_affected] =>
[_logsql] =>
[_transmode] =>
[bol_sc_debug] =>
[bol_sc_debug_level] => 0
)
[_numOfRows] => 0
[_numOfFields] => 3
[_queryID] => Resource id #50
[_currentRow] => 0
[_closed] =>
[_inited] => 1
[_obj] =>
[_names] =>
[_currentPage] => -1
[_atFirstPage] =>
[_atLastPage] =>
[_lastPageNo] => -1
[_maxRecordCount] => 0
[datetime] =>
[adodbFetchMode] => 0
)[/code]
meu código do botão ajax está assim:
[code]
/*QUERY PARA SELECIONAR OS VALORES PARA CALCULAR O PREÇO MÉDIO PRODUÇÂO RAC
$sql=“Select cr.ENCARGOS, pr.VENDAINTERNAT, pr.VENDAINTERNAR from
COMPLEMENTORAC cr, PRODUCAORAC pr
Where cr.EMPRESAS_IDEMPRESAS in(select EMPRESAS_IDEMPRESAS from COMPLEMENTORAC ) and
cr.ANO = ‘{ANO}’ and
cr.MES = TO_CHAR(pr.PERIODO, ‘mm’) and
pr.PERIODO = TO_DATE(’{MES}’, ‘mm’) and
pr.EMPRESAS_IDEMPRESAS = cr.EMPRESAS_IDEMPRESAS”;
sc_select (dataset, $sql);
/VERIFICA EXCESSÃO CASO NAO TENHA DADOS NO SELECT/
if(empty({dataset}))
{
sc_alert(‘ERRO na busca de dados!!!’);
}
else
{
echo ‘
’;
print_r({dataset});
echo ‘
’;
foreach({dataset} as $dt)
{
//Aqui o resultado será linha por linha e acessado por
{ENCARGOS}=$dt[0];//campo1 linha a linha
{VENDAINTERNAT}=$dt[2];//campo2 linha a linha
{VENDAINTERNAR}=$dt[3];//campo3 linha a linha
[preco_medio_global] = ((( VENDAINTERNAR / 1000 ) /VENDAINTERNAT ) / ENCARGOS );
/**
* Update a record on another table
*/
// SQL statement parameters
$update_table = 'PRODUCAORAC'; // Table name
$update_where = "ANO = {ANO} and PERIODO={MES}"; // Where clause
$update_fields = array("PRECO_MEDIO = [preco_medio_global]");
// Update record
$update_sql = 'UPDATE ' . $update_table
. ' SET ' . implode(', ', $update_fields)
. ' WHERE ' . $update_where;
sc_exec_sql($update_sql);
}
}[/code]