-insert into alias (nom, cmd, argc, help) values ('tables', 'select tablename from pg_tables', 0, 'list table (every table...)');
+insert into alias (nom, cmd, argc, help) values ('tables', 'select tablename from pg_tables where tableowner=current_user', 0, 'list table (every table...)');
INSERT INTO alias (nom, cmd, argc, help) VALUES ('ls', 'select id,texte from raw order by date asc;', 0, 'list id,text of every records');
insert into alias (nom, cmd, argc, help) values ('ls', 'select * from raw where id=$1 order by date asc;', 1, 'print id,date,text of one record');
insert into alias (nom, cmd, argc, help) values ('ls', 'select * from raw where date between $1 and $2 order by date asc;', 2, 'liste record with date between $1 and $2');
insert into alias (nom, cmd, argc, help) values ('help', 'select help from alias where nom=$1 and argc=$2', 2, 'print help for only one alias (as "nom" and "argc" is a key)');
insert into alias (nom, cmd, argc, help) values ('print', 'select cmd,inf from alias where nom=$1 and argc=$2', 2, 'print SQL command of an alias (...)');
insert into alias (nom, cmd, argc, inf, help) values ('default', 'INSERT INTO raw (date, texte) VALUES ($1::timestamp, $2::text);', 2 , '1', 'default command');
+insert into alias (nom, cmd, argc, inf, help) values ('aliasadd', 'insert into alias (nom, argc, cmd) values ( $1, $2, $3 );', 3, '1', 'add alias (with form : aliasadd "name" "argc" "SQL")');
int hm;
diary.getvar();
do{
- clog<<"again\n";
+ clog<<"======================again=================================\n";
hm=diary.hmRecord();
cout<<hm<<shell;
getline(cin,rep,'\n');
//cut rep into words[0], words[1], ...
while (ss >> buf) words.push_back(buf);
if(words.size()==0)break;//quit
- else if (words[0]=="w") diary.exec(words);
else if (words[0]=="p") diary.print();
- //else if (words[0]=="help") diary.help(); now into SQL
else if (words[0]=="status") diary.status();
-
else if (words[0]=="con") diary.printvar();
- else if ((words[0]=="alias")&&(words.size()>1)) {
- if (words[1]=="add") {
- string cmd="";
- for (int a=3; a<words.size()-1; a++){
- cmd=cmd+words[a]+" ";
- }
- cmd=cmd+words[words.size()-1];
- diary.exec("insert into alias (nom, command) values ( '"+words[2]+"', '"+cmd+"' );");
- }
- else if (words[1]=="list") {diary.exec("select * from alias;");diary.print();}
- }
else if (words[0]=="!") {
string a=rep.substr(2);
diary.exec(a);
else {
/*vector<string>::iterator it;
it = words.begin();
- it = words.insert ( it , "default");
+ it = words.insert (it, "now");
+ it = words.insert (it, "default");
diary.alias(words);*/
diary.insert(words);
}
binary[inf-inf]=0;
}
clog<<"if(inf!=0) finish\n";
- for(int k=0; k<(argc+inf); k++){
+ for(int k=0; k<(argc); k++){
clog<<"value["<<k<<"]="<<value[k]<<" length="<<length[k]<<"\n";
}
-
-
-
-
-
clog<<"cmd2="<<cmd2<<" argc="<<argc<<endl;
res=PQprepare(conn, "execalias",cmd2.c_str(), argc, NULL);
clog<<"PQprepart done(cmd2="<<cmd2<<" argc="<<argc<<"\n";
value.insert(pair<string, string> (a, b) );
};
- clog<<"value.size="<<value.size();
+ clog<<"value.size="<<value.size()<<endl;
};
#endif