Link to home
Start Free TrialLog in
Avatar of MrTV
MrTVFlag for Thailand

asked on

put constant from select to insert into field Posgresql

In code line 14   i want to put table name into  field   filname   but this code put all column in each row to filed  filname  how cani fixit

sc_lookup(Dataset, "SELECT  tablename FROM pg_catalog.pg_tables
where schemaname = 'public'and tablename not like 'pong8%' order by tablename") ;

{TabName} = {Dataset[33][0]};

$table = {TabName} ;
echo "$table";

$sql ='INSERT INTO pong8_maintable ("filname","timestamp8","Last","TradePrice", "TradeVolume" , "BestBid", "BidSize", "BestAsk","AskSize" ,"Turnover" ,"CalcVWAP" ,"Flow" ,"TradeFlags"

) 

SELECT
'.$table.' ,
cast(public.'.$table.'."Timestamp" as timestamp) ,
cast(public.'.$table.'."Last" as numeric)  ,
cast(public.'.$table.'."Trade Price" as numeric)  ,  
cast(public.'.$table.'."Trade Volume" as numeric),
cast(public.'.$table.'."Best Bid" as numeric),
cast(public.'.$table.'."Bid Size"as numeric),
cast(public.'.$table.'."Best Ask"as numeric),
cast(public.'.$table.'."Ask Size"as numeric),
cast(public.'.$table.'."Turnover"as numeric),
cast(public.'.$table.'."Calc VWAP"as numeric),
cast(public.'.$table.'."Flow"as numeric),
cast(public.'.$table.'."Trade Flags"as varchar)

FROM Public.'.{TabName}; 


sc_exec_sql($sql);

Open in new window

SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial